prometheus配置alertmanager

DevOps Prometheus评论2,407字数 176阅读0分35秒阅读模式

修改prometheus配置文件

[root@devops-prometheus ecs-user]# vim /usr/local/prometheus/prometheus.yml
# Alertmanager configuration
alerting:
  alertmanagers:
    - static_configs:
        - targets:
           - 10.1.0.157:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  - "first_rules.yml"
  # - "second_rules.yml"

prometheus配置alertmanager-图片1

配置规则

[root@devops-prometheus prometheus]# pwd
/usr/local/prometheus
[root@devops-prometheus prometheus]# vim first_rules.yml
groups:
- name: Container CPU usage
  rules:
  - alert: ContainerCpuUsage
    expr: (sum(rate(container_cpu_usage_seconds_total{name!=""}[3m])) BY (instance, name) * 100) > 80
    for: 2m
    labels:
      severity: warning
    annotations:
      summary: Container CPU usage (instance {{ $labels.instance }})
      description: "Container CPU usage is above 80%\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"

检查规则有没有问题

[root@devops-prometheus prometheus]#  ./promtool check config prometheus.yml
Checking prometheus.yml
  SUCCESS: 1 rule files found
 SUCCESS: prometheus.yml is valid prometheus config file syntax

Checking first_rules.yml
  SUCCESS: 1 rules found

重启服务

[root@devops-prometheus prometheus]# systemctl restart prometheus

prometheus配置alertmanager-图片2

  • 更多现成规则https://awesome-prometheus-alerts.grep.to/

继续阅读
 
DevOps
  • 本文由 DevOps 发表于 2022年11月28日 11:29:35
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
  • Alertmanager
Alertmanager报警 Prometheus

Alertmanager报警

一、介绍 preometheus 报警由 Alertmanager 的独立工具进行管理的,它是一个可以集群化的独立报警管理工具。 我们需要在 Prometheus 上定义报警规则,这些规则将使用收集到...
Prometheus监控mysql Prometheus

Prometheus监控mysql

简述 mysql_exporter是用来收集MysQL或者Mariadb数据库相关指标的,mysql_exporter需要连接到数据库并有相关权限。 创建用户并授权 root@bjzhanjiserv...
Prometheus监控redis Prometheus

Prometheus监控redis

简述 redis_exporter prometheus官方开源的专门监控Redis的插件工具,我们直接使用就可以。 更多资料介绍点我 安装配置redis_exporter [root@devops ...
Prometheus监控kafka Prometheus

Prometheus监控kafka

前言 Kafka现有开源的集群监控方案:kafka-manager、kafka-monitor、kafka-eagle、KafkaOffsetMonitor,但有所限制监控指标被固化,不易扩展、预警功...

发表评论