linux(centos8):prometheus使用mtail监控错误日志
一,mtail的用途?
说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest
对应的源码可以访问这里获取: https://github.com/liuhongdi/
说明:作者:刘宏缔 邮箱: 371125307@qq.com
二,下载mtail
https://github.com/google/mtail
[root@SearchCacheServer ~]# cd /usr/local/source/
[root@SearchCacheServer source]# mkdir mtail
[root@SearchCacheServer source]# cd mtail/
[root@SearchCacheServer mtail]# wget https://github.com/google/mtail/releases/download/v3.0.0-rc35/mtail_v3.0.0-rc35_linux_amd64
三,安装mtail
[root@SearchCacheServer mtail]# chmod 744 mtail_v3.0.0-rc35_linux_amd64
[root@SearchCacheServer mtail]# mkdir /usr/local/soft/mtail_v3.0.0-rc35_linux_amd64
[root@SearchCacheServer mtail]# mv mtail_v3.0.0-rc35_linux_amd64 /usr/local/soft/mtail_v3.0.0-rc35_linux_amd64/mtail
[root@SearchCacheServer mtail]# /usr/local/soft/mtail_v3.0.0-rc35_linux_amd64/mtail --version
mtail version v3.0.0-rc35 git revision a33283598c4b7a70fc2f113680318f29d5826cca go version go1.14 go arch amd64 go os linux
四,运行mtail
[root@SearchCacheServer phplogs]# mkdir -p /data/mtail/prog
[root@SearchCacheServer phplogs]# cd /data/mtail/prog/
[root@SearchCacheServer prog]# vi error_count.mtail
counter error_count
/ERROR/ {
error_count++
}
说明:error_count变量值统计了包含ERROR字串的行
https://github.com/google/mtail/tree/master/examples
[root@SearchCacheServer prog]# nohup /usr/local/soft/mtail_v3.0.0-rc35_linux_amd64/mtail -logtostderr -progs /data/mtail/prog/error_count.mtail -logs /data/logs/phplogs/prd_mobile_php_errors.log &
[root@SearchCacheServer prog]# ss -lntp | grep mtail
LISTEN 0 128 *:3903 *:* users:(("mtail",27642,11))
http://121.122.123.118:3903/
http://121.122.123.118:3903/metrics
五,配置prometheus
[root@blog ~]# cd /usr/local/soft/prometheus-2.18.1.linux-amd64/
[root@blog prometheus-2.18.1.linux-amd64]# vi prometheus.yml
- job_name: '118mtail'
static_configs:
- targets: ['121.122.123.118:3903']
[root@blog prometheus-2.18.1.linux-amd64]# systemctl restart prometheus.service
http://121.122.123.47:9090/graph

