goaccess 通过jsonpath 转换为prometheus metrics
goaccess 是一个不错的日志分析工具,包含了json 数据同时支持基于websocket 的实时数据处理,当然我们可以通过jsonpath
的exporter 转换为支持promethues 的metrics,还是很方便的
环境准备
- docker-compose 文件
version: "3"
services:
metrics:
image: sunbird/prometheus-jsonpath-exporter
volumes:
- "./conf/config.yml:/etc/prometheus-jsonpath-exporter/config.yml"
ports:
- "9158:9158"
command: /etc/prometheus-jsonpath-exporter/config.yml
g:
image: grafana/grafana
ports:
- "3000:3000"
p:
image: prom/prometheus
volumes:
- "./conf/prometheus.yml:/etc/prometheus/prometheus.yml"
ports:
- "9090:9090"
log:
image: dalongrong/goaccess-geo
ports:
- "7890:7890"
volumes:
- "./data:/srv/data"
- "./logs:/srv/logs"
- "./html:/srv/report"
- "./geoip/:/src/geoip/"
web:
image: nginx
ports:
- "8080:80"
volumes:
- "./html/:/usr/share/nginx/html/"
- prometheus 配置
conf/prometheus.yml
scrape_configs:
- job_name: go_access
metrics_path: /
static_configs:
- targets: ['metrics:9158']
- jsonpath exporter 配置
conf/config.yml
exporter_port: 9158 # Port on which prometheus can call this exporter to get metrics
log_level: info
json_data_url: http://web/app.json # Url to get json data used for fetching metric values
metric_name_prefix: go_access # All metric names will be prefixed with this value
metrics:
- name: total_request # Final metric name will be go_access_total_request
description: Number of total request
path: $.general.total_requests
- goaccess 配置
主要是添加支持json 的处理data/goaccess.conf
geoip-database /src/geoip/GeoLiteCity.dat
log-format COMBINED
real-time-html true
log-file /srv/logs/access.log
output /srv/report/index.html
output /srv/report/app.json
- 说明
metrics 很简单,就是通过jsonpath 获取请求的总数
运行&&测试
- 启动
docker-compose up -d
- 效果
goaccess
jsonpath exporter metrics
prometheus
说明
这个只是一种简单的处理实际上我们可以基于其他的nginx 或者logger exporter 进行prometheus metrics 的处理,对于需要进行离线日志请求分析的,
也是一种不错的方案,需要的操作比较少,但是可以帮助我们分析好多有用的信息
参考资料
https://github.com/project-sunbird/prometheus-jsonpath-exporter
https://github.com/rongfengliang/goaccess-geoip-docker-compose-demo
https://goaccess.io/
https://goessner.net/articles/JsonPath/index.html#e2
goaccess 通过jsonpath 转换为prometheus metrics的更多相关文章
- 使用haproxy 2.0 prometheus metrics 监控系统状态
haproxy 2.0 已经发布一段时间了,提供内部直接暴露的prometheus metrics 很方便 ,可以快速的监控系统的状态 以下是一个简单的demo 环境准备 docker-compose ...
- Prometheus Metrics 设计的最佳实践和应用实例,看这篇够了!
Prometheus 是一个开源的监控解决方案,部署简单易使用,难点在于如何设计符合特定需求的 Metrics 去全面高效地反映系统实时状态,以助力故障问题的发现与定位.本文即基于最佳实践的 Metr ...
- 使用golang编写prometheus metrics exporter
metrcis输出 collector.go package main import ( "github.com/prometheus/client_golang/prometheus&qu ...
- 编写一个简单的基于jmespath 的prometheus exporter
目的很简单,因为系统好多监控指标是通过json 暴露的,并不是标准的prometheus metrics 格式,处理方法 实际上很简单,我们可以基于jsonpath 解析json数据,转换为prome ...
- 手把手教你使用 Prometheus 监控 JVM
概述 当你的 Java 业务容器化上 K8S 后,如果对其进行监控呢?Prometheus 社区开发了 JMX Exporter 来导出 JVM 的监控指标,以便使用 Prometheus 来采集监控 ...
- 使用JMX Exporter监控Rainbond上的Java应用
场景 Prometheus 社区开发了 JMX Exporter 用于导出 JVM 的监控指标,以便使用 Prometheus 来采集监控数据.当您的 Java 应用部署在Rainbond上后 可通过 ...
- 自定义Metrics:让Prometheus监控你的应用程序
前言 Prometheus社区提供了大量的官方以及第三方Exporters,可以满足Prometheus的采纳者快速实现对关键业务,以及基础设施的监控需求. 如上所示,一个简单的应用以及环境架构.一般 ...
- 关于Prometheus监控的思考:多标签埋点及Mbean
使用 grafana+prometheus+jmx 作为普通的监控手段,是比较有用的.我之前的文章介绍了相应的实现办法. 但是,按照之前的实现,我们更多的只能是监控 单值型的数据,如请求量,tps 等 ...
- 《为什么说 Prometheus 是足以取代 Zabbix 的监控神器?》
为什么说 Prometheus 是足以取代 Zabbix 的监控神器? Kuberneteschina 致力于提供最权威的 Kubernetes 技术.案例与Meetup! 关注他 12 人赞同 ...
随机推荐
- 腾讯云服务器突然远程连不上(包含ssh,拒绝访问)
版权声明:本文转载自 https://blog.csdn.net/Alexwu555/article/details/78448113, 暂时这样 , 以后再来整理.不太习惯不能直接贴截图啊 配置安 ...
- 第 8 章 容器网络 - 070 - 如何定制 Calico 网络 Policy?
定制 Calico 网络 Policy Calico 默认的 policy 规则是:容器只能与同一个 calico 网络中的容器通信. Calico 能够让用户定义灵活的 policy 规则,精细化控 ...
- RNA velocity | RNA速率
单细胞转录组确实是利器,但我们大多只利用了表达的信息,而从reads到表达之间的信息完全被我们忽略了. 最近nature发了一篇单细胞方法类文章,讲得就是如何利用RNA velocity来做细胞发育路 ...
- vscode ----> 学习笔记
java开发环境 jdk配置 maven配置 file --> preferences --> settings 在search settings搜索关键词 java.home , mav ...
- 安卓下设置系统字体大小影响H5页面布局
问题描述: 调整好的h5页面,放在安卓app内嵌页面后布局正常,后来用户调整系统里面字体大小,后内嵌H5布局乱掉 问题分析: 因为用户调整了系统字体的大小,修改了根节点和body节点的font-siz ...
- django之ModelForm的用法
概述: ModelForm类是form是组件中Form的一个子类,所以,也是处理表单的,但功能要比Form类强大,而且使用方便. 步骤: 1.自定义一个类,继承ModelForm from djang ...
- "她等待刀尖已经太久"--茨维塔耶娃诗抄
生活 1 你无法夺走我的红晕—— 它强大——如同河水的汛潮! 你是猎人,可我不会上当, 你若追逐,我就会逃跑. 你无法夺走我鲜活的灵魂! 就这样,在急遽的追逐中—— 一匹阿拉伯的骏马, 微 ...
- Descriptors;Hello1 project中的Web.xml
Deployment Descriptors(描述符)是一个xml文件,用来描述如何部署一个模块或者应用(根据描述符中定义的配置和容器选项).举例来说,一个EJB的部署描述符会向EJB容器传递如何管理 ...
- 监听图片src发生改变时的事件
$img.on('load', function() { $img.attr("src", getBase64Image($img.get(0))); $img.off('load ...
- linux如何让一个程序崩溃后自动重启
思路: 写一个脚本 监控程序的运行状态 没有运行启动运行 已运行不做操作. 如果在控制台启动脚本 注意必须 nohup sh xxx.sh & while true do ps -ef ...