Job label in file-based SD

18 views
Skip to first unread message

Björn Fischer

unread,
Jun 26, 2020, 4:34:00 AM6/26/20
to Prometheus Users

Hi all,

I was going through the guide for file-based service discovery [1] and noticed that they are setting the job label in the targets file. That doesn't make sense to me. Targets are not strictly job-specific and Prometheus is setting the job label anyways. Can someone think of a reason to set the job label explicitly here?

Cheers,
Björn


Christian Hoffmann

unread,
Jun 30, 2020, 1:59:37 AM6/30/20
to Björn Fischer, Prometheus Users
Hi,

On 6/26/20 10:33 AM, Björn Fischer wrote:
> I was going through the guide for file-based service discovery [1] and
> noticed that they are setting the job label in the targets file. That
> doesn't make sense to me. Targets are not strictly job-specific and
> Prometheus is setting the job label anyways. Can someone think of a
> reason to set the job label explicitly here?

Yes, Prometheus will set a job label anyway. I assume it was simple
chosen as an example for setting a label there without inventing a
non-default label.

While I think there are cases where overriding the job label makes sense
[1], I don't think it is too common.

So, I agree that this example is a bit confusing. Maybe a Pull Request
to improve this would be welcome?


Kind regards,
Christian


[1] For example, we want all node_exporter jobs to have the job="node"
label, but we have to make them multiple jobs because of different
proxy_url settings. Therefore, we have node-proxy1, but explicitly set
job="node" as a label.
Reply all
Reply to author
Forward
0 new messages