diff --git a/plugins/inputs/consul/consul.go b/plugins/inputs/consul/consul.go index 0eaa25604..45612a928 100644 --- a/plugins/inputs/consul/consul.go +++ b/plugins/inputs/consul/consul.go @@ -69,6 +69,10 @@ func (c *Consul) createAPIClient() (*api.Client, error) { config.Datacenter = c.Datacentre } + if c.Token != "" { + config.Token = c.Token + } + if c.Username != "" { config.HttpAuth = &api.HttpBasicAuth{ Username: c.Username, diff --git a/plugins/inputs/consul/consul_test.go b/plugins/inputs/consul/consul_test.go index d0595508d..bbb43d066 100644 --- a/plugins/inputs/consul/consul_test.go +++ b/plugins/inputs/consul/consul_test.go @@ -20,7 +20,7 @@ var sampleChecks = []*api.HealthCheck{ }, } -func TestGatherHealtCheck(t *testing.T) { +func TestGatherHealthCheck(t *testing.T) { expectedFields := map[string]interface{}{ "check_name": "foo.health", "status": "passing",