当前位置:网站首页>prometheus告警记录持久化(历史告警保存与统计)
prometheus告警记录持久化(历史告警保存与统计)
2022-04-23 06:01:00 【洒满阳光的午后】
前段时间碰到一个需求:将Prometheus的历史告警进行持久化保存,一遍进行分析统计。在尝试了一些工具后,最终选用了alertsnitch+grafana的方案。
alertsnitch: https://gitlab.com/yakshaving.art/alertsnitch
简单介绍一下这个工具的原理,alertsnitch实现了一个webhook,通过在alertmanager中配置receiver为alertsbnitch webhook将告警发送给alertsnitch,alertsnitch对数据进行处理后存入Mysql/Postgre,详细介绍可参考其gitlab主页。
下面简单介绍一下使用方法(k8s安装,数据库使用Mysql)
1、Mysql创建alertsnitch所用数据库及对应账户,略。
2、安装alertsnitch,修改下面ALERTSNITCH_DSN的值
# alertsnitch-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: alertsnitch
namespace: alertmanager
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: alertsnitch
template:
metadata:
labels:
app.kubernetes.io/name: alertsnitch
spec:
containers:
- image: registry.gitlab.com/yakshaving.art/alertsnitch
name: alertsnitch
ports:
- containerPort: 9567
name: http
env:
- name: ALERTSNITCH_BACKEND
value: mysql
- name: ALERTSNITCH_DSN
value: ${MYSQL_USER}:${MYSQL_PASSWORD}(${MYSQL_IP}:${MYSQL_PORT})/{$MYSQL_DATABASE}
readinessProbe:
httpGet:
path: /-/ready
port: 9567
initialDelaySeconds: 30
periodSeconds: 10
livenessProbe:
httpGet:
path: /-/health
port: 9567
initialDelaySeconds: 60
periodSeconds: 10
apiVersion: v1
kind: Service
metadata:
name: alertsnitch
namespace: alertmanager
spec:
ports:
- name: http
port: 9567
targetPort: http
selector:
app.kubernetes.io/name: alertsnitch
3、配置alertmanager
route:
receiver: all
routes:
#所有告警收集
- receiver: all
continue: true
--------------------
receivers:
#alertsnitch
- name: 'all'
webhook_configs:
- url: 'http://alertsnitch.alertmanager.svc:9567/webhook'
send_resolved: true
4、可以使用grafana来进行历史告警的展示和统计,做一个现成的供参考
版权声明
本文为[洒满阳光的午后]所创,转载请带上原文链接,感谢
https://zhangrongjie.blog.csdn.net/article/details/123234231
边栏推荐
- [OSS file upload quick start]
- Thinkphp5 -- object (think \ response \ JSON) to array
- LeetCode刷题|897递增顺序搜索树
- 关于 synchronized、ThreadLocal、线程池、Atomic 原子类的 JUC 面试题
- The arithmetic square root of X in leetcode
- 【代码解析(7)】Communication-Efficient Learning of Deep Networks from Decentralized Data
- [step by step, even thousands of miles] MySQL reports a large number of unauthenticated user connection errors
- 修改Jupyter Notebook样式
- [ES6 quick start]
- Introduction to the top 12 domestic databases in 2021
猜你喜欢
随机推荐
Binary sum of leetcode questions
Solution to page cache problem (use with caution)
重启Oracle监听器会中断已有连接吗
tensorflow下载
TP5 uses redis
LeetCode刷题|两个链表的第一个公共节点
【代码解析(3)】Communication-Efficient Learning of Deep Networks from Decentralized Data
异常记录-8
你应该知道的 JVM 基础知识
Introduction to the top 12 domestic databases in 2021
SSM项目在阿里云部署
Imitation scallop essay reading page
MySQL 【读写锁+表锁+行锁+MVCC】
【不积跬步无以至千里】Oracle应用导数Ora-01455报错处理
DDOS攻击/防御介绍
SQL学习|窗口函数
异常记录-12
Oracle数据库性能分析之常用视图
Ansible basic commands, roles, built-in variables and tests judgment
Implementation of leetcode question brushing str ()