lpt监控安装_jenkins_docs/Prometheus安装部署+监控+绘图+告警.md at master · lizenghua/jenkins_docs · GitHub...

Prometheus安装部署+监控+绘图+告警

安装部分

在官网下载对应的压缩包文件,解压、添加系统服务器、启动。

Node_exporter

安装命令

tar zxf node_exporter-0.17.0.linux-amd64.tar.gz -C /usr/local

vim /etc/systemd/system/node_exporter.service

[Unit]

Description=node_exporter

After=network.target

[Service]

Restart=on-failure

ExecStart=/usr/local/node_exporter-0.17.0.linux-amd64/node_exporter

[Install]

WantedBy=multi-user.target

systemctl start node_exporter

systemctl status node_exporter

systemctl enable node_exporter

验证

01.png

AlertManager

安装命令

tar zxf alertmanager-0.17.0.linux-amd64.tar.gz -C /usr/local

vim /etc/systemd/system/alertmanager.service

[Unit]

Description=Alertmanager

After=network-online.target

[Service]

Restart=on-failure

ExecStart=/usr/local/alertmanager-0.17.0.linux-amd64/alertmanager --config.file=/usr/local/alertmanager-0.17.0.linux-amd64/alertmanager.yml

[Install]

WantedBy=multi-user.target

systemctl start alertmanager

systemctl status alertmanager

systemctl enable alertmanager

netstat -anlpt | grep 9093

验证

02.png

Prometheus

Shell命令

tar zxf prometheus-2.9.2.linux-amd64.tar.gz -C /usr/local

vim /etc/systemd/system/prometheus.service

[Unit]

Description=Prometheus Server

Documentation=https://prometheus.io/docs/introduction/overview/

After=network-online.target

[Service]

Restart=on-failure

ExecStart=/usr/local/prometheus-2.9.2.linux-amd64/prometheus --config.file=/usr/local/prometheus-2.9.2.linux-amd64/prometheus.yml --storage.tsdb.path=/var/lib/prometheus --web.external-url=http://0.0.0.0:9090

[Install]

WantedBy=multi-user.target

验证

03.png

Grafana

安装

下载:https://mirrors.tuna.tsinghua.edu.cn/grafana/yum/el7/grafana-5.4.2-1.x86_64.rpm

rpm -ivh grafana-5.4.2-1.x86_64.rpm

systemctl start grafana-server

systemctl status grafana-server

systemctl enable grafana-server

netstat -anlpt | grep 3000

验证

06.png

配置部分

AlertManager

配置文件

global:

resolve_timeout: 5m

smtp_smarthost: 'smtp.qq.com:465'

smtp_from: 'xxxxx@qq.com'

smtp_auth_username: 'xxxx@qq.com'

smtp_auth_password: 'xxxkbpfmygbecg'

smtp_require_tls: false

route:

group_by: ['alertname']

group_wait: 10s

group_interval: 10s

repeat_interval: 1h

receiver: 'toemail'

receivers:

- name: 'toemail'

email_configs:

- to: 'xxxxx@qq.com'

send_resolved: true

- 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']

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

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.

rule_files:

- "rules/host_rules.yml"

# - "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=` to any timeseries scraped from this config.

- job_name: 'prometheus'

# metrics_path defaults to '/metrics'

# scheme defaults to 'http'.

static_configs:

- targets: ['localhost:9090']

- job_name: 'my target'

static_configs:

- targets: ['localhost:9100']

mkdir rules && vim rules/host_rules.yml

groups:

- name: 'Linux Instances'

rules:

- alert: InstanceDown

expr: up == 0

for: 5s

labels:

severity: page

# Prometheus templates apply here in the annotation and label fields of the alert.

annotations:

description: 'has been down for more than 5 s.'

验证

查看目标

04.png

查看告警配置

05.png

告警

模拟node_exporter宕机

systemctl stop node_exporter

08.png

09.png

查看邮箱收件箱

10.png

以上就完成了一个简单的监控告警配置!特别感谢网上的一些文档。

参考文档:https://jianshu.com/p/e59cfd15612e

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
一、prometheus简介 Prometheus是一个开源的系统监控告警系统,现在已经加入到CNCF基金会,成为继k8s之后第二个在CNCF维护管理的项目,在kubernetes容器管理系统中,通常会搭配prometheus进行监控prometheus支持多种exporter采集数据,还支持通过pushgateway进行数据上报,Prometheus再性能上可支撑上万台规模的集群。 二、prometheus架构图 三、prometheus组件介绍 1.Prometheus Server: 用于收集和存储时间序列数据。 2.Client Library: 客户端库,检测应用程序代码,当Prometheus抓取实例的HTTP端点时,客户端库会将所有跟踪的metrics指标的当前状态发送到prometheus server端。 3.Exporters: prometheus支持多种exporter,通过exporter可以采集metrics数据,然后发送到prometheus server端 4.Alertmanager: 从 Prometheus server 端接收到 alerts 后,会进行去重,分组,并路由到相应的接收方,发出报警,常见的接收方式有:电子邮件,微信,钉钉, slack等。 5.Grafana:监控仪表盘 6.pushgateway: 各个目标主机可上报数据到pushgatewy,然后prometheus server统一从pushgateway拉取数据。 四、课程亮点 五、效果图展示 六、讲师简介 先超(lucky):高级运维工程师、资深DevOps工程师,在互联网上市公司拥有多年一线运维经验,主导过亿级pv项目的架构设计和运维工作 主要研究方向: 1.云计算方向:容器 (kubernetes、docker),虚拟化(kvm、Vmware vSphere),微服务(istio),PaaS(openshift),IaaS(openstack)等2.系统/运维方向:linux系统下的常用组件(nginx,tomcat,elasticsearch,zookeeper,kafka等),DevOps(Jenkins+gitlab+sonarqube+nexus+k8s),CI/CD,监控(zabbix、prometheus、falcon)等 七、课程大纲
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值