六,增加对alertmanager报警的配置
[root@blog rules]# pwd
/data/prometheus/rules
[root@blog rules]# vi rule.yml
- alert: ErrorlogStatus # alert 名字
expr: error_count{job="118mtail"} > 0 # 判断条件
for: 10s # 条件保持 10s 才会发出 alter
labels: # 设置 alert 的标签
severity: "critical"
annotations: # alert 的其他标签,但不用于标识 alert
description: php log error more than 20s
summary: php have error
说明:error_count>0是触发报警的条件
[root@blog prometheus-2.18.1.linux-amd64]# ./promtool check config prometheus.yml
Checking prometheus.yml
SUCCESS: 1 rule files found Checking /data/prometheus/rules/rule.yml
SUCCESS: 2 rules found
[root@blog prometheus-2.18.1.linux-amd64]# ./promtool check rules /data/prometheus/rules/rule.yml
Checking /data/prometheus/rules/rule.yml
SUCCESS: 2 rules found
[root@blog rules]# systemctl restart prometheus.service
https://www.cnblogs.com/architectforest/p/13065262.html
七,查看prometheus的版本
[root@blog ~]# /usr/local/soft/prometheus-2.18.1.linux-amd64/prometheus --version
prometheus, version 2.18.1 (branch: HEAD, revision: ecee9c8abfd118f139014cb1b174b08db3f342cf)
build user: root@2117a9e64a7e
build date: 20200507-16:51:47
go version: go1.14.2
八,查看linux的版本
[root@blog ~]# cat /etc/redhat-release
CentOS Linux release 8.0.1905 (Core)
linux(centos8):prometheus使用mtail监控错误日志的更多相关文章
- MS SQL 监控错误日志的告警信息
SQL Server的错误消息(Error Message)按照消息的严重级别一共划分25个等级,级别越高,表示严重性也越高.但是如果你统计sys.messages,你会发现,实际上只有16(SQL ...
- 2. SQL Server数据库状态监控 - 错误日志
原文:2. SQL Server数据库状态监控 - 错误日志 无论是操作系统 (Unix 或者Windows),还是应用程序 (Web 服务,数据库系统等等) ,通常都有自身的日志机制,以便故障时追溯 ...
- linux(centos8):zabbix配置邮件报警(监控错误日志)(zabbix5.0)
一,zabbix5.0发邮件报警的准备工作: zabbix5.0在linux平台上的安装:参见这一篇: https://www.cnblogs.com/architectforest/p/129125 ...
- linux(centos8):prometheus使用alertmanager发送报警邮件(prometheus 2.18.1/alertmanager 0.20.0)
一,alertmanager的用途 1,Alertmanager的作用: Alertmanager是一个独立的报警模块, 它接收Prometheus等客户端发来的警报,并通过分组.删除重复等处理, 通 ...
- Python自动监控错误日志
平时在查看日志的时候打开满屏的日志,看上去有点凌乱.于是写个Python脚本过滤出想要看的错误的日志.直接上脚本 脚本示例 def read_log(logname,keyword): tell = ...
- mtail 提取应用日志数据到时序数据库的工具-支持prometheus
mtail 是谷歌开源的一款很不错的应用日志提取工具,我们可以方便的用来提取应用的数据 到常见的监控系统(prometheus,stats,collectd,gragphite....) 说明: de ...
- 记-Windows环境下Prometheus+alertmanager+windows_exporter+mtail监控部署
1.概述 最近因项目需要统计服务的负载情况及机器的负载情况,但是项目里面却没有相关统计而服务所在的机器也没有相关的监控,因为工期原因就选择了相对轻量级的prometheus方案.其中windows_e ...
- 在Linux系统上查看Apache服务器的错误日志
错误日志和访问日志文件为系统管理员提供了有用的信息,比如,为 Web 服务器排障,保护系统不受各种各样的恶意活动侵犯,或者只是进行各种各样的分析以监控 HTTP 服务器.根据你 Web 服务器配置的不 ...
- Grafana+Prometheus通过node_exporter监控Linux服务器信息
Grafana+Prometheus通过node_exporter监控Linux服务器信息 一.Grafana+Prometheus通过node_exporter监控Linux服务器信息 1.1nod ...
随机推荐
- %s 表示格式化一个对象为字符
比如: name=“good” print('%s'%name)会打印出good print('%3s'%name) 会打印出good,当%和s之间的数字,小于字符串长度时,实际打印出字符串的长度 ...
- jmeter进行MySQL压测
jmeter怎么对数据库进行压测 目录 jmeter怎么对数据库进行压测 点击测试计划,再点击"浏览",把JDBC驱动添加进来: 然后添加配置元件 再添加一个采样器:JDBC re ...
- 测试软件—禅道BUG管理工具
入禅 目录 入禅 1.禅道的基本使用 1.禅道的基本使用 admin(管理员) 部门:创建部门(需求部门,开发部门,测试部门,项目部门,产品部门) 组织:创建用户(产品经理,项目经理,开发人员,测试人 ...
- Bootstrap学习第一天
听说bootstrap很火,页面做的非常好看,今天我决定开始学习bootstrap. bootstrap是一种响应式前端技术,可以用于构建适应多种设备的网站页面,当页面尺寸变化时会根据变化的尺寸适应设 ...
- 必应API接口nodejs版
近期,在研究百度.必应.API等的url提交API时,发现有用Go语言做工具的大佬的分享 利用 API 自动向搜索引擎提交网址(Go语言版) - pyList. 其中提到bing API提交方法,并给 ...
- IHttpClientFactory组件使用
起因 :由于需要前段时间写了一个http请求的公共方法 使用的 HttpClient,但是在jmeter测试下 爆发了这个问题:“Cannot assign requested address Ca ...
- Java并发包之Executors
概述 Executor.ExecutorService.ScheduledExecutorService.ThreadFactory.Callable的工厂和工具类. 方法 构造一个固定线程数目的线程 ...
- Socket 核心原理分享
Socket 的个人故事.希望通过这篇文章让你弄懂什么是 Socket,明白 TCP 和 UDP 协议的通讯,明白长连接和短连接的优缺点,明白 BIO.NIO.AIO的区别. Socket 大家好,我 ...
- Oracle学习(四)SQL高级--表优化相关(序列、视图等)
INDEX(索引) 可以在表中创建索引,以便更加快速高效地查询数据. 用户无法看到索引,它们只能被用来加速搜索/查询. PS:更新一个包含索引的表需要比更新一个没有索引的表花费更多的时间,这是由于索引 ...
- 使用jpa时,实体类有不存在数据库中的字段
使用jpa时,实体类有不存在数据库中的字段.在改属性上面加上这个注解@Transient就可以解决问题.