206 lines
6.1 KiB
Django/Jinja
206 lines
6.1 KiB
Django/Jinja
# {{ 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.
|
||
|
||
# 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.
|
||
- job_name: '{{ prometheus_server_job_name }}'
|
||
|
||
# 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
|
||
|
||
# metrics_path defaults to '/metrics'
|
||
# scheme defaults to 'http'.
|
||
|
||
static_configs:
|
||
- targets: ['localhost:9090']
|
||
|
||
{% if prometheus_node_exporter_targets is defined %}
|
||
# node exporter #
|
||
- job_name: node
|
||
scrape_interval: 30s
|
||
scrape_timeout: 10s
|
||
static_configs:
|
||
- targets:
|
||
{% for target in prometheus_node_exporter_targets %}
|
||
- {{ target }}:9100
|
||
{% endfor %}
|
||
{% endif %}
|
||
|
||
{% if prometheus_mysqld_exporter_targets is defined %}
|
||
# mysql exporter #
|
||
- job_name: mysql
|
||
scrape_interval: 30s
|
||
scrape_timeout: 10s
|
||
static_configs:
|
||
{% 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 %}
|
||
- targets:
|
||
{% for target in prometheus_mysqld_exporter_targets %}
|
||
- {{ target }}:9104
|
||
{% endfor %}
|
||
{% endif %}
|
||
{% endif %}
|
||
|
||
{% if prometheus_mongodb_exporter_targets is defined %}
|
||
# mongoDB exporter #
|
||
- job_name: mongodb
|
||
scrape_interval: 30s
|
||
scrape_timeout: 10s
|
||
static_configs:
|
||
{% 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 %}
|
||
- targets:
|
||
{% for target in prometheus_mongodb_exporter_targets %}
|
||
- {{ target }}:9216
|
||
{% endfor %}
|
||
{% endif %}
|
||
{% endif %}
|
||
|
||
{% if prometheus_postgres_exporter_targets is defined %}
|
||
# postgresql exporter #
|
||
- job_name: postgresql
|
||
scrape_interval: 30s
|
||
scrape_timeout: 10s
|
||
static_configs:
|
||
{% 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 %}
|
||
- targets:
|
||
{% for target in prometheus_postgres_exporter_targets %}
|
||
- {{ target }}:9187
|
||
{% endfor %}
|
||
{% endif %}
|
||
{% endif %}
|
||
|
||
{% if prometheus_phpfpm_exporter_targets is defined %}
|
||
# PHP-FPM exporter #
|
||
- job_name: phpfpm
|
||
scrape_interval: 30s
|
||
scrape_timeout: 10s
|
||
static_configs:
|
||
- targets:
|
||
{% for target in prometheus_phpfpm_exporter_targets %}
|
||
- {{ target }}:9253
|
||
{% endfor %}
|
||
{% endif %}
|
||
|
||
{% if prometheus_apache_exporter_targets is defined %}
|
||
# apache exporter #
|
||
- job_name: apache
|
||
scrape_interval: 30s
|
||
scrape_timeout: 10s
|
||
static_configs:
|
||
- targets:
|
||
{% for target in prometheus_apache_exporter_targets %}
|
||
- {{ target }}:9117
|
||
{% endfor %}
|
||
{% endif %}
|
||
|
||
{% if prometheus_haproxy_exporter_targets is defined %}
|
||
# haproxy exporter #
|
||
- job_name: haproxy
|
||
scrape_interval: 30s
|
||
scrape_timeout: 10s
|
||
static_configs:
|
||
- targets:
|
||
{% for target in prometheus_haproxy_exporter_targets %}
|
||
- {{ target }}:8404
|
||
{% endfor %}
|
||
{% endif %}
|
||
|
||
{% if prometheus_varnish_exporter_targets is defined %}
|
||
- job_name: varnish
|
||
scrape_interval: 30s
|
||
scrape_timeout: 10s
|
||
static_configs:
|
||
- targets:
|
||
{% for target in prometheus_varnish_exporter_targets %}
|
||
- {{ target }}:9131
|
||
{% endfor %}
|
||
{% endif %}
|
||
|
||
{% if prometheus_blackbox_exporter is defined %}
|
||
# blacbox #
|
||
{% if prometheus_blackbox_exporter_http is defined %}
|
||
{% for target in prometheus_blackbox_exporter_http.values() %}
|
||
## http check ##
|
||
- job_name: blackbox - url {{ target.service_name }}
|
||
scrape_interval: 30s
|
||
scrape_timeout: 10s
|
||
metrics_path: {{ target.metrics_path }}
|
||
params:
|
||
module: [http_2xx]
|
||
static_configs:
|
||
- targets:
|
||
- {{target.host }}
|
||
relabel_configs:
|
||
- source_labels: [__address__]
|
||
target_label: __param_target
|
||
- source_labels: [__param_target]
|
||
target_label: instance
|
||
- target_label: __address__
|
||
replacement: localhost:9115
|
||
{% endfor %}
|
||
{% endif %}
|
||
{% if prometheus_blackbox_exporter_ping is defined %}
|
||
{% for target in prometheus_blackbox_exporter_ping.values() %}
|
||
## ping ##
|
||
- job_name: blackbox - ping {{ target.service_name }}
|
||
scrape_interval: 30s
|
||
scrape_timeout: 10s
|
||
params:
|
||
module: [icmp]
|
||
static_configs:
|
||
- targets:
|
||
- {{ target.host }}
|
||
relabel_configs:
|
||
- source_labels: [__address__]
|
||
target_label: __param_target
|
||
- source_labels: [__param_target]
|
||
target_label: instance
|
||
- target_label: __address__
|
||
replacement: localhost:9115
|
||
{% endfor %}
|
||
{% endif %}
|
||
{% endif %}
|