prometheus/templates/conf/prometheus.yml.j2

524 lines
14 KiB
Plaintext
Raw Normal View History

2021-05-25 18:25:22 +02:00
# {{ ansible_managed }}
global:
scrape_interval: {{ prometheus_server_global_scrape_interval }}s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: {{ prometheus_server_global_evaluation_interval }}s # Evaluate rules every 15 seconds. The default is every 1 minute.
2021-05-25 18:25:22 +02:00
# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
external_labels:
monitor: '{{ prometheus_server_monitor }}'
{% if prometheus_server_rules is defined %}
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
- 'rules.yml'
{% endif %}
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
2022-11-14 11:05:19 +01:00
- job_name: '{{ prometheus_server_job_name }}'
2021-05-25 18:25:22 +02:00
# Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: {{ prometheus_server_scrape_interval }}s
scrape_timeout: {{ prometheus_server_scrape_timeout }}s
2021-05-25 18:25:22 +02:00
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9090']
2021-05-26 17:34:59 +02:00
{% if prometheus_node_exporter_targets is defined %}
2021-11-02 15:51:47 +01:00
# node exporter #
2021-05-25 18:25:22 +02:00
- job_name: node
scrape_interval: 30s
scrape_timeout: 10s
static_configs:
- targets:
{% for target in prometheus_node_exporter_targets %}
2022-11-14 11:05:19 +01:00
- {{ target }}:9100
2021-05-25 18:25:22 +02:00
{% endfor %}
relabel_configs:
- source_labels: [ __address__ ]
target_label: instance
regex: '(.*):9100'
replacement: '${1}'
2021-05-25 18:25:22 +02:00
2023-02-09 18:01:15 +01:00
{% endif %}
2021-05-26 17:34:59 +02:00
{% if prometheus_mysqld_exporter_targets is defined %}
2021-11-02 15:51:47 +01:00
# mysql exporter #
2021-05-25 18:25:22 +02:00
- job_name: mysql
scrape_interval: 30s
scrape_timeout: 10s
static_configs:
2021-10-29 17:40:18 +02:00
{% if prometheus_mysqld_exporter_custom is defined %}
{% for target in prometheus_mysqld_exporter_custom.values() %}
- targets: ['{{ target.node_name }}:9104']
labels:
environment: '{{ target.environment }}'
node_name: '{{ target.node_name }}'
service_name: '{{ target.service_name }}'
cluster: '{{ target.cluster }}'
{% endfor %}
{% else %}
2021-05-25 18:25:22 +02:00
- targets:
{% for target in prometheus_mysqld_exporter_targets %}
2022-11-14 11:05:19 +01:00
- {{ target }}:9104
2021-05-25 18:25:22 +02:00
{% endfor %}
{% endif %}
relabel_configs:
- source_labels: [ __address__ ]
target_label: instance
regex: '(.*):9104'
replacement: '${1}'
2021-05-25 18:25:22 +02:00
2023-02-09 18:01:15 +01:00
{% endif %}
2021-05-26 17:34:59 +02:00
{% if prometheus_mongodb_exporter_targets is defined %}
2021-11-02 15:51:47 +01:00
# mongoDB exporter #
2021-05-25 18:25:22 +02:00
- job_name: mongodb
scrape_interval: 30s
scrape_timeout: 10s
static_configs:
2021-10-12 15:46:38 +02:00
{% if prometheus_mongodb_exporter_custom is defined %}
{% for target in prometheus_mongodb_exporter_custom.values() %}
- targets: ['{{ target.node_name }}:9216']
labels:
environment: '{{ target.environment }}'
node_name: '{{ target.node_name }}'
service_name: '{{ target.service_name }}'
cluster: '{{ target.cluster }}'
{% endfor %}
{% else %}
2021-05-26 17:34:59 +02:00
- targets:
2021-05-25 18:25:22 +02:00
{% for target in prometheus_mongodb_exporter_targets %}
2022-11-14 11:05:19 +01:00
- {{ target }}:9216
2021-05-25 18:25:22 +02:00
{% endfor %}
{% endif %}
2023-04-21 16:35:56 +02:00
relabel_configs:
- source_labels: [ __address__ ]
target_label: instance
regex: '(.*):9216'
replacement: '${1}'
2021-05-25 18:25:22 +02:00
2023-02-09 18:01:15 +01:00
{% endif %}
2021-05-26 17:34:59 +02:00
{% if prometheus_postgres_exporter_targets is defined %}
2021-11-02 15:51:47 +01:00
# postgresql exporter #
2021-05-25 18:25:22 +02:00
- job_name: postgresql
scrape_interval: 30s
scrape_timeout: 10s
static_configs:
2021-10-29 18:16:32 +02:00
{% if prometheus_postgres_exporter_custom is defined %}
{% for target in prometheus_postgres_exporter_custom.values() %}
- targets: ['{{ target.node_name }}:9187']
labels:
environment: '{{ target.environment }}'
node_name: '{{ target.node_name }}'
service_name: '{{ target.service_name }}'
cluster: '{{ target.cluster }}'
{% endfor %}
{% else %}
2021-05-25 18:25:22 +02:00
- targets:
{% for target in prometheus_postgres_exporter_targets %}
2022-11-14 11:05:19 +01:00
- {{ target }}:9187
2021-05-25 18:25:22 +02:00
{% endfor %}
{% endif %}
2023-04-21 16:35:56 +02:00
relabel_configs:
- source_labels: [ __address__ ]
target_label: instance
regex: '(.*):9187'
replacement: '${1}'
2021-10-05 16:52:47 +02:00
2023-02-09 18:01:15 +01:00
{% endif %}
2021-10-05 16:52:47 +02:00
{% if prometheus_phpfpm_exporter_targets is defined %}
2021-11-02 15:51:47 +01:00
# PHP-FPM exporter #
2021-10-05 16:52:47 +02:00
- job_name: phpfpm
scrape_interval: 30s
scrape_timeout: 10s
static_configs:
- targets:
{% for target in prometheus_phpfpm_exporter_targets %}
2022-11-14 11:05:19 +01:00
- {{ target }}:9253
2021-10-05 16:52:47 +02:00
{% endfor %}
2022-10-24 18:34:13 +02:00
relabel_configs:
- source_labels: [ __address__ ]
target_label: instance
regex: '(.*):9253'
replacement: '${1}'
2021-10-08 10:57:40 +02:00
2023-02-09 18:01:15 +01:00
{% endif %}
2022-01-05 16:00:23 +01:00
{% if prometheus_opcache_exporter_targets is defined %}
2022-11-11 21:00:00 +01:00
# opcache exporter #
2022-01-05 16:00:23 +01:00
- job_name: opcache
2022-01-05 15:44:39 +01:00
scrape_interval: 30s
scrape_timeout: 10s
static_configs:
- targets:
2022-01-05 16:00:23 +01:00
{% for target in prometheus_opcache_exporter_targets %}
2022-11-14 11:05:19 +01:00
- {{ target }}:9101
2022-01-05 15:44:39 +01:00
{% endfor %}
2022-10-24 18:34:13 +02:00
relabel_configs:
- source_labels: [ __address__ ]
target_label: instance
regex: '(.*):9101'
replacement: '${1}'
2022-01-05 15:44:39 +01:00
2023-02-09 18:01:15 +01:00
{% endif %}
2021-10-08 10:57:40 +02:00
{% if prometheus_apache_exporter_targets is defined %}
2021-11-02 15:51:47 +01:00
# apache exporter #
2021-10-08 10:57:40 +02:00
- job_name: apache
scrape_interval: 30s
scrape_timeout: 10s
static_configs:
- targets:
{% for target in prometheus_apache_exporter_targets %}
2022-11-14 11:05:19 +01:00
- {{ target }}:9117
2021-10-08 10:57:40 +02:00
{% endfor %}
2022-10-24 18:34:13 +02:00
relabel_configs:
- source_labels: [ __address__ ]
target_label: instance
regex: '(.*):9117'
replacement: '${1}'
2023-04-21 15:22:24 +02:00
{% endif %}
{% if prometheus_nginx_exporter_targets is defined %}
# nginx exporter #
- job_name: nginx
scrape_interval: 30s
scrape_timeout: 10s
static_configs:
- targets:
{% for target in prometheus_nginx_exporter_targets %}
- {{ target }}:9113
{% endfor %}
relabel_configs:
- source_labels: [ __address__ ]
target_label: instance
regex: '(.*):9113'
replacement: '${1}'
2023-02-09 18:01:15 +01:00
{% endif %}
{% if prometheus_haproxy_exporter_targets is defined %}
2021-11-02 15:51:47 +01:00
# haproxy exporter #
- job_name: haproxy
scrape_interval: 30s
scrape_timeout: 10s
static_configs:
- targets:
{% for target in prometheus_haproxy_exporter_targets %}
2022-11-14 11:05:19 +01:00
- {{ target }}:8404
{% endfor %}
2022-10-24 18:34:13 +02:00
relabel_configs:
- source_labels: [ __address__ ]
target_label: instance
regex: '(.*):8404'
replacement: '${1}'
2021-10-08 15:22:59 +02:00
2023-02-09 18:01:15 +01:00
{% endif %}
2021-10-08 15:22:59 +02:00
{% if prometheus_varnish_exporter_targets is defined %}
2021-11-19 12:30:22 +01:00
# Varnish exporter #
2021-10-08 15:22:59 +02:00
- job_name: varnish
scrape_interval: 30s
scrape_timeout: 10s
static_configs:
- targets:
{% for target in prometheus_varnish_exporter_targets %}
2022-11-14 11:05:19 +01:00
- {{ target }}:9131
2021-10-08 15:22:59 +02:00
{% endfor %}
2022-10-24 18:34:13 +02:00
relabel_configs:
- source_labels: [ __address__ ]
target_label: instance
regex: '(.*):9131'
replacement: '${1}'
2021-11-02 15:51:47 +01:00
2023-02-09 18:01:15 +01:00
{% endif %}
2021-11-02 15:55:14 +01:00
{% if prometheus_blackbox_exporter is defined %}
# blackbox #
2021-11-02 16:11:54 +01:00
{% if prometheus_blackbox_exporter_http is defined %}
2021-11-02 15:51:47 +01:00
## http check ##
- job_name: blackbox - url
2021-11-02 15:51:47 +01:00
scrape_interval: 30s
scrape_timeout: 10s
metrics_path: /probe
2021-11-02 15:51:47 +01:00
params:
module: [http_2xx]
static_configs:
- targets:
{% for target in prometheus_blackbox_exporter_http %}
- {{target }}
{% endfor %}
2021-11-02 15:51:47 +01:00
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
2022-11-14 11:05:19 +01:00
replacement: {{ prometheus_blackbox_exporter_host }}:9115
2021-11-02 16:11:54 +01:00
{% endif %}
{% if prometheus_blackbox_exporter_ping is defined %}
2021-11-02 15:51:47 +01:00
## ping ##
- job_name: blackbox - ping
2021-11-02 15:51:47 +01:00
scrape_interval: 30s
scrape_timeout: 10s
params:
module: [icmp]
static_configs:
- targets:
{% for target in prometheus_blackbox_exporter_ping %}
2022-11-14 11:05:19 +01:00
- {{ target }}
{% endfor %}
2021-11-02 15:51:47 +01:00
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
2022-11-14 11:05:19 +01:00
replacement: {{ prometheus_blackbox_exporter_host }}:9115
2021-11-02 15:51:47 +01:00
{% endif %}
2023-02-09 18:01:15 +01:00
{% endif %}
2021-12-23 16:27:09 +01:00
{% if prometheus_redis_multi_instances_exporter_targets is defined %}
# Redis exporter #
- job_name: 'redis_exporter_targets'
static_configs:
- targets:
{% for target in prometheus_redis_multi_instances_exporter_targets %}
2022-11-14 11:05:19 +01:00
- {{ target }}
2021-12-23 16:27:09 +01:00
{% endfor %}
metrics_path: /scrape
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- source_labels: [instance]
target_label: __address__
regex: 'redis://(.*):63..'
replacement: '${1}:9121'
2023-02-09 18:01:15 +01:00
{% endif %}
2021-11-19 12:30:22 +01:00
{% if prometheus_redis_exporter_targets is defined %}
# Redis exporter #
- job_name: redis
scrape_interval: 30s
scrape_timeout: 10s
static_configs:
- targets:
{% for target in prometheus_redis_exporter_targets %}
2022-11-14 11:05:19 +01:00
- {{ target }}:9121
2021-11-19 12:30:22 +01:00
{% endfor %}
2022-10-24 18:34:13 +02:00
relabel_configs:
- source_labels: [ __address__ ]
target_label: instance
regex: '(.*):9121'
replacement: '${1}'
2021-12-01 18:16:45 +01:00
2023-02-09 18:01:15 +01:00
{% endif %}
2021-12-01 18:16:45 +01:00
{% if prometheus_proxysql_exporter_targets is defined %}
# ProxySQL exporter #
- job_name: proxysql
scrape_interval: 30s
scrape_timeout: 10s
static_configs:
- targets:
{% for target in prometheus_proxysql_exporter_targets %}
2022-11-14 11:05:19 +01:00
- {{ target }}:6070
2021-12-01 18:16:45 +01:00
relabel_configs:
- source_labels: [ __address__ ]
target_label: instance
regex: '(.*):6070'
replacement: '${1}'
{% endfor %}
2022-06-15 12:09:15 +02:00
2023-02-09 18:01:15 +01:00
{% endif %}
2022-06-15 12:09:15 +02:00
{% if prometheus_kong_exporter_targets is defined %}
# Kong exporter #
- job_name: kong
scrape_interval: 30s
scrape_timeout: 10s
metrics_path: /metrics
honor_labels: false
honor_timestamps: true
sample_limit: 0
static_configs:
- targets:
{% for target in prometheus_kong_exporter_targets %}
2022-11-14 11:07:16 +01:00
- {{ target }}
2022-06-15 12:09:15 +02:00
{% endfor %}
2022-11-11 17:32:23 +01:00
2023-02-09 18:01:15 +01:00
{% endif %}
2022-11-11 17:32:23 +01:00
{% if prometheus_memcached_exporter_targets is defined %}
# Memcached exporter #
- job_name: memcached
scrape_interval: 30s
scrape_timeout: 10s
static_configs:
- targets:
{% for target in prometheus_memcached_exporter_targets %}
2022-11-14 11:05:19 +01:00
- {{ target }}:9150
2022-11-11 17:32:23 +01:00
{% endfor %}
relabel_configs:
- source_labels: [ __address__ ]
target_label: instance
regex: '(.*):9150'
replacement: '${1}'
2023-02-09 18:01:15 +01:00
{% endif %}
{% if prometheus_docker_exporter_targets is defined %}
# Docker exporter #
- job_name: docker
scrape_interval: 30s
scrape_timeout: 10s
static_configs:
- targets:
2022-11-11 19:08:28 +01:00
{% for target in prometheus_docker_exporter_targets %}
2022-11-14 11:05:19 +01:00
- {{ target }}:9323
{% endfor %}
relabel_configs:
- source_labels: [ __address__ ]
target_label: instance
regex: '(.*):9323'
replacement: '${1}'
2023-02-09 18:01:15 +01:00
{% endif %}
{% if prometheus_cadvisor_exporter_targets is defined %}
# cadvisor #
- job_name: cadvisor
scrape_interval: 30s
static_configs:
- targets:
2023-03-20 15:50:02 +01:00
{% for target in prometheus_cadvisor_exporter_targets %}
2023-03-20 14:56:03 +01:00
- {{ target }}
{% endfor %}
relabel_configs:
- source_labels: [ __address__ ]
target_label: instance
2023-03-20 14:56:03 +01:00
regex: '(.*):8080'
replacement: '${1}'
2023-02-09 18:01:15 +01:00
{% endif %}
2023-01-27 16:51:27 +01:00
{% if prometheus_cloudflare_exporter_targets is defined %}
# cloudflare #
- job_name: cloudflare
scrape_interval: 30s
static_configs:
- targets:
{% for target in prometheus_cloudflare_exporter_targets %}
- {{ target }}:8082
{% endfor %}
relabel_configs:
- source_labels: [ __address__ ]
target_label: instance
regex: '(.*):8082'
replacement: '${1}'
2023-01-27 20:34:33 +01:00
2023-02-09 18:01:15 +01:00
{% endif %}
2023-01-27 20:34:33 +01:00
{% if prometheus_pve_exporter_targets is defined %}
# proxmox #
- job_name: pve
scrape_interval: 30s
static_configs:
- targets:
{% for target in prometheus_pve_exporter_targets %}
- {{ target }}:9221
{% endfor %}
metrics_path: /pve
relabel_configs:
- source_labels: [ __address__ ]
target_label: instance
regex: '(.*):9221'
replacement: '${1}'
2023-04-21 15:22:24 +02:00
2023-01-27 20:34:33 +01:00
{% endif %}
2023-03-20 16:33:38 +01:00
{% if prometheus_opensearch_exporter_targets is defined %}
# opensearch #
- job_name: opensearch
scrape_interval: 30s
metrics_path: "/_prometheus/metrics"
2023-03-20 17:56:56 +01:00
scheme: https
tls_config:
insecure_skip_verify: true
2023-03-20 16:33:38 +01:00
static_configs:
- targets:
{% for target in prometheus_opensearch_exporter_targets %}
- {{ target }}:9200
{% endfor %}
2023-03-20 16:52:30 +01:00
basic_auth:
username: {{ opensearch_user }}
password: {{ opensearch_pass }}
2023-03-20 16:33:38 +01:00
relabel_configs:
- source_labels: [ __address__ ]
target_label: instance
regex: '(.*):9200'
replacement: '${1}'
2023-04-21 15:22:24 +02:00
2023-03-20 16:33:38 +01:00
{% endif %}
2023-03-21 16:00:49 +01:00
{% if prometheus_gitlab_exporter_targets is defined %}
# gitlab #
2023-03-21 16:19:50 +01:00
- job_name: gitlab-nginx
2023-03-21 16:00:49 +01:00
static_configs:
- targets:
{% for target in prometheus_gitlab_exporter_targets %}
- {{ target }}:8060
2023-03-21 17:19:26 +01:00
{% endfor %}
- job_name: gitlab-node
static_configs:
- targets:
{% for target in prometheus_gitlab_exporter_targets %}
- {{ target }}:9101
2023-03-21 16:00:49 +01:00
{% endfor %}
- job_name: gitlab-redis
static_configs:
- targets:
{% for target in prometheus_gitlab_exporter_targets %}
- {{ target }}:9121
{% endfor %}
- job_name: gitlab-postgres
static_configs:
- targets:
{% for target in prometheus_gitlab_exporter_targets %}
- {{ target }}:9187
{% endfor %}
- job_name: gitlab-workhorse
static_configs:
- targets:
{% for target in prometheus_gitlab_exporter_targets %}
- {{ target }}:9229
{% endfor %}
- job_name: gitlab-rails
metrics_path: "/-/metrics"
static_configs:
- targets:
{% for target in prometheus_gitlab_exporter_targets %}
2023-03-21 16:58:06 +01:00
- {{ target }}:8880
2023-03-21 16:00:49 +01:00
{% endfor %}
- job_name: gitlab-sidekiq
static_configs:
- targets:
{% for target in prometheus_gitlab_exporter_targets %}
- {{ target }}:8082
{% endfor %}
- job_name: gitlab_exporter_database
metrics_path: "/database"
static_configs:
- targets:
{% for target in prometheus_gitlab_exporter_targets %}
- {{ target }}:9168
{% endfor %}
- job_name: gitlab_exporter_sidekiq
metrics_path: "/sidekiq"
static_configs:
- targets:
{% for target in prometheus_gitlab_exporter_targets %}
- {{ target }}:9168
{% endfor %}
- job_name: gitaly
static_configs:
- targets:
{% for target in prometheus_gitlab_exporter_targets %}
- {{ target }}:9236
{% endfor %}
2023-04-21 15:22:24 +02:00
2023-03-21 16:00:49 +01:00
{% endif %}