Last active
August 15, 2018 14:14
-
-
Save allanbatista/b19a27f540ecf2264d6999d71cc8546a to your computer and use it in GitHub Desktop.
How Configure Docker to delivery log to logstash
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
# /etc/docker/daemon.json | |
{ | |
"log-driver": "gelf", | |
"log-opts": { | |
"gelf-address": "udp://127.0.0.1:12201", | |
"labels": "production_status", | |
"env": "os,customer" | |
} | |
} |
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
# /etc/logstash/conf.d/logstash.conf | |
input { | |
gelf {} | |
} | |
filter { | |
ruby { | |
code => " | |
require 'json' | |
parsed = JSON.parse(event.get('message')) rescue {} | |
event.set('message_parsed', parsed) | |
" | |
} | |
} | |
output { | |
elasticsearch { | |
hosts => ["localhost:9200"] | |
index => "index_name-%{+YYYY.MM.dd}" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment