-
-
Save jib/4112f72078071ce19b9b to your computer and use it in GitHub Desktop.
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
1) An event that won't be converted to JSON | |
======== prn =============== | |
#riemann.codec.Event{:host "ops-dev005", :service "check_http.py", :state "warning", :description "audience_segments: HTTP 503 from http://localhost/audience_segments/__status?indent=4", :metric nil, :tags ["puppet_environment:development" "zone:us-east-1e" "s_sandbox::charlie" "instance_type:c1.medium" "instance_id:i-13ff6b75" "security_group:krux-ops-dev" "team:ops"], :time 1353009793609/1000, :ttl nil} | |
======== tcp send ========== | |
INFO [2012-11-15 20:03:13,610] pool-489-thread-4 - krux.test - About to send event: #riemann.codec.Event{:host ops-dev005, :service check_http.py, :state warning, :description audience_segments: HTTP 503 from http://localhost/audience_segments/__status?indent=4, :metric nil, :tags [puppet_environment:development zone:us-east-1e s_sandbox::charlie instance_type:c1.medium instance_id:i-13ff6b75 security_group:krux-ops-dev team:ops], :time 1353009793609/1000, :ttl nil} | |
INFO [2012-11-15 20:03:13,610] pool-489-thread-4 - krux.test - About to convert to JSON: #riemann.codec.Event{:host ops-dev005, :service check_http.py, :state warning, :description audience_segments: HTTP 503 from http://localhost/audience_segments/__status?indent=4, :metric nil, :tags [puppet_environment:development zone:us-east-1e s_sandbox::charlie instance_type:c1.medium instance_id:i-13ff6b75 security_group:krux-ops-dev team:ops], :time 1353009793609/1000, :ttl nil} | |
### Note: there's no JSON string generated | |
===================================== | |
2) An event converted to malformed JSON | |
======== prn =============== | |
#riemann.codec.Event{:host "ops-dev005", :service "check_http.py", :state "warning", :description "urlmapper_store: HTTP 503 from http://localhost/store/__status", :metric nil, :tags ["puppet_environment:development" "zone:us-east-1e" "s_sandbox::charlie" "instance_type:c1.medium" "instance_id:i-13ff6b75" "security_group:krux-ops-dev" "team:ops"], :time 1353009793579/1000, :ttl nil} | |
======== tcp send ========== | |
INFO [2012-11-15 20:03:13,580] pool-486-thread-4 - krux.test - About to send event: #riemann.codec.Event{:host ops-dev005, :service check_http.py, :state warning, :description urlmapper_store: HTTP 503 from http://localhost/store/__status, :metric nil, :tags [puppet_environment:development zone:us-east-1e s_sandbox::charlie instance_type:c1.medium instance_id:i-13ff6b75 security_group:krux-ops-dev team:ops], :time 1353009793579/1000, :ttl nil} | |
INFO [2012-11-15 20:03:13,580] pool-486-thread-4 - krux.test - About to convert to JSON: #riemann.codec.Event{:host ops-dev005, :service check_http.py, :state warning, :description urlmapper_store: HTTP 503 from http://localhost/store/__status, :metric nil, :tags [puppet_environment:development zone:us-east-1e s_sandbox::charlie instance_type:c1.medium instance_id:i-13ff6b75 security_group:krux-ops-dev team:ops], :time 1353009793579/1000, :ttl nil} | |
INFO [2012-11-15 20:03:13,580] pool-486-thread-4 - krux.test - Will be writing this string: {"description":"urlmapper_store: HTTP 503 from http://localhost/store/__status","tags":["puppet_environment:development","zone:us-east-1e","s_sandbox::charlie","instance_type:c1.medium","instance_id:i-13ff6b75","security_group:krux-ops-dev","team:ops"],"service":"check_http.py","ttl":null,"metric":null,"state":"warning","host":"ops-dev005","time"} | |
### Note: the JSON string is malformed, with "time" not having a value. | |
====================================== | |
====== code for tcp send ============ | |
(fn [event] | |
(info "About to send event:" event) | |
;(when (:metric event) | |
(with-pool [ [sock out] pool (:claim-timeout opts) ] | |
(let [ | |
debug (info "About to convert to JSON:" event) | |
; generate a JSON string from the event, a la pagerduty | |
string (str (json/generate-string event) "\n") ] | |
(info "Will be writing this string:" string) | |
(.write ^OutputStreamWriter out string) | |
(.flush ^OutputStreamWriter out) | |
) | |
) | |
;) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment