prometheus / consul_exporter

Exporter for Consul metrics
Apache License 2.0
440 stars 167 forks source link

ACL support #39

Closed deepthawtz closed 7 years ago

deepthawtz commented 7 years ago

once a consul cluster is locked down w/ ACL consul_exporter cannot export metrics

I added this to enable support for that and tested:

diff --git a/consul_exporter.go b/consul_exporter.go
index 77d6790..dae7356 100644
--- a/consul_exporter.go
+++ b/consul_exporter.go
@@ -107,6 +107,7 @@ func NewExporter(uri, kvPrefix, kvFilter string, healthSummary bool, consulTimeo
                Address:    u.Host,
                Scheme:     u.Scheme,
                HttpClient: httpClient,
+               Token:      os.Getenv("CONSUL_TOKEN"),
        })

I made CONSUL_TOKEN an environment variable so I don't have to expose it in a command

grobie commented 7 years ago

@deepthawtz I think this is called CONSUL_HTTP_TOKEN in the consul code base, right? Any reason not to use the same name?

Actually, I think this should work already by setting the right environment variable.

deepthawtz commented 7 years ago

you are correct https://github.com/hashicorp/consul/blob/c744792fc4d665363dba0ecfc7d05fdedc9cab32/api/api.go#L210-L212

merely setting CONSUL_HTTP_TOKEN will be enough

grobie commented 7 years ago

It actually doesn't work yet as we don't use their DefaultConfig initializer. I'll send a patch later.

On Wed, Jan 4, 2017, 15:58 Dylan Clendenin notifications@github.com wrote:

you are correct https://github.com/hashicorp/consul/blob/c744792fc4d665363dba0ecfc7d05fdedc9cab32/api/api.go#L210-L212

merely setting CONSUL_HTTP_TOKEN will be enough

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/prometheus/consul_exporter/issues/39#issuecomment-270499023, or mute the thread https://github.com/notifications/unsubscribe-auth/AAANaDa55htDL6m0JaW1txRtxYeIrdkcks5rPBYYgaJpZM4LTJ9_ .