1. 程式人生 > 實用技巧 >【Prometheus專題】3. Prometheus監控元件的配置

【Prometheus專題】3. Prometheus監控元件的配置

prometheus監控元件的配置的自由度並不是很高,也有一定得規範,總的還說還是中規中矩

Prometheus

首先我們來看一下預設的配置

# my global config
global:
  scrape_interval:     15s     # 多久 收集 一次資料
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).   # 每次 收集資料的 超時時間

# 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.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
    - targets: ['localhost:9090']

這裡主要說明下alerting和prometheus監控自身部分的配置,因為我們修改了服務的URL,所以預設的配置是無法傳送告警的

alerting:
  alertmanagers:
  - static_configs:
    - targets: ['localhost:9093']
    path_prefix: '/alertmanager'
    timeout: 30s

- job_name: 'prometheus'
    scrape_interval: 60s
    metrics_path: '/prometheus/metrics'
    static_configs:
    - targets: ['localhost:9090']

... 未完成,明天寫