Hi Brain,

This worked like a charm and saved couple of hundred lines of code as I 
have 20 end points to monitor. One quick question, I have scraping metrics 
for some of my spring boot applications and there are around 30 
applications that I am scrapping metrics from. is there a way to use 
file_sd to reduce the redundancy of the code just like the way it worked 
for blackbox exporter.

Thanks
Eswar

On Tuesday, March 17, 2020 at 9:52:32 AM UTC+1, Yagyansh S. Kumar wrote:
>
> Thanks a lot.
>
> On Tuesday, March 17, 2020 at 1:46:42 PM UTC+5:30, Brian Candler wrote:
>>
>> On Tuesday, 17 March 2020 03:33:40 UTC, Yagyansh S. Kumar wrote:
>>>
>>> And that would mean making 10 different jobs to probe those 10 URLs. 
>>> Right?
>>>
>>>
>> No: you can set __param_module differently for targets in the same job.
>>
>> A simple way is to use the file_sd file to add labels to groups of 
>> targets (each group can be a single target):
>>
>> - labels:
>>     module: mod1
>>   targets:
>>     - foo.example.com
>>
>> - labels:
>>     module: mod2
>>   targets:
>>     - bar.example.com
>>
>> #... etc
>>
>> And a simple relabel config:
>>
>>     relabel_configs:
>>       - source_labels: [module]
>>         target_label: __param_module
>>
>> (Note: you *could* just set the __param_module label directly in the 
>> targets file.  However this is dangerous if you ever probe the same host 
>> with two different blackbox modules; you need some stored distinguishing 
>> label to keep the timeseries separate.  In any case, the label giving the 
>> probe module used is useful for history and dashboards)
>>
>> If the above targets config is still too verbose for you, then you can 
>> used something like this:
>>
>> - targets:
>>     - foo.example.com;mod1
>>     - bar.example.com;mod2
>>
>> with some more sophisticated relabeling (untested):
>>
>>     relabel_configs:
>>       # Split "foo;bar" into instance="foo" module="bar"
>>       - source_labels: [__address__]
>>         regex: '(.+);(.+)'
>>         target_label: instance
>>         replacement: '${1}'
>>
>>       - source_labels: [__address__]
>>         regex: '(.+);(.+)'
>>         target_label: module
>>         replacement: '${2}'
>>
>>       # Fallback: bare "foo" becomes instance="foo" module="some_default"
>>       - source_labels: [__address__]
>>         regex: '([^;]+)'
>>         target_label: instance
>>         replacement: '${1}'
>>
>>       - source_labels: [__address__]
>>         regex: '([^;]+)'
>>         target_label: module
>>         replacement: 'icmp'
>>
>>       # copy instance to __param_target and module to __param_module
>>       - source_labels: [instance]
>>         target_label: __param_target
>>
>>       - source_labels: [module]
>>         target_label: __param_module
>>
>>       # send scrape to blackbox_exporter
>>       - target_label: __address__
>>         replacement: 127.0.0.1:9115
>>
>> HTH, Brian.
>>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/4f8b7248-1094-46a1-92fa-54ceadbaf8b9%40googlegroups.com.

Reply via email to