garrettsickles / DogFood

A C++, header only library for DataDog communication on Windows, Mac, and Linux
MIT License
15 stars 4 forks source link

Unix socket support #17

Open xkrt opened 5 years ago

xkrt commented 5 years ago

Hi!

Please, support Unix socket: https://docs.datadoghq.com/developers/dogstatsd/unix_socket/

garrettsickles commented 5 years ago

@xkrt If you have any setup advice for getting UDS setup and running on a linux host it would be greatly appreciated. I am struggling to get the DataDog agent properly configured despite DataDog's current documentation.

garrettsickles commented 5 years ago

For now I would recommend DataDog's method for bypassing this issue until I implement it

xkrt commented 5 years ago

@garrettsickles I already have applications that use DD UDS, they have written in Java and Python and using java-dogstatsd-client and datadog libs.

In my /etc/datadog-agent/datadog.yaml configuration I have:

dogstatsd_socket: /var/run/datadog/dsd.socket

And directory and socket permissions:

# ls -la /var/run/datadog/
total 0
drwxrwxrwx  2 dd-agent dd-agent  60 Apr 19 05:36 .
drwxr-xr-x 27 root     root     780 Apr 24 07:09 ..
srwx-w--w-  1 dd-agent dd-agent   0 Apr 19 05:36 dsd.socket

My application runs in a docker container and there is important to map directory with a socket from host to container, not socket itself (DD docs):

docker run \
  -v "/var/run/datadog:/var/run/datadog:ro"
  <other args>

For now, my C++ application uses your DogFood with UDP socket, but I want to change it to UDS socket in future just like my other applications in Java/Python.

Please, let me know if I could help you somehow.

garrettsickles commented 5 years ago

@xkrt Thanks for the information. I am working on debugging why my ubuntu agent is not working properly (Mine will not create the socket in /var/run/datadog no matter what I do). Am I misunderstanding that the datadog agent should be setting up the UDS socket on its own?

garrettsickles commented 5 years ago

@xkrt I dove a little deeper and found this in the logs btw...

2019-04-25 19:59:51 PDT | CORE | ERROR | (pkg/dogstatsd/server.go:104 in NewServer) | can't listen: listen unixgram /var/run/datadog/dsd.socket: bind: no such file or directory
2019-04-25 19:59:51 PDT | CORE | INFO | (cmd/agent/app/start.go:210 in StartAgent) | logs-agent disabled
2019-04-25 19:59:51 PDT | CORE | INFO | (pkg/tagger/tagger.go:82 in Init) | starting the tagging system
2019-04-25 19:59:51 PDT | CORE | INFO | (pkg/dogstatsd/listeners/udp.go:77 in Listen) | dogstatsd-udp: starting to listen on 127.0.0.1:8125

As you can see the agent tries to open the socket, fails, then falls back to UDP.

garrettsickles commented 5 years ago
mkdir /var/run/datadog/
sudo chown dd-agent:dd-agent -R /var/run/datadog/

That did the trick. Should have a release out tonight. :)

garrettsickles commented 5 years ago

https://github.com/garrettsickles/DogFood/pull/19

xkrt commented 5 years ago

I used DogFood v2 in my production with UDS and all works fine. Thanks!