Last active
March 19, 2023 20:10
-
-
Save sandys/9c3798f60caaa6449a889bd7b605a177 to your computer and use it in GitHub Desktop.
Getting Datadog logs to work with Docker Swarm or journald
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Datadog Docker Swarm | |
After=systemd-journald.service | |
Requires=systemd-journald.service | |
[Service] | |
ExecStart=/bin/zsh -c "coproc while true; do ncat --ssl intake.logs.datadoghq.com 10516; done ;journalctl -o json -f | jq -r --unbuffered '\"c441ade4f5f4d04c \" + ({ message:.MESSAGE, service_name:.COM_DOCKER_SWARM_SERVICE_NAME, container:.CONTAINER_NAME, containerid:.CONTAINER_ID_FULL, host:._HOSTNAME,pid:(._PID // \"-\"), timestamp:(.__REALTIME_TIMESTAMP|tonumber/1000000|todate),\"syslog.severity\":((.PRIORITY|tonumber)) }|tostring)' >&p 2>&p" | |
ExecStop=/bin/sh -c "pkill -f 'journalctl -o json -f'" | |
TimeoutStartSec=0 | |
Restart=always | |
RestartSec=5s | |
[Install] | |
WantedBy=multi-user.target | |
[X-Fleet] | |
Global=true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment