federate job configuration does not seem to work
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Prometheus2 charm |
Fix Committed
|
Undecided
|
Unassigned |
Bug Description
- When I configure this example federate job through the charm config `federate-config`,
```
- job_name: 'mesh-federate'
scrape_interval: 2m
scrape_timeout: 1m
honor_labels: true
metrics_path: '/federate'
params:
'match[]':
- '{__name__=~".+"}'
static_configs:
- targets:
- '<FQDN of other prometheus server>:9090'
```
- The job does not show up.
In the Prometheus UI -> Status -> Configuration, I see
```
- job_name: mesh-federate
honor_labels: true
honor_timestamps: true
params:
match[]:
- '{__name__=~".+"}'
scrape_interval: 15s
scrape_timeout: 15s
metrics_path: /federate
scheme: http
follow_redirects: true
enable_http2: true
static_configs:
- targets: []
labels:
group: promoagents-
```
As such, the target is missing and the scrape interval and timeout seem to be from the charm configs `scrape-timeout` and `scrape-interval` instead.
This charm is stable, 48.
Related branches
- JamesLin: Approve
- Eric Chen: Approve
- Tianqi Xiao (community): Approve
- 🤖 prod-jenkaas-bootstack: Approve (continuous-integration)
- Robert Gildein: Needs Fixing
- Erhan Sunar (community): Needs Fixing
-
Diff: 57 lines (+16/-2)2 files modifiedsrc/templates/prometheus.yml.j2 (+9/-1)
src/tests/unit/test_reactive_prometheus.py (+7/-1)
description: | updated |
Changed in charm-prometheus2: | |
status: | New → Fix Committed |
milestone: | none → 23.10 |
The jinja template does NOT grab scrape timeout and interval in the federate config section
``` 'metrics_ path') %} ].items( ) %} federate'
# federate jobs
{%- if federate %}
{%- for job in federate %}
- job_name: '{{ job['job_name'] }}'
honor_labels: true
{%- if job.get(
metrics_path: {{ job['metrics_path'] }}
{%- else %}
metrics_path: /federate
{%- endif %}
{%- if job.get('scheme') %}
scheme: {{ job['scheme'] }}
{%- endif %}
params:
{%- for param, values in job['params'
'{{ param }}':
{%- for value in values %}
- '{{ value }}'
{%- endfor %}
{%- endfor %}
static_configs:
- targets:
{%- for target in job['targets'] %}
- {{ target }}
{%- endfor %}
labels:
{%- if job.get('label') %}
group: '{{job['label']}}'
{%- else %}
group: 'promoagents-
{%- endif %}
{%- endfor %}
{%- endif %}
```