热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

grafana监控配置

一、配置开启smtp服务1、编辑grafana配置文件grafana.ini[smtp]enabledtruehostsmtp.163.com:25user157xxxx3606@

一、配置开启smtp服务


1、编辑grafana配置文件grafana.ini

[smtp]
enabled = true
host = smtp.163.com:25
user = 157xxxx3606@163.com
password = 自己的密码(如果是qq邮箱则是授权码)
skip_verify = true
from_address = 157xxxx3606@163.com

2、重启grafana服务生效

systemctl start grafana-server

二、web端定义监控

左边面板的铃铛标记Alerting--->Notification channels


 三、应用监控

Name 自定义
Evaluate every 1m For 2m #每1min监控一次,连续2min超过上限则告警;
WHEN avg() OF query(A,5m,now) IS BELOW -2 #默认avg,有好多选项,根据需求选择,字母A代表选择的metrice中这只的sql(这部分没搞明白,默认即可)。5m表示从现在为基准,5min之前的那个点为起始点,now为结束点,平均值小于-2则告警;
Send to 选择之前定义的告警
Messsage 告警信息

四、安装grafana-image-renderer插件

其作用是渲染邮件中的图片,否则收到的邮件就是如下效果:

grafana-cli plugins install grafana-image-renderer #安装插件
grafana-cli plugins ls #查看已经安装的插件

   此时还需要重启grafana来使插件生效;图片的渲染还需要chrom的支持,所以还需要安装chrome

wget https://dl.grafana.com/enterprise/release/grafana-enterprise-8.3.3-1.x86_64.rpm
yum install grafana-enterprise-8.3.3-1.x86_64.rpm -y

  并且需要检查以下chrome所需要的插件是否齐全,如果显示为“not found”,则需要安装该插件;

