Tealk
October 13, 2023, 11:34am
1
Hello all,
I am thinking about using telegraf instead of prometheus because I have it in use anyway and don’t have to maintain 2 services.
I have seen that there are inputs.prometheus but do not know exactly how I have to write my config then.
In Prometheus I added several targets to a scrape job and then gave them a service tag:
scrape_configs:
- job_name: "vserver"
static_configs:
- targets: [ '192.168.100.1:9100' ]
labels:
service: 'server1'
- targets: [ '192.168.100.2:9100' ]
labels:
service: 'server2'
- ...
- job_name: "statsd-exporter"
static_configs:
- targets: [ '192.168.100.1:9102' ]
- ...
Can I do the same in telegraf, I didn’t find anything in the linked documentation.
Hi,
When you looked at the docs, what did you not find?
The very first config option contains the URLs to scrape:
[[inputs.prometheus]]
urls = ["http://localhost:9100/metrics"]
You can repeat the above section for every target if you need custom configs for each of them. Or you can specify different plugins for each and then set specific tags for each:
[[inputs.prometheus]]
urls = ["192.168.100.1:9100"]
tags = {service = "server1"}
[[inputs.prometheus]]
urls = ["192.168.100.2:9100"]
tags = {service = "server2"}
1 Like
Tealk
October 13, 2023, 2:04pm
3
i can’t find this part in the linked docs,
//EDIT
but i have find it here
another question, I have now moved everything, but on a call I get the error:
2023-10-13T15:32:58Z E! [inputs.prometheus] Error in plugin: error reading metrics for “http://192.168.100.1:9300/metrics ”: reading metric family protocol buffer failed: proto: cannot parse invalid wire-format data
this is the monitoring of authentik and when i call it via curl it also looks normal like all other metrics.
Looks like it is trying to use protobuf to collect the data, can you try adding the following header to see if we get:
http_headers = {"Accept" = "text/plain;version=0.0.4;q=1" }
Tealk
October 13, 2023, 4:33pm
5
yes no more errors, thank you