Add numerical representation of Consul health check state. (#2277)

This commit is contained in:
John Engelman 2017-01-28 18:47:25 -06:00 committed by Cameron Sparr
parent 28314f93b6
commit ce2ad1a74c
4 changed files with 18 additions and 2 deletions

View File

@ -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. - [#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. - [#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. - [#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 ### Bugfixes

View File

@ -35,12 +35,19 @@ Fields:
- check_name - check_name
- service_id - service_id
- status - 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 ## Example output
``` ```
$ telegraf --config ./telegraf.conf -input-filter consul -test $ telegraf --config ./telegraf.conf -input-filter consul -test
* Plugin: consul, Collection 1 * 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,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" 1464698464486519036 > 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
``` ```

View File

@ -97,7 +97,12 @@ func (c *Consul) GatherHealthCheck(acc telegraf.Accumulator, checks []*api.Healt
record["check_name"] = check.Name record["check_name"] = check.Name
record["service_id"] = check.ServiceID record["service_id"] = check.ServiceID
record["status"] = check.Status record["status"] = check.Status
record["passing"] = 0
record["critical"] = 0
record["warning"] = 0
record[check.Status] = 1
tags["node"] = check.Node tags["node"] = check.Node
tags["service_name"] = check.ServiceName tags["service_name"] = check.ServiceName

View File

@ -24,6 +24,9 @@ func TestGatherHealtCheck(t *testing.T) {
expectedFields := map[string]interface{}{ expectedFields := map[string]interface{}{
"check_name": "foo.health", "check_name": "foo.health",
"status": "passing", "status": "passing",
"passing": 1,
"critical": 0,
"warning": 0,
"service_id": "foo.123", "service_id": "foo.123",
} }