Skip to content

Instantly share code, notes, and snippets.

@sandys
Last active Mar 22, 2018
Embed
What would you like to do?
Getting Datadog logs to work with Docker Swarm or journald
[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