以下是prometheus配置文件详解,重点地方有中文简介
# my global config
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).# 查询日志查询日志路径设置query_log_file: ./query.log# Alertmanager configuration
alerting:alertmanagers:- static_configs:- targets:# - alertmanager:9093# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:# - "first_rules.yml"# - "second_rules.yml"# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
# 配置每一个需要抓取metrics的endpoint配置
scrape_configs:# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.# 监控rabbitmq的相关metrics,需要先enable rabbitmq_prometheus 插件,开启15692端口- job_name: "rabbitmq-prometheus"metrics_path: "/metrics"scheme: "http"static_configs:# 可以设置多个targaet- targets: ["10.240.184.81:15692"]labels:kind: rabbit- targets: ["10.240.184.81:8080"]labels:kind: nginx# 监控自身节点需要- job_name: "prometheus---node"static_configs:# 一个target可以设置多个endpoint# localhost:9090 监控prometheus本身# localhost:9100 监控promethues所在节点的操作系统指标- targets: ["localhost:9090","localhost:9100"]# 抓取的操作系统的metrics,需要先在操作系统上部署node_exporter,然后再做如下配置# 对于节点类型的可以指定job_name为主机名# 在label中可以设置ip:ip值,paso:paso名等- job_name: "node2"static_configs:- targets: ["10.240.141.55:9100"]# 抓取的k8s的相关metrics,需要做如下https配置# 需要配置CA证书,公钥私钥等- job_name: "kube-apiserver"scheme: "https"tls_config:ca_file: /kyzjj/prometheus-2.37.5.linux-amd64/ssl/ca.pemcert_file: /kyzjj/prometheus-2.37.5.linux-amd64/ssl/default-admin.pemkey_file: /kyzjj/prometheus-2.37.5.linux-amd64/ssl/default-admin-key.pemstatic_configs:- targets: ["10.240.184.74:6443"]labels:kind: k8s