diff --git a/CHANGELOG.md b/CHANGELOG.md index 777eefbdf..f3e0626d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ It is highly recommended that all users migrate to the new riemann output plugin - [#2251](https://github.com/influxdata/telegraf/pull/2251): InfluxDB output: use own client for improved through-put and less allocations. - [#1900](https://github.com/influxdata/telegraf/pull/1900): Riemann plugin rewrite. - [#1453](https://github.com/influxdata/telegraf/pull/1453): diskio: add support for name templates and udev tags. +- [#2277](https://github.com/influxdata/telegraf/pull/2277): add integer metrics for Consul check health state. ### Bugfixes diff --git a/plugins/inputs/consul/README.md b/plugins/inputs/consul/README.md index 01a39cbf7..dbb576421 100644 --- a/plugins/inputs/consul/README.md +++ b/plugins/inputs/consul/README.md @@ -35,12 +35,19 @@ Fields: - check_name - service_id - status +- passing +- critical +- warning + +`passing`, `critical`, and `warning` are integer representations of the health +check state. A value of `1` represents that the status was the state of the +the health check at this sample. ## Example output ``` $ telegraf --config ./telegraf.conf -input-filter consul -test * Plugin: consul, Collection 1 -> consul_health_checks,host=wolfpit,node=consul-server-node,check_id="serfHealth" check_name="Serf Health Status",service_id="",status="passing" 1464698464486439902 -> consul_health_checks,host=wolfpit,node=consul-server-node,service_name=www.example.com,check_id="service:www-example-com.test01" check_name="Service 'www.example.com' check",service_id="www-example-com.test01",status="critical" 1464698464486519036 +> consul_health_checks,host=wolfpit,node=consul-server-node,check_id="serfHealth" check_name="Serf Health Status",service_id="",status="passing",passing=1i,critical=0i,warning=0i 1464698464486439902 +> consul_health_checks,host=wolfpit,node=consul-server-node,service_name=www.example.com,check_id="service:www-example-com.test01" check_name="Service 'www.example.com' check",service_id="www-example-com.test01",status="critical",passing=0i,critical=1i,warning=0i 1464698464486519036 ``` diff --git a/plugins/inputs/consul/consul.go b/plugins/inputs/consul/consul.go index 4c28f4d12..0eaa25604 100644 --- a/plugins/inputs/consul/consul.go +++ b/plugins/inputs/consul/consul.go @@ -97,7 +97,12 @@ func (c *Consul) GatherHealthCheck(acc telegraf.Accumulator, checks []*api.Healt record["check_name"] = check.Name record["service_id"] = check.ServiceID + record["status"] = check.Status + record["passing"] = 0 + record["critical"] = 0 + record["warning"] = 0 + record[check.Status] = 1 tags["node"] = check.Node tags["service_name"] = check.ServiceName diff --git a/plugins/inputs/consul/consul_test.go b/plugins/inputs/consul/consul_test.go index f970d4449..d0595508d 100644 --- a/plugins/inputs/consul/consul_test.go +++ b/plugins/inputs/consul/consul_test.go @@ -24,6 +24,9 @@ func TestGatherHealtCheck(t *testing.T) { expectedFields := map[string]interface{}{ "check_name": "foo.health", "status": "passing", + "passing": 1, + "critical": 0, + "warning": 0, "service_id": "foo.123", }