Prometheus集成telegram报警

目录

一、安装Prometheus

二、安装node_exporter采集器

三、安装alertmanager报警器

四、安装Grafana集成Prometheus


一、安装Prometheus

1、下载安装并解压

mkdir -p /data;cd /data
wget https://github.com/prometheus/prometheus/releases/download/v2.25.1/prometheus-2.25.1.linux-amd64.tar.gz
tar xf prometheus-2.25.1.linux-amd64.tar.gz
mv prometheus-2.25.1.linux-amd64 prometheus

2、修改配置文件

#备份配置文件
cp prometheus.yml{,.bak}

cat 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).

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      - localhost:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  - "rules/*.rules"
  # - "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'
    static_configs:
    - targets: ['localhost:9090']
#node_export添加
  - job_name: 'linux'
    static_configs:
    - targets: ['127.0.0.1:9100','192.168.10.12:9100']

3、编写报警规则

规则参考网址:https://awesome-prometheus-alerts.grep.to/rules#host-and-hardware

1)示例1:实例宕机规则

cd prometheus;mkdir rules

cat rules/first.rules 
groups:
- name: example
  rules:
  - alert: InstanceDown
    expr: up == 0
    for: 5m
    labels:
        severity: warning
    annotations:
        summary: "Instance {
  { $labels.instance }} down"
        description: "{
  { $labels.instance }} of job {
  { $labels.job }} has been down for more than 5 minutes."

2)示例模板

groups:
- name: 实例告警规则
  rules:
  - alert: 实例存活告警
    expr: up == 0
    for: 1m
    labels:
      user: prometheus
      severity: warning
    annotations:
      description: "{
  { $labels.instance }} of job {
  { $labels.job }} has been down for more than 1 minutes."

# mem报警
  - alert: 内存使用率告警
    expr: (node_memory_MemTotal_bytes - (node_memory_MemFree_bytes+node_memory_Buffers_bytes+node_memory_Cached_bytes )) / node_memory_MemTotal_bytes * 100 > 80
    for: 1m
    labels:
      user: prometheus
      severity: warning
    annotations:
      description: "服务器: 内存使用超过80%!(当前值: {
  { $value }}%)"

# disk报警
  - alert: 磁盘使用率告警
    expr: (node_filesystem_size_bytes - node_filesystem_avail_bytes) / node_filesystem_size_bytes * 100 > 80
    for: 1m
    labels:
      user: prometheus
      severity: warning
    annotations:
      description: "服务器: 磁盘设备: 使用超过80%!(挂载
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
要在Prometheus中设置钉钉报警,你需要进行以下步骤: 1. 首先,你需要在Prometheus的配置文件`prometheus.yml`中定义告警规则(AlertRule)。你可以使用Prometheus的查询语言(PromQL)来定义告警规则,以监测指标并触发告警。具体的告警规则配置可以参考\[1\]。 2. 接下来,你需要安装和配置Alertmanager。Alertmanager是Prometheus的一个报警通知组件,负责接收来自Prometheus告警信息,并发送通知到不同的目标,比如钉钉。你可以从Alertmanager的官方GitHub页面下载并安装Alertmanager\[2\]。 3. 在Alertmanager的配置文件中,你需要添加钉钉的配置信息。具体的配置可以参考Alertmanager的文档,其中包括钉钉的webhook地址、消息模板等信息。你可以根据需要自定义告警通知的内容和格式。 4. 最后,重新启动Prometheus和Alertmanager,使配置生效。 通过以上步骤,你就可以在Prometheus中设置钉钉报警了。当Prometheus监测到满足告警规则的条件时,会将告警信息发送给Alertmanager,然后Alertmanager会将告警通知发送到钉钉。这样,你就能及时收到钉钉上的告警通知了。 #### 引用[.reference_title] - *1* [Prometheus集成钉钉报警](https://blog.csdn.net/weixin_45203131/article/details/118545413)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [prometheus自定义钉钉报警](https://blog.csdn.net/qq_41892421/article/details/116761373)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不忘丶初衷

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值