pambrose/prometheus-proxy

Question: Labels in discovery api

Closed this issue · 4 comments

Hi,

Have been playing a little bit with prometheus-proxy and I am planning to use it in one scenario.
I have not found anything about it in the documention but maybe I have missed it.
Is it possible to add tags to the output of the discovery api? The best solution would be to add tags to the agent and have them exposed in the discovery api if possible.

Something like:

"labels": {
  "__scheme__": "http",
  "__shard": "Default",
  "farm": "DockerHosts",
  "job": "cadvisor",
  "project": "Docker",
  "environment": "Prod"
},

Hi Anton,

Sounds interesting, but I am not following you completely. If you would, talk me through how you would like to see the label data propagated through the output of the discovery API.

Hi,

I would like to add it in the agent config file like this:

  pathConfigs: [
    
    {
      name: "Windows local"
      path: host-id_windows
      labels: {"key1": "value", "key2": "value"}
      url: "http://localhost:9182/metrics"
    },
    {
      name: "Agent metrics"
      path: host-id_agent
      labels: {"key1": "value", "key2": "value", "key3": "value"}
      url: "http://localhost:8083/metrics"
      }
  ]
}

But I realized it might be easier to do this in an proxy so made an poc yesterday where Prometheus is calling an internal API instead of /discovery.
This local api is extracting the first part of the uri and is fetching tags from our cmdb.

So when the source /discovery produces:

[
    {
        "targets": [
            "proxy:8081/ID-123_agent",
        ]
    }
]

The output from my local api is:

[
	{
		"labels": {
			"environment": "Development",
			"group": "Anton",
			"insightKey": "ID-123",
			"job": "agent"
		},
		"targets": [
			"proxy:8081/ID-123_agent"
		]
	}
]

This workaround would work for me for now.

So, you are content with your workaround and do not need any changes from me?

I think my workaround will work for now and since is it for an specific usecase maybe it is better not to include it in the core product.

Anyway, thanks for an great product.