# Sample config for Prometheus. global: scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. # scrape_timeout is set to the global default (10s). # Attach these labels to any time series or alerts when communicating with # external systems (federation, remote storage, Alertmanager). external_labels: monitor: '{{datacenter}}' # Alertmanager configuration alerting: alertmanagers: - static_configs: - targets: {% for host in alertmanagers %} - '{{host}}' {% endfor %} scheme: https tls_config: # Prometheus will check that the node_exporter presents a certificate # signed by this ca. ca_file: '/etc/ssl/prometheus_client/root.ca.crt' # The cert and key are presented to node_exporter to authenticate # Prometheus as a client. cert_file: '/etc/ssl/prometheus_client/{{fqdn}}.crt' key_file: '/etc/ssl/prometheus_client/{{fqdn}}.key' # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. rule_files: - 'alerts/*.yml' scrape_configs: - job_name: lxc scheme: https tls_config: ca_file: '/etc/ssl/prometheus_client/root.ca.crt' cert_file: '/etc/ssl/prometheus_client/{{fqdn}}.crt' key_file: '/etc/ssl/prometheus_client/{{fqdn}}.key' file_sd_configs: - files: - 'lxc.yml' - job_name: bare_metal scheme: https tls_config: ca_file: '/etc/ssl/prometheus_client/root.ca.crt' cert_file: '/etc/ssl/prometheus_client/{{fqdn}}.crt' key_file: '/etc/ssl/prometheus_client/{{fqdn}}.key' file_sd_configs: - files: - 'bare_metal.yml' - job_name: postfix metrics_path: /postfix_metrics scheme: https tls_config: ca_file: '/etc/ssl/prometheus_client/root.ca.crt' cert_file: '/etc/ssl/prometheus_client/{{fqdn}}.crt' key_file: '/etc/ssl/prometheus_client/{{fqdn}}.key' file_sd_configs: - files: - 'postfix.yml' {% if groups['lxc_host'] is defined %} - job_name: lxc_host_cadvisor metrics_path: /cadvisor-metrics scheme: https tls_config: ca_file: '/etc/ssl/prometheus_client/root.ca.crt' cert_file: '/etc/ssl/prometheus_client/{{fqdn}}.crt' key_file: '/etc/ssl/prometheus_client/{{fqdn}}.key' static_configs: - targets: {% for host in groups['lxc_host'] %} - '{{host}}:9100' {% endfor %} - job_name: lxc_host_lvm metrics_path: /lvm-metrics scheme: https tls_config: ca_file: '/etc/ssl/prometheus_client/root.ca.crt' cert_file: '/etc/ssl/prometheus_client/{{fqdn}}.crt' key_file: '/etc/ssl/prometheus_client/{{fqdn}}.key' static_configs: - targets: {% for host in groups['lxc_host'] %} - '{{host}}:9100' {% endfor %} {% endif %} {% if blackbox_monitoring is defined %} ### blackbox exporter configuration ### {% for exporter in blackbox_exporters %} {% if blackbox_monitoring.http_no_tls is defined %} - job_name: {{exporter}}_http_no_tls scheme: https tls_config: ca_file: '/etc/ssl/prometheus_client/root.ca.crt' cert_file: '/etc/ssl/prometheus_client/{{fqdn}}.crt' key_file: '/etc/ssl/prometheus_client/{{fqdn}}.key' metrics_path: /probe params: module: [http_no_tls] static_configs: - targets: {% for host in blackbox_monitoring.http_no_tls %} - http://{{host}} {% endfor %} relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: {{exporter}}:9100 {% endif %} {% if blackbox_monitoring.http_2xx is defined %} - job_name: {{exporter}}_http_2xx scheme: https tls_config: ca_file: '/etc/ssl/prometheus_client/root.ca.crt' cert_file: '/etc/ssl/prometheus_client/{{fqdn}}.crt' key_file: '/etc/ssl/prometheus_client/{{fqdn}}.key' metrics_path: /probe params: module: [http_2xx] static_configs: - targets: {% for host in blackbox_monitoring.http_2xx %} - https://{{host}} {% endfor %} relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: {{exporter}}:9100 {% endif %} {% if blackbox_monitoring.http_custom is defined %} {% for custom in blackbox_monitoring.http_custom %} - job_name: {{exporter}}_{{ custom.name }}_http_custom scheme: https tls_config: ca_file: '/etc/ssl/prometheus_client/root.ca.crt' cert_file: '/etc/ssl/prometheus_client/{{fqdn}}.crt' key_file: '/etc/ssl/prometheus_client/{{fqdn}}.key' metrics_path: /probe params: module: [{{ custom.name }}_http_custom] static_configs: - targets: {% for target in custom.targets %} - {{ target }} {% endfor %} relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: {{exporter}}:9100 {% endfor %} {% endif %} {% if blackbox_monitoring.tls is defined %} - job_name: {{exporter}}_tls scheme: https tls_config: ca_file: '/etc/ssl/prometheus_client/root.ca.crt' cert_file: '/etc/ssl/prometheus_client/{{fqdn}}.crt' key_file: '/etc/ssl/prometheus_client/{{fqdn}}.key' metrics_path: /ssl_probe params: module: [tcp] static_configs: - targets: {% for host in blackbox_monitoring.tls %} - {{host}}{%if host is not search(':')%}:443{% endif %} {% endfor %} relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: {{exporter}}:9100 {% endif %} {% if blackbox_monitoring.internal_tls is defined %} - job_name: {{exporter}}_internal_tls scheme: https tls_config: ca_file: '/etc/ssl/prometheus_client/root.ca.crt' cert_file: '/etc/ssl/prometheus_client/{{fqdn}}.crt' key_file: '/etc/ssl/prometheus_client/{{fqdn}}.key' metrics_path: /ssl_probe params: module: [internal_ca_tcp] static_configs: - targets: {% for host in blackbox_monitoring.internal_tls %} - {{host}} {% endfor %} relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: {{exporter}}:9100 {% endif %} {% if blackbox_monitoring.dns is defined %} {% for domain in blackbox_monitoring.dns %} - job_name: {{exporter}}_{{domain}}_dns scheme: https tls_config: ca_file: '/etc/ssl/prometheus_client/root.ca.crt' cert_file: '/etc/ssl/prometheus_client/{{fqdn}}.crt' key_file: '/etc/ssl/prometheus_client/{{fqdn}}.key' metrics_path: /probe params: module: [dns_{{domain}}] static_configs: - targets: {% for host in groups['knotd'] %} - {{host}} {% endfor %} relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: {{exporter}}:9100 {% endfor %} {% endif %} {% endfor %} {% endif %}