1.拉取镜像
docker pull prom/prometheus
2.创建配置文件
cd /root/prometheus touch prometheus.yml touch first_rules.yml
3.配置文件内容
- prometheus.yml文件内容
# 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). remote_write: # 使用远程存储,VictoriaMetrics时序数据库 - url: http://xxx.xxx.xx.xxx:8480/insert/0/prometheus remote_read: # 使用远程读取,VictoriaMetrics时序数据库 - url: http://xxx.xxx.xx.xxx:8481/select/0/prometheus # Alertmanager configuration alerting: alertmanagers: - static_configs: - targets: # 告警push到alertmanager集群 - xxx.xxx.xx.xxx:9093 - xxx.xxx.xx.xxx:9093 # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. rule_files: - "/etc/prometheus/rules/first_rules.yml" # 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=` to any timeseries scraped from this config. - job_name: "prometheus" # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: - targets: ["localhost:9090"]
- first_rule.yml配置文件内容
groups: - name: default_group rules: - alert: sqlserver-default annotations: description: sqlserver-exporter............ summary: sqlserver-exporter............ expr: up{job="sqlserver-exporter"}
- first_rule.yml配置文件内容