diff --git a/plugins/inputs/consul/README.md b/plugins/inputs/consul/README.md index a2685e2bf..01a39cbf7 100644 --- a/plugins/inputs/consul/README.md +++ b/plugins/inputs/consul/README.md @@ -29,9 +29,9 @@ to query the data. It will not report the [telemetry](https://www.consul.io/docs Tags: - node: on which node check/service is registered on - service_name: name of the service (this is the service name not the service ID) +- check_id Fields: -- check_id - check_name - service_id - status @@ -41,6 +41,6 @@ Fields: ``` $ 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" 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 ``` diff --git a/plugins/inputs/consul/consul.go b/plugins/inputs/consul/consul.go index eaeae73c1..4c28f4d12 100644 --- a/plugins/inputs/consul/consul.go +++ b/plugins/inputs/consul/consul.go @@ -95,13 +95,13 @@ func (c *Consul) GatherHealthCheck(acc telegraf.Accumulator, checks []*api.Healt record := make(map[string]interface{}) tags := make(map[string]string) - record["check_id"] = check.CheckID record["check_name"] = check.Name record["service_id"] = check.ServiceID record["status"] = check.Status tags["node"] = check.Node tags["service_name"] = check.ServiceName + tags["check_id"] = check.CheckID acc.AddFields("consul_health_checks", record, tags) } diff --git a/plugins/inputs/consul/consul_test.go b/plugins/inputs/consul/consul_test.go index 772ccba91..f970d4449 100644 --- a/plugins/inputs/consul/consul_test.go +++ b/plugins/inputs/consul/consul_test.go @@ -22,7 +22,6 @@ var sampleChecks = []*api.HealthCheck{ func TestGatherHealtCheck(t *testing.T) { expectedFields := map[string]interface{}{ - "check_id": "foo.health123", "check_name": "foo.health", "status": "passing", "service_id": "foo.123", @@ -31,6 +30,7 @@ func TestGatherHealtCheck(t *testing.T) { expectedTags := map[string]string{ "node": "localhost", "service_name": "foo", + "check_id": "foo.health123", } var acc testutil.Accumulator