Prometheus 配置解析
配置文件例子
global: scrape_interval: 15s evaluation_interval: 15s alerting: alertmanagers: - static_configs: - targets: - localhost:9093 rule_files: - "rules.yml" scrape_configs: - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] - job_name: 'node_exporter' consul_sd_configs: - server: 192.168.10.17:8500 tags: - node_exporter
rules.yml
groups: - name: node-alert.rules rules: - alert: NodeNetworkReceiveTooHigh expr: irate(node_network_receive_bytes_total{device="eth0"}[2m]) > 1000 for: 5m labels: severity: warning annotations: description: "{{ $labels.device }}当前速率 {{ $value }} bytes" summary: "网络下载速度过快" - name: node.rules rules: - record: node_network_receive_bytes_total:irate expr: irate(node_network_receive_bytes_total{device="eth0"}[2m])
联邦配置
scrape_configs: - job_name: 'federate' scrape_interval: 15s honor_labels: true metrics_path: '/federate' params: 'match[]': - '{job="prometheus"}' - '{__name__=~"job:.*"}' static_configs: - targets: - 'source-prometheus-1:9090' - 'source-prometheus-2:9090' - 'source-prometheus-3:9090'