prometheus告警
写点笔记
共 2332字,需浏览 5分钟
· 2021-06-23
下载好altermanager之后,我们解压。其中的altermanager.yml是altermanager的配置文件。主要用来管理告警信息发送的规则,也就是说给谁发,用那种方式。
这块作者简单测试了一下监控mysql的线程数的告警。首先配置一下prometheus的数据收集的规则和push告警信息的地址。
groups:
- name: test-mysql-rule
rules:
- alert: "连接数报警"
expr: mysql_global_variables_mysqlx_max_connections > 90 #连接数大于90就告警
for: 1s
labels:
severity: warning
annotations:
summary: "服务名:{{$labels.alertname}}"
description: "业务msyql连接数不够报警: 当前值为:{{ $value }}"
value: "{{ $value }}"
在prometheus配置文件中添加这个告警规则
# 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"] #发送到altermanager的告警分析中
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
- "tianjingle_rules.yml"
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=` to any timeseries scraped from this config.
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
# 添加msyql的监控
- job_name: 'mysql'
# 静态添加node
static_configs:
# 指定监控端
- targets: ['localhost:9104']
- job_name: 'bounter-monitor'
scrape_interval: 5s
metrics_path: '/actuator/prometheus'
static_configs:
- targets: ['localhost:8081']
配置好上述配置之后对prometheus重启。并在prometheus的alter栏目中查看告警是否触发。发现已经触发了告警配置。
global:
resolve_timeout: 5m
smtp_smarthost: 'smtp.qq.com:465'
smtp_from: '2695062879@qq.com'
smtp_auth_username: '2695062879@qq.com'
smtp_auth_password: '********'
smtp_require_tls: false
route:
receiver: mail
receivers:
name: 'mail'
email_configs:
to: '2695062879@qq.com'
配置好qq邮箱的报警提醒之后,我们重启altermanager。然后看一下是否会收到报警的邮件。稍等片刻,在邮箱中收到了邮件,如图。
早~
评论
10分钟带你上手 Prometheus
原文链接:https://www.cnblogs.com/cjsblog/p/11585145.htmlPrometheus(译:普罗米修斯)用领先的开源监控解决方案为你的指标和警报提供动力(赋能)。 1. 概述1.1. Prometheus是什么?Promethe
DevOps技术栈
1903
springboot第53集:微服务分布式架构,docker-compose,Prometheus,...
从0搭建一套Prometheus监控体系 简介: Prometheus是一款开源监控系统,起源于SoundCloud的警告工具包。自2012年以来,许多公司和组织开始广泛采用Prometheus。该项目具有活跃的开发人员和用户社区,吸引越来越多的...
程序源代码
0
打造出色的 Prometheus 监控系统,看完后薪资翻倍?
一、监控概念&误区 监控是管理基础设施和业务的核心工具,监控应该和应用程序一起构建和部署,没有监控,将无法了解你的系统运行环境,进行故障诊断,也无法阻止提供系统性的性能、成本和状态等信息。 误区: 要...
程序员面试吧
0