Hey Aliaksandr!

Thank you for the answer, these relabeling rules helped indeed! I will save 
the medium post to bookmarks as it contains a lot of good examples! 

Best regards,
Rasmus Rüngenen
Observability Platform Developer
Pipedrive
On Thursday, 25 March 2021 at 19:25:46 UTC+2 [email protected] wrote:

> The `labels` section is unavailable in `consul_sd_configs`. If you want 
> adding labels to all the metrics collected from discovered Consul targets, 
> then add the following relabeling rules under consul_sd_configs section:
>
> - target_label: env
>   replacement: foo
> - target_label: region
>   replacement: bar
>
>
> See this article 
> <https://valyala.medium.com/how-to-use-relabeling-in-prometheus-and-victoriametrics-8b90fc22c4b2>
>  
> for details.
>
> On Thu, Mar 25, 2021 at 12:36 PM Rasmus Rüngenen <[email protected]> 
> wrote:
>
>> Hello! I wanted to ask if it would be possible to add labels via 
>> static_config to a scrape job that uses the Consul Service Discovery 
>> mechanism?
>>
>> Right now I have tested two solutions and with the static target, the 
>> labels are being applied while the Consul SD does not apply.
>>
>> Consul SD:
>>   - job_name: 'kubernetes-pods-federation'
>>     scrape_interval: 30s
>>     metrics_path: '/federate'
>>     consul_sd_configs:
>>       - server: 'localhost:8500'
>>     relabel_configs:
>>       - source_labels: [__meta_consul_tags]
>>         regex: '^.*k8s.*$'
>>         action: keep
>>       - source_labels: ['__meta_consul_node']
>>         target_label: instance
>>       - source_labels: ['__meta_consul_service']
>>         target_label: service
>>       - source_labels: ['__meta_consul_tags']
>>         target_label: consul_tags
>>     static_configs:
>>       - labels:
>>           env: foo
>>           region: bar
>>
>> and second that has static target 
>>   - job_name: 'consul-agent'
>>     scrape_interval: 30s
>>     metrics_path: '/v1/agent/metrics'
>>     params:
>>       format: ['prometheus']
>>     scheme: http
>>     static_configs:
>>      - targets: ['localhost:8500']
>>        labels:
>>          env: foo
>>          region: bar
>>
>> Thanks in advance for the help! 
>>
>> -- 
>> 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/2bff96e0-a11f-4d10-b01d-60965241e099n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/prometheus-users/2bff96e0-a11f-4d10-b01d-60965241e099n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> -- 
> Best Regards,
>
> Aliaksandr Valialkin, CTO VictoriaMetrics
>

-- 
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/2dc83978-8d52-4b9a-ba0c-c73ce263751fn%40googlegroups.com.

Reply via email to