使用grok exporter 做为log 与prometheus 的桥
grok 是一个工具,可以用来解析非结构化的日志文件,可以使其结构化,同时方便查询,grok 被logstash 大量依赖
同时社区也提供了一个prometheus 的exporter 可以方便的进行log 指标,暴露为promethesu 的标准数据格式,当
然谷歌的mtail 也是一个不错的选择,同时性能很不错,扩展也很方便(提供了自己的处理语言),对于比较熟悉
logstash 的同学grok 是一个很不错的选择。
以下演示一个简单的基于grok exporter的log 统计分析功能
环境准备
- docker-compose 文件
version: "3.7"
services:
grafana:
image: grafana/grafana
ports:
- "3000:3000"
prometheus:
image: prom/prometheus
volumes:
- "./prometheus.yml:/etc/prometheus/prometheus.yml"
ports:
- "9090:9090"
grok:
image: dalongrong/grok-exporter
volumes:
- "./example:/opt/example"
- "./grok.yaml:/grok/config.yml"
ports:
- "9144:9144"
- grok 配置文件说明
global:
config_version: 2
input:
type: file
path: /opt/example/examples.log
readall: true
grok:
patterns_dir: ./patterns
metrics:
- type: counter
name: grok_example_lines_total
help: Counter metric example with labels.
match: '%{DATE} %{TIME} %{USER:user} %{NUMBER}'
labels:
user: '{{.user}}'
server:
port: 9144
- promethesu 静态配置文件
scrape_configs:
- job_name: grok
metrics_path: /metrics
scrape_interval: 10s
scrape_timeout: 10s
static_configs:
- targets: ['grok:9144']
- log 日志文件格式
30.07.2016 14:37:03 alice 1.5
30.07.2016 14:37:33 alice 2.5
30.07.2016 14:43:02 bob 2.5
30.07.2016 14:45:59 alice 2.5
30.07.2016 14:46:59 dalong 2.5
30.07.2016 14:47:59 dalong 2.5
30.07.2016 14:48:59 dalong 2.5
启动&&测试
- 启动
docker-compose up -d
- 配置grafana
打开http://localhost:3000 按照提示操作即可 - prometheus metrics 查看

- prometheus web console

- grafana 图表

说明
当前支持的metrics 有计数,仪表板,直方图,摘要,是一个不错的工具,作者当前也在开发支持多日志文件的处理
参考资料
https://github.com/fstab/grok_exporter
https://github.com/google/mtail
https://github.com/rongfengliang/grok-exporter-docker-compose
使用grok exporter 做为log 与prometheus 的桥的更多相关文章
- cratedb 做为prometheus 的后端存储
prometheus 提供了remote_write 以及remote_read 的数据存储方式,可以帮助我们进行数据的长时间存储.方便查询 cratedb 提供了对应的adapter,可以直接进行适 ...
- [转帖]prometheus数据采集exporter全家桶
prometheus数据采集exporter全家桶 Rainbowhhy1人评论2731人阅读2019-04-06 15:38:32 https://blog.51cto.com/13053917/2 ...
- Prometheus 使用之 node exporter
本文使用的 Prometheus 版本为 2.22.0,node exporter 版本为 1.0.1:部署在 Linux 服务器Prometheus 是开源的监控报警系统和时序列数据库 (TSDB) ...
- prometheus(1)之核心概念
个人理解:prometheus核心在于 1.prom数据类型的理解 (4钟数据类型 与常用的promQL语法 其实很容易) 2.各种服务发现与正则拼接(服务发现的拼接其实官方定义好的 理解就行) 3. ...
- 1. 初探--prometheus调研
一.基本概念 Prometheus 是由前 Google 工程师从 2012 年开始在 Soundcloud 以开源软件的形式进行研发的系统监控和告警工具包,自此以后,许多公司和组织都采用了 Prom ...
- Prometheus安装部署说明
本文主要介绍了如何二进制安装Prometheus.使用 Node Exporter 采集主机信息并使用Grafana来进行图形化的展示. 1. 安装Prometheus Server Promethe ...
- DevOps-ISC,CSS,Prometheus,Ansible ,Terraform,zabbix
https://www.terraform.io/ Terraform Use Infrastructure as Code to provision and manage any cloud, in ...
- 实战 Prometheus 搭建监控系统
实战 Prometheus 搭建监控系统 Prometheus 是一款基于时序数据库的开源监控告警系统,说起 Prometheus 则不得不提 SoundCloud,这是一个在线音乐分享的平台,类似于 ...
- 01 . Prometheus简介及安装配置Grafana
Promethus简介 Prometheus受启发于Google的Brogmon监控系统(相似的Kubernetes是从Google的Brog系统演变而来),从2012年开始由前Google工程师在S ...
随机推荐
- opencv imshow plt imshow
opencv官方文档上写的,https://docs.opencv.org/master/dc/d2e/tutorial_py_image_display.html Color image loade ...
- GoldenDict(for Linux)配置无道词典
引言 我原来写过一篇博客:(离线)英语词典软件推荐,个人比较喜欢的就是GoldenDict词典.不仅仅是因为它是免费开源的多平台程序,更重要的是支持丰富的原版词典(下文给出了下载链接).本文主要针对其 ...
- Stopwatch 类用于计算程序运行时间
Stopwatch 类 命名空间:System.Diagnostics.Stopwatch 实例化:Stopwatch getTime=new Stopwatch(); 开始计时:getTime.St ...
- Mysql中的排序查询
进阶3:排序查询 语法: select 查询列表 from 表 [where 筛选条件]order by 排序列表 [asc 升序 | desc降序] 例子 查询员工信息,要求工资从高到低 SELEC ...
- asp.net core web的导入导出excel功能
这里主要记录下asp.net core web页面上进行导入导出excel的操作. 主要是导入,因为现在使用的很多前端框架(例如kendo ui)本身就有导出的功能. 这里使用到EPPlus.Core ...
- C#读写修改设置调整UVC摄像头画面-伽玛
有时,我们需要在C#代码中对摄像头的伽玛进行读和写,并立即生效.如何实现呢? 建立基于SharpCamera的项目 首先,请根据之前的一篇博文 点击这里 中的说明,建立基于SharpCamera的摄像 ...
- 计数计量单位KMGTPEZY【计算机】【天文】
· Bit = Binary Digit · Bits = · s = Kilo · Kilo s = Mega · Mega s = Giga · Giga s = Tera · Tera s = ...
- Tigase XMPP Server
Tigase XMPP Server是我们的旗舰服务器端软件,提供XMPP服务或实例通信(IC)服务.最基本的解释是Tigase是一个聊天服务器,但它远不止于此.聊天是其可能的应用程序之一,但任何类型 ...
- Content-Type属性的取值和作用
1.Content-Type 的值类型: 1.1 application/json:消息主体是序列化后的 JSON 字符串 1.2 application/x-www-form-urlencoded: ...
- psexec与wmi在内网渗透的使用
psexec是一个很好的管理工具,在内网渗透中也被广泛使用. 但太“出名”也往往会遭来各种麻烦. 在有安全监听.防护的内网中使用psexec会容易触发告警. 1.psexec用法(前提:对方要开启ad ...