Last active
March 4, 2016 23:55
-
-
Save alq666/a2f79293df9bf8b028bf to your computer and use it in GitHub Desktop.
Datadog from gawk
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
/app/ { | |
split($7, arr, "/"); | |
host = arr[2]; | |
if (host == "<NOSRV>") { | |
host = "nosrv"; | |
} | |
split($8, arr, "/"); | |
tq = arr[1]; | |
tw = arr[2]; | |
tc = arr[3]; | |
tr = arr[4]; | |
tt = arr[5]; | |
split($18, arr, "?"); | |
stem = arr[1]; | |
# send to dogstatsd | |
d = "app.connection.error:1|c|#server:" host ",stem:" stem; | |
print d > "/inet4/udp/0/localhost/8125"; | |
close("/inet4/udp/0/localhost/8125"); | |
# send other metrics | |
d = "haproxy.request.tq:" tq "|ms|#server:" host ",stem:" stem; | |
print d > "/inet4/udp/0/localhost/8125"; | |
close("/inet4/udp/0/localhost/8125"); | |
d = "haproxy.request.tw:" tw "|ms|#server:" host ",stem:" stem; | |
print d > "/inet4/udp/0/localhost/8125"; | |
close("/inet4/udp/0/localhost/8125"); | |
d = "haproxy.request.tc:" tc "|ms|#server:" host ",stem:" stem; | |
print d > "/inet4/udp/0/localhost/8125"; | |
close("/inet4/udp/0/localhost/8125"); | |
d = "haproxy.request.tr:" tr "|ms|#server:" host ",stem:" stem; | |
print d > "/inet4/udp/0/localhost/8125"; | |
close("/inet4/udp/0/localhost/8125"); | |
d = "haproxy.request.tt:" tt "|ms|#server:" host ",stem:" stem; | |
print d > "/inet4/udp/0/localhost/8125"; | |
close("/inet4/udp/0/localhost/8125"); | |
} |
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
# in this case, mpstat 1 | gawk -f metric.awk | |
# change the metric name at will | |
/all/ { | |
d = "system.cpu.mpstat.idle:" $NF "|g"; | |
print d > "/inet4/udp/0/localhost/8125"; | |
close("/inet4/udp/0/localhost/8125"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment