influxdata / telegraf-operator

telegraf-operator helps monitor application on Kubernetes with Telegraf
Apache License 2.0
80 stars 37 forks source link

Ability to set Basic Auth credentials for the default prometheus input plugin #118

Open magoogli opened 1 year ago

magoogli commented 1 year ago

At the moment I can't figure out a way to set the username and password for basic authentication for the default prometheus input plugin.

Having a look at: https://github.com/influxdata/telegraf/tree/master/plugins/inputs/prometheus

It seems that this is possible by setting username and password, however this does not seem currently possible via pod annotations.

To work around this I currently redefine the entire prometheus input via the annotations as follows:

podAnnotations:  
  telegraf.influxdata.com/class: "default"    
  telegraf.influxdata.com/inputs: |+
    [[inputs.prometheus]]
      urls = ["http://127.0.0.1:8080/metrics"]
      username = "MyUsername"
      password = "MyPassword"

However this results in two prometheus inputs in the /etc/telegraf/telegraf.conf file as below.

[[inputs.prometheus]]
  urls = ["http://127.0.0.1:8080/metrics"]

[[inputs.prometheus]]
  urls = ["http://127.0.0.1:8080/metrics"]
  username = "MyUsername"
  password = "MyPassword"
...

Of course the first / default one that I cannot disable or set basic auth credentials on spews out 401 errors.

So either the username and password should be settable via annotations, or just being able to disable the default generated input would work.