Send Prometheus query from telegraf to VictoriaMetrics DB

162 Views Asked by At

Did anyone know if it is possible to collect metric directly by sending a prometheus query in telegraf to VictoriaMetrics ?

I have tried this but it is not working :/

[inputs]
[[inputs.prometheus]]
urls = ["http://my_db_address:8428"]
query = "ifHCOutOctets_counter{target="device"}" 

Any ideas ? Thanks !

2

There are 2 best solutions below

2
Skill Skot On

Make sure Prometheus query is valid data in system.if issue persists victoria metrics logs connection problem.Adusjust query with single quotes.Not use double quotes.

0
valyala On

Try the following config for Telegraf:

[[inputs.prometheus]]
urls = ["http://my_db_address:8428/federate?match[]=ifHCOutOctets_counter{target='device'}"]

It uses /federate endpoint for obtaining the last values for metrics matching the given filters. The /federate endpoint returns metrics in the same format as usual Prometheus exporters do at /metrics page.