当前位置:网站首页>Prometheus + alertmanager message alert
Prometheus + alertmanager message alert
2022-07-29 02:20:00 【I have a fat Mantis】
List of articles
install Prometheus
To configure prometheus.yml, The default configuration https://prometheus.io/docs/prometheus/latest/getting_started/
mkdir /opt/promethus
cd /opt/promethus/
vim prometheus.yml
Default prometheus.yml
global:
scrape_interval: 15s # By default, scrape targets every 15 seconds.
# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
external_labels:
monitor: 'codelab-monitor'
# 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'
# Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: 5s
static_configs:
- targets: ['localhost:9090']
Pull the mirror image
docker pull prom/prometheus
Start installation
docker run -d \
-p 9090:9090 \
-v /opt/prometheus:/etc/prometheus \
--name promethenus \
--restart=always \
prom/prometheus
-p Port mapping
-v Mount the file
-name Instance naming
–restart=always restart docker The container starts automatically
browser ip Add ports 9090 Can access
install AlertManager
To configure alertmanager.yml, The default configuration https://prometheus.io/docs/prometheus/latest/getting_started/
mkdir /opt/alertmanager
cd /opt/alertmanager/
vim alertmanager.yml
Default alertmanager.yml
global:
resolve_timeout: 5m
route:
group_by: ['alertname']
group_wait: 10s
group_interval: 10s
repeat_interval: 1h
receiver: 'web.hook'
receivers:
- name: 'web.hook'
webhook_configs:
- url: 'http://127.0.0.1:5001/'
inhibit_rules:
- source_match:
severity: 'critical'
target_match:
severity: 'warning'
equal: ['alertname', 'dev', 'instance']
browser ip Add ports 9090 Can access
Pull the mirror image
docker pull bitnami/alertmanager:latest
Start installation
docker run -d \
-p 9093:9093 \
--name alertmanager
-v /opt/alertmanager/alertmanager.yml:/opt/bitnami/alertmanager/conf/config.yml \
--restart=always \
bitnami/alertmanager:latest
browser ip Add ports 9093 Can access
To configure Prometheus
prometheus.yml Example
global:
scrape_interval: 15s
external_labels:
monitor: 'codelab-monitor'
scrape_configs:
- job_name: 'prometheus'
scrape_interval: 5s
static_configs:
- targets: ['localhost:9090']
- job_name: 'service'
static_configs:
- targets: ['192.168.xxx.0:9100']
- targets: ['192.168.xxx.1:9100']
alerting:
alertmanagers:
- static_configs:
- targets:
- [ The server ip]:9093
rule_files:
- "rules.yml"
alerting.alertmanagers.static_configs.targets:AlertManager Deployed servers [ ip: port ]
rule_files: newly build rules.yml, Path and prometheus.yml In the same place
rules.yml Example
groups:
- name: CPU-rule
rules:
- alert: High-CPU-80
expr: 100-avg(irate(node_cpu_seconds_total{
job="component",mode="idle"}[5m]))by(instance)*100 > 80
for: 1m
labels:
severity: warning
annotations:
description: "{
{$labels.instance}}: Client CPU is above 80% (current value is: {
{ $value }}"
- alert: High-CPU-90
expr: 100-avg(irate(node_cpu_seconds_total{
job="component",mode="idle"}[5m]))by(instance)*100 > 90
for: 1m
labels:
severity: warning
annotations:
description: "{
{$labels.instance}}: Client CPU is above 90% (current value is: {
{ $value }}"
- name: Menory-rule
rules:
- alert: HighMenory-80
expr: (1 - (node_memory_MemAvailable_bytes / (node_memory_MemTotal_bytes)))* 100 > 80
for: 1m
labels:
severity: warning
annotations:
description: "jobname:{
{$labels.job}}, instance:{
{$labels.instance}}, Client num is above 80%, current value is: {
{ $value }}"
- alert: HighMenory-90
expr: (1 - (node_memory_MemAvailable_bytes / (node_memory_MemTotal_bytes)))* 100 > 90
for: 1m
labels:
severity: warning
annotations:
description: "jobname:{
{$labels.job}}, instance:{
{$labels.instance}}, Client num is above 90%, current value is: {
{ $value }}"
- name: jvm-rule
rules:
- alert: High-jvm-80
expr: jvm_memory_usage_after_gc_percent{
} * 100 > 80
for: 1m
labels:
severity: warning
annotations:
description: "jobname:{
{$labels.job}}, application :{
{$labels.application }}, jvm num is above 80%, current value is: {
{ $value }}"
- alert: High-jvm-90
expr: jvm_memory_usage_after_gc_percent{
} * 100 > 90
for: 1m
labels:
severity: warning
annotations:
description: "jobname:{
{$labels.job}}, application :{
{$labels.application }}, jvm num is above 90%, current value is: {
{ $value }}"
name: It's similar to grouping , The example is divided into cpu、 Memory 、jvm
alert: Custom naming
expr: Index value
for: The duration of the
label: label , Customize
annotations: annotation , Customize
Indicator Status 
Monitor target status ,status - targets
To configure AlertManager
alertmanager.yml Example
global:
smtp_smarthost: 'smtp.exmail.qq.com:465'
smtp_from: '[email protected]'
smtp_auth_username: '[email protected]'
smtp_auth_password: '111'
smtp_require_tls: false
route:
receiver: mail
receivers:
- name: 'mail'
email_configs:
- to: '[email protected]'
- to: '[email protected]'

边栏推荐
- JVM内存溢出在线分析Dump文件以及在线分析打开.hprof文件得出JVM运行报告jvisualvm怎么在线分析
- Understand the clock tree in STM32 in simple terms
- ES6 语法扩展
- MotionLayout--在可视化编辑器中实现动画
- 年中总结 | 与自己对话,活在当下,每走一步都算数
- 表单校验 隐藏的输入框 显示才校验
- 基于C51控制蜂鸣器
- TI C6000 TMS320C6678 DSP+ Zynq-7045的PS + PL异构多核案例开发手册(2)
- 第十五天(VLAN相关知识)
- Mobile communication -- simulation model of error control system based on convolutional code
猜你喜欢

Mathematical modeling -- cold proof simulation of low temperature protective clothing with phase change materials

什么是作用域和作用域链

Establish an engineering template based on STM32 in keil -- detailed steps

Navigation -- realize data transmission and data sharing between fragments

Why can't Bi software do correlation analysis

Anti crawler mechanism solution: JS code generates random strings locally

Cookies and sessions

Internet of things development -- mqtt message server emqx

Rgbd point cloud down sampling

JetPack--Navigation实现页面跳转
随机推荐
Detailed explanation of IVX low code platform series -- Overview (II)
Derivation of Euler angle differential equation
TI C6000 TMS320C6678 DSP+ Zynq-7045的PS + PL异构多核案例开发手册(2)
h5背景音乐通过触摸自动播放
QT qstackedwidget multi interface switching
2022.7.28-----leetcode.1331
Comprehensive use method of C treeview control
第十四天:续第十三天标签相关知识
ES6 syntax extension
表单校验 隐藏的输入框 显示才校验
控制输入框弹出弹窗 和不弹出窗口
autoware中ndtmatching功能加载点云图坐标系修正的问题
Probability Density Reweight
Blind separation of speech signals based on ICA and DL
试着换个角度理解低代码平台设计的本质
连PostgreSQL问题:expected authentication request from server, but received v
在Qt中如何编写插件,加载插件和卸载插件
响应式织梦模板户外露营类网站
Quanzhi t3/a40i industrial core board, 4-core [email protected] The localization rate reaches 100%
The growth path of embedded engineers