下载grafana,
下载链接:https://repo.huaweicloud.com/grafana/7.4.3/
网盘下载:
链接:https://pan.baidu.com/s/1JJgJ90k_VGctOgo4ZWe7Aw
提取码:ympu
[root@localhost ~]# mv grafana-7.4.3.linux-amd64.tar.gz /opt/grafana [root@localhost opt]# ls apache-maven-3.5.4 elasticsearch-analysis-ik-7.4.0.zip maven apache-maven-3.5.4-bin.tar.gz filebeat node_export containerd grafana node_exporter-0.16.0.linux-amd64.tar.gz elasticsearch-7.6.1 grafana-7.4.3 prometheus elasticsearch-analysis-ik-7.4.0 kibana-7.6.1-linux-x86_64 rh [root@localhost opt]#
解压:
[root@localhost opt]# tar -zxvf grafana [root@localhost opt]# cd grafana-7.4.3/ [root@localhost grafana-7.4.3]# ls bin conf LICENSE NOTICE.md plugins-bundled public README.md scripts VERSION [root@localhost grafana-7.4.3]#4 启动和关闭grafana 第一步:查看端口是否占用
查看端口是否占用,如果占用就关闭端口
[root@localhost grafana-7.4.3]# lsof -i:300 [root@localhost grafana-7.4.3]# lsof -i:3000 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME grafana-s 68257 grafana 6u IPv6 639958 0t0 TCP *:hbci (LISTEN)
关闭端口:
[root@localhost grafana-7.4.3]# kill 68257 [root@localhost grafana-7.4.3]# lsof -i:3000 [root@localhost grafana-7.4.3]#第二步:启动
[root@localhost grafana-7.4.3]# ./bin/grafana-server web第三步:查看UI界面 第四步:登录grafana
账号密码默认都是admin
直接ctrl+C即可
[root@localhost grafana-7.4.3]# pwd /opt/grafana-7.4.3 [root@localhost grafana-7.4.3]# cd conf/ [root@localhost conf]# ls defaults.ini ldap_multiple.toml ldap.toml provisioning sample.ini [root@localhost conf]# vim defaults.ini第二步:将邮件通道打开
defaults.ini的邮件的默认配置是没有打开的,如下:
#################################### SMTP / Emailing ##################### [smtp] enabled = false host = localhost:25 user = # If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;""" password = cert_file = key_file = skip_verify = false from_address = admin@grafana.localhost from_name = Grafana ehlo_identity = startTLS_policy = [emails] welcome_email_on_sign_up = false templates_pattern = emails/*.html
修改为:
#################################### SMTP / Emailing ##################### [smtp] enabled = true host = smtp.qq.com:465 user = 15xxx775@qq.com # If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;""" password =dbvlxxxeh cert_file = key_file = skip_verify = false from_address = 15xxx775@qq.com from_name = Grafana ehlo_identity = startTLS_policy = [emails] welcome_email_on_sign_up = false templates_pattern = emails/*.html
保存退出
配置说明:
- host这里是你邮箱所在运营商的 SMTP 服务器。user 属性是发件人的邮箱地址。password 是发件人邮箱的登陆密码。from_address 与 user 属性一样,都是发件人的邮箱地址。from_name 是发件人的显示名称。
[root@localhost conf]# ../bin/grafana-server web第四步:通过 alerting 菜单添加告警渠道
进入添加channel页面
按如下模板适当填写
点击test
查看邮箱信息
首先配置dashboard面板,规则设置好了之后
点击alert创建alert
报警规则名称,多久检测一次,持续时间
具体监控组里的哪个指标,阈值是多少,还可以添加多个监控条件规则,下面的内容是Prometheus有的,按下面的内容进行设置即可
修改监控指标,设置阈值
选择报警渠道,可以添加多个,附加一些额外的信息
测试报警规则是否可用
右上角点击save进行保存
返回上一页进行查看,会发现该监控组里有条红线,表示的是上面监控规则设置的阈值
过一段时间之后,会出现下面的内容
然后就会报警,如下



