0

在将规则文件添加到之后,我添加了简单的规则以从节点导出器获取可用磁盘空间

普罗米修斯.yml

文件,prometheus 没有启动,可能是规则文件的一些问题。

# my global config
global:
  scrape_interval:     60s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 60s # 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:
  - 'low-disk-space.rules'
  # - 'sample-rules.yml'
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  #- job_name: 'prometheus'

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

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

  - job_name: 'machine'
    static_configs:
    - targets: ['localhost:9100']

我的规则文件如下所示:

groups:
  - name: disk_usage
    interval: 5s
    rules:
    - record: node_exporter:node_filesystem_free:fs_used_percents
      expr: 100 - 100 * ( node_filesystem_free{mountpoint="/"} / node_filesystem_size{mountpoint="/"} )

    - name: alerting_rules
      rules:
        - alert: DiskSpace10%Free
          expr: node_exporter:node_filesystem_free:fs_used_percents >= 90
          labels:
            severity: moderate
          annotations:
            summary: "Instance {{ $labels.instance }} is low on disk space"
            description: "{{ $labels.instance }} has only {{ $value }}% free."

prometheus 版本:2.3.2 在此处发布了另一个关于规则文件验证的问题 如何在 ubuntu 中安装最新版本的 prometheus/promtool?

4

1 回答 1

0

您对规则文件的缩进稍微偏离了一点,第二部分 ( alerting_rules) 缩进太远,请尝试将其与disk_usage录制规则相提并论。

groups:
  - name: disk_usage
    interval: 5s
    rules:
    - record: node_exporter:node_filesystem_free:fs_used_percents
      expr: 100 - 100 * ( node_filesystem_free{mountpoint="/"} / node_filesystem_size{mountpoint="/"} )

  - name: alerting_rules
    rules:
      - alert: DiskSpace10%Free
        expr: node_exporter:node_filesystem_free:fs_used_percents >= 90
        labels:
          severity: moderate
        annotations:
          summary: "Instance {{ $labels.instance }} is low on disk space"
          description: "{{ $labels.instance }} has only {{ $value }}% free."

于 2019-02-23T22:48:50.857 回答