Skip to content
Snippets Groups Projects
Commit de34adf0 authored by ale's avatar ale
Browse files

Add extra labels to monitoring_endpoints

parent 02ed6ef7
No related branches found
No related tags found
No related merge requests found
...@@ -1970,6 +1970,9 @@ Prometheus to find the service endpoints. This can only have the value ...@@ -1970,6 +1970,9 @@ Prometheus to find the service endpoints. This can only have the value
`metrics_path`: Path for metrics if different from the default of `/metrics`. `metrics_path`: Path for metrics if different from the default of `/metrics`.
`labels`: An optional dictionary of key/value labels to set for this
target (they will be added to all metrics scraped from it).
### Traffic routing ### Traffic routing
Services can define *public* HTTP and TCP endpoints, that will be Services can define *public* HTTP and TCP endpoints, that will be
......
...@@ -15,12 +15,15 @@ ...@@ -15,12 +15,15 @@
{% endmacro %} {% endmacro %}
{# Generate a static_configs entry for a scrape config #} {# Generate a static_configs entry for a scrape config #}
{% macro static_configs_for_group(group, port, service_name='') %} {% macro static_configs_for_group(group, port, service_name='', extra_labels=None) %}
static_configs: static_configs:
{% if service_name %} {% if service_name %}
{{ targets_for_service(service_name, port) }} {{ targets_for_service(service_name, port) }}
labels: labels:
service: "{{ service_name }}" service: "{{ service_name }}"
{% for k, v in extra_labels | dictsort %}
{{ k }}: "{{ v }}"
{% endfor %}
{% else %} {% else %}
{{ targets_for_group(group, port) }} {{ targets_for_group(group, port) }}
{% endif %} {% endif %}
...@@ -50,7 +53,7 @@ ...@@ -50,7 +53,7 @@
cert_file: /etc/credentials/x509/prometheus/client/cert.pem cert_file: /etc/credentials/x509/prometheus/client/cert.pem
key_file: /etc/credentials/x509/prometheus/client/private_key.pem key_file: /etc/credentials/x509/prometheus/client/private_key.pem
{% endif %} {% endif %}
{{ static_configs_for_group(target_config.get('group', services[service_name].group_name), target_config.port, service_name) }} {{ static_configs_for_group(target_config.get('group', services[service_name].group_name), target_config.port, service_name, target_config.get('labels')) }}
{% endmacro %} {% endmacro %}
global: global:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment