在将规则文件添加到
之后,我添加了简单的规则以从节点导出器获取可用磁盘空间prometheus.yml
文件,prometheus尚未启动,可能与规则文件有关。
def __init__(self,author,question,*args,**kwargs):
super().__init__(*args,**kwargs)
self.form.instance.user = author
self.form.instance.question = question
我的规则文件如下所示:
# 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']
普罗米修斯版本:2.3.2 在此发布了另一个有关验证规则文件的问题 how to install latest version of prometheus/promtool in ubuntu?
答案 0 :(得分: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."