[root@master grafana]# ldd /var/lib/grafana/plugins/grafana-image-renderer/chrome-linux/chrome
linux-vdso.so.1 => (0x00007fff18197000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f4e47beb000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f4e479cf000)
libgobject-2.0.so.0 => /lib64/libgobject-2.0.so.0 (0x00007f4e4777e000)
libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007f4e47468000)
libnss3.so => /lib64/libnss3.so (0x00007f4e47133000)
libnssutil3.so => /lib64/libnssutil3.so (0x00007f4e46f03000)
libsmime3.so => /lib64/libsmime3.so (0x00007f4e46cdb000)
libnspr4.so => /lib64/libnspr4.so (0x00007f4e46a9d000)
libatk-1.0.so.0 => /lib64/libatk-1.0.so.0 (0x00007f4e46877000)
libatk-bridge-2.0.so.0 => /lib64/libatk-bridge-2.0.so.0 (0x00007f4e46648000)
libgio-2.0.so.0 => /lib64/libgio-2.0.so.0 (0x00007f4e462a8000)
libcups.so.2 => /lib64/libcups.so.2 (0x00007f4e4603f000)
libdrm.so.2 => /lib64/libdrm.so.2 (0x00007f4e45e2e000)
libdbus-1.so.3 => /lib64/libdbus-1.so.3 (0x00007f4e45bde000)
libexpat.so.1 => /lib64/libexpat.so.1 (0x00007f4e459b4000)
libxcb.so.1 => /lib64/libxcb.so.1 (0x00007f4e4578c000)
libxkbcommon.so.0 => /lib64/libxkbcommon.so.0 (0x00007f4e4554c000)
libm.so.6 => /lib64/libm.so.6 (0x00007f4e4524a000)
libX11.so.6 => /lib64/libX11.so.6 (0x00007f4e44f0c000)
libXcomposite.so.1 => /lib64/libXcomposite.so.1 (0x00007f4e44d09000)
libXdamage.so.1 => /lib64/libXdamage.so.1 (0x00007f4e44b06000)
libXext.so.6 => /lib64/libXext.so.6 (0x00007f4e448f4000)
libXfixes.so.3 => /lib64/libXfixes.so.3 (0x00007f4e446ee000)
libXrandr.so.2 => /lib64/libXrandr.so.2 (0x00007f4e444e3000)
libgbm.so.1 => /lib64/libgbm.so.1 (0x00007f4e442d5000)
libpango-1.0.so.0 => /lib64/libpango-1.0.so.0 (0x00007f4e4408f000)
libcairo.so.2 => /lib64/libcairo.so.2 (0x00007f4e43d58000)
libasound.so.2 => /lib64/libasound.so.2 (0x00007f4e43a58000)
libatspi.so.0 => /lib64/libatspi.so.0 (0x00007f4e43827000)
libxshmfence.so.1 => /lib64/libxshmfence.so.1 (0x00007f4e43624000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f4e4340e000)
libc.so.6 => /lib64/libc.so.6 (0x00007f4e43040000)
/lib64/ld-linux-x86-64.so.2 (0x00007f4e544cb000)
libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f4e42dde000)
libffi.so.6 => /lib64/libffi.so.6 (0x00007f4e42bd6000)
libplc4.so => /lib64/libplc4.so (0x00007f4e429d1000)
libplds4.so => /lib64/libplds4.so (0x00007f4e427cd000)
librt.so.1 => /lib64/librt.so.1 (0x00007f4e425c5000)
libgmodule-2.0.so.0 => /lib64/libgmodule-2.0.so.0 (0x00007f4e423c1000)
libz.so.1 => /lib64/libz.so.1 (0x00007f4e421ab000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f4e41f84000)
libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f4e41d6a000)
libmount.so.1 => /lib64/libmount.so.1 (0x00007f4e41b27000)
libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f4e418da000)
libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f4e415f1000)
libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f4e413be000)
libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f4e411ba000)
libssl.so.10 => /lib64/libssl.so.10 (0x00007f4e40f48000)
libcrypto.so.10 => /lib64/libcrypto.so.10 (0x00007f4e40ae5000)
libavahi-common.so.3 => /lib64/libavahi-common.so.3 (0x00007f4e408d8000)
libavahi-client.so.3 => /lib64/libavahi-client.so.3 (0x00007f4e406c7000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f4e40490000)
libsystemd.so.0 => /lib64/libsystemd.so.0 (0x00007f4e4025f000)
libXau.so.6 => /lib64/libXau.so.6 (0x00007f4e4005b000)
libXrender.so.1 => /lib64/libXrender.so.1 (0x00007f4e3fe50000)
libwayland-server.so.0 => /lib64/libwayland-server.so.0 (0x00007f4e3fc3d000)
libthai.so.0 => /lib64/libthai.so.0 (0x00007f4e3fa31000)
libfribidi.so.0 => /lib64/libfribidi.so.0 (0x00007f4e3f815000)
libpixman-1.so.0 => /lib64/libpixman-1.so.0 (0x00007f4e3f56c000)
libfontconfig.so.1 => /lib64/libfontconfig.so.1 (0x00007f4e3f32a000)
libfreetype.so.6 => /lib64/libfreetype.so.6 (0x00007f4e3f06b000)
libEGL.so.1 => /lib64/libEGL.so.1 (0x00007f4e3ee57000)
libpng15.so.15 => /lib64/libpng15.so.15 (0x00007f4e3ec2c000)
libxcb-shm.so.0 => /lib64/libxcb-shm.so.0 (0x00007f4e3ea28000)
libxcb-render.so.0 => /lib64/libxcb-render.so.0 (0x00007f4e3e81a000)
libGL.so.1 => /lib64/libGL.so.1 (0x00007f4e3e58e000)
libblkid.so.1 => /lib64/libblkid.so.1 (0x00007f4e3e34e000)
libuuid.so.1 => /lib64/libuuid.so.1 (0x00007f4e3e149000)
libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f4e3df39000)
libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f4e3dd35000)
libfreebl3.so => /lib64/libfreebl3.so (0x00007f4e3db32000)
libcap.so.2 => /lib64/libcap.so.2 (0x00007f4e3d92d000)
liblzma.so.5 => /lib64/liblzma.so.5 (0x00007f4e3d707000)
liblz4.so.1 => /lib64/liblz4.so.1 (0x00007f4e3d4f8000)
libgcrypt.so.11 => /lib64/libgcrypt.so.11 (0x00007f4e3d277000)
libgpg-error.so.0 => /lib64/libgpg-error.so.0 (0x00007f4e3d072000)
libdw.so.1 => /lib64/libdw.so.1 (0x00007f4e3ce21000)
libbz2.so.1 => /lib64/libbz2.so.1 (0x00007f4e3cc11000)
libGLdispatch.so.0 => /lib64/libGLdispatch.so.0 (0x00007f4e3c95b000)
libGLX.so.0 => /lib64/libGLX.so.0 (0x00007f4e3c729000)
libattr.so.1 => /lib64/libattr.so.1 (0x00007f4e3c524000)
libelf.so.1 => /lib64/libelf.so.1 (0x00007f4e3c30c000)

  这一步我安装完成之后,测试能否展示图片的时候,由于购买的云服务器配置太低,grafana调用chrome渲染的时候导致服务器负载太高,我就把chrome卸载了,但是测试的时候发现还能展示图片,负载也不高;感觉不需要安装chrome只需要用“ldd /var/lib/grafana/plugins/grafana-image-renderer/chrome-linux/chrome”检查一下把该装的依赖装了就可以用了,而我安装chrome时,歪打正着把依赖都装上了;

 

   最终效果:

  邮件效果图:

   只是图片中的中文是乱码;也无伤大雅了,就不解决了;



推荐阅读
author-avatar
胖儿的小金子
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有