file_sd_configs custom params for each target

97 views
Skip to first unread message

dykow

unread,
Aug 11, 2020, 4:42:52 AM8/11/20
to Prometheus Users

Hi there!
Is there a way to do something like this with file_sd_configs?

[
  {
     "targets": [ "x.x.x.x" ],
      "labels": {
         "job": "vmware"
   },
      "params": {
        "section": ["origin"]
      }
   }
]

dykow

unread,
Aug 11, 2020, 4:45:26 AM8/11/20
to Prometheus Users
I need to specify custom param for each target

Stuart Clark

unread,
Aug 11, 2020, 4:51:29 AM8/11/20
to dykow, Prometheus Users
You should be able to do something like this via relabelling. Basically
you can encode extra information in your target using delimiters such as
: and then split that in the relabelling to set whatever you are
wanting...


--
Stuart Clark

Julien Pivotto

unread,
Aug 11, 2020, 6:02:50 AM8/11/20
to dykow, Prometheus Users
On 11 Aug 01:45, dykow wrote:
> I need to specify custom param for each target
>
> wtorek, 11 sierpnia 2020 o 10:42:52 UTC+2 dykow napisał(a):
>
> >
> > Hi there!
> > Is there a way to do something like this with file_sd_configs?


You can change limited things with labels:



[
{
"targets": [ "x.x.x.x" ],
"labels": {
"job": "vmware" ,
"__metrics_path__": "/vmware/metric",
"__scheme__": "https"
},
]

>
> --
> You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/6cbd6d70-38ee-4f72-9656-b02fc52cc951n%40googlegroups.com.


--
Julien Pivotto
@roidelapluie

dykow

unread,
Aug 11, 2020, 6:39:46 AM8/11/20
to Prometheus Users
What do you mean by this? How should I do it then? Stuart's way?

Say I have such target: 10.10.10.10:origin, how should relabeling be performed in order to achieve http://address:9272/metrics?vsphere_host=10.10.10.1?section=origin, given that I currently have such relabel_configs:
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__metrics_path__]
target_label: __metrics_path
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: address:9272

Julien Pivotto

unread,
Aug 11, 2020, 7:16:58 AM8/11/20
to dykow, Prometheus Users
On 11 Aug 03:39, dykow wrote:
> What do you mean by this? How should I do it then? Stuart's way?
>
> Say I have such target: 10.10.10.10:origin, how should relabeling be

You dont need relabel configs if you control the file_sd completely
(which is what I understood from first message):

{
target: [address:9272]
labels: {
'__param_vsphere_host': 10.10.10.1,
'__param_vsphere_section': origin
> To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/98f8a67c-1bb6-4516-bc98-29e805abc091n%40googlegroups.com.


--
Julien Pivotto
@roidelapluie

dykow

unread,
Aug 11, 2020, 7:45:36 AM8/11/20
to Prometheus Users
Thank You Julien!
Reply all
Reply to author
Forward
0 new messages