Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
float
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ai3
float
Commits
aa6e84d9
Commit
aa6e84d9
authored
2 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Allow setting custom scrape_intervals for services and blackbox probes
parent
a4a79c6f
Branches
Branches containing commit
No related tags found
1 merge request
!277
Allow setting custom scrape_intervals for services and blackbox probes
Pipeline
#45147
passed
2 years ago
Stage: test
Stage: cleanup
Changes
2
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
docs/reference.md
+9
-0
9 additions, 0 deletions
docs/reference.md
roles/float-infra-prometheus/templates/prometheus.yml.j2
+11
-0
11 additions, 0 deletions
roles/float-infra-prometheus/templates/prometheus.yml.j2
with
20 additions
and
0 deletions
docs/reference.md
+
9
−
0
View file @
aa6e84d9
...
...
@@ -1575,6 +1575,8 @@ provided:
specify a regex (with a capture group) to extract back the host
name from the target; the default regex will extract the short
host name from URLs and host:port targets.
*
(optionally) a *scrape_interval* if for some reason it should be
different than the default *prometheus_probe_scrape_interval*.
So, in the context of the previous example, if we wanted to probe
another float service called *myservice*, which hypothetically serves
...
...
@@ -2032,6 +2034,9 @@ attributes:
`labels`
:
An optional dictionary of key/value labels to set for this
target (they will be added to all metrics scraped from it).
`scrape_interval`
:
Optionally override the scrape interval for this
target.
The Prometheus *job* labels for service targets will be automatically
generated by *float* to include the service name and the endpoint
port.
...
...
@@ -2533,6 +2538,10 @@ instances should scrape their targets (default 10s).
`prometheus_lts_scrape_interval` sets how often the long-term
Prometheus instances should scrape the primary ones (default 1m).
`prometheus_probe_scrape_interval` controls the default
scrape_interval setting for all blackbox probes, and it just defaults
to the value of prometheus_scrape_interval if unset.
`prometheus_external_targets` allows adding additional targets to Prometheus
beyond those that are described by the service metadata. It is a list of entries
with *name*, *targets* attributes. Optionally, you may specify a *scheme*
...
...
This diff is collapsed.
Click to expand it.
roles/float-infra-prometheus/templates/prometheus.yml.j2
+
11
−
0
View file @
aa6e84d9
...
...
@@ -44,6 +44,9 @@
{% macro job_service_config(service_name, target_config) %}
- job_name: "{{ service_name }}_{{ target_config.port }}"
scheme: "{{ target_config.get('scheme', 'https') }}"
{% if target_config.get('scrape_interval') %}
scrape_interval: "{{ target_config['scrape_interval'] }}"
{% endif %}
{% if target_config.get('metrics_path') %}
metrics_path: "{{ target_config['metrics_path'] }}"
{% endif %}
...
...
@@ -103,6 +106,7 @@ scrape_configs:
{# Blackbox probes #}
{% for prober_host in services['prometheus'].hosts|sort %}
{% set prober_idx = loop.index %}
{% set probe_scrape_interval = prometheus_probe_scrape_interval | default(prometheus_scrape_interval) %}
{# Create all the health probes for all the monitored services #}
{% for service_name, service in services | dictsort %}
...
...
@@ -142,6 +146,7 @@ scrape_configs:
- job_name: "prober_ping_{{ loop.index }}"
metrics_path: "/probe"
scrape_interval: "{{ probe_scrape_interval }}"
params:
module:
- ping
...
...
@@ -171,6 +176,7 @@ scrape_configs:
- job_name: "prober_https_{{ prober_idx }}"
metrics_path: "/probe"
scrape_interval: "{{ probe_scrape_interval }}"
params:
module:
- http_base
...
...
@@ -200,6 +206,7 @@ scrape_configs:
- job_name: "prober_dns_{{ prober_idx }}"
metrics_path: "/probe"
scrape_interval: "{{ probe_scrape_interval }}"
params:
module: [dns_toplevel]
relabel_configs:
...
...
@@ -233,6 +240,7 @@ scrape_configs:
{% for prober_host in services[p.service].hosts | sort %}
- job_name: "prober_{{ p.name }}_{{ loop.index }}"
metrics_path: "/probe"
scrape_interval: "{{ p.scrape_interval | default(probe_scrape_interval) }}"
params:
module:
- {{ p.module | default(p.name) }}
...
...
@@ -280,6 +288,9 @@ scrape_configs:
- job_name: "{{ target.name }}"
scheme: "{{ target.scheme | default('http') }}"
metrics_path: "{{ target.metrics_path | default('/metrics') }}"
{% if target.scrape_interval is defined %}
scrape_interval: "{{ target.scrape_interval }}"
{% endif %}
static_configs:
- targets: {{ target.targets | to_json }}
labels:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment