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 人赞同 ...
随机推荐
- [福建集训2011][LOJ10111]相框
这题主要还是分类讨论欧拉回路 首先对于导线一端没有东西的新建一个节点 由于原图不一定连通所以需要用到并查集判断有多少个连通块 将一条导线连接的两个焊点连接 然后先对于只有一个连通块考虑 1.如果一个焊 ...
- 通过RequestContextHolder直接获取HttpServletRequest对象
问题 朋友遇到一个问题:他想在Service方法中使用HttpServletRequest的API,但是又不想把HttpServletRequest对象当作这个Service方法的参数传过来,原因是这 ...
- Python自学:第三章 在列表末尾添加元素与在列表中插入元素
motorcycles = ['honda', 'yamaha' ,'suzuki'] motorcycles.insert(0, "ducati") print(motorcyc ...
- 【分布式搜索引擎】Elasticsearch分布式架构原理
一.相关概念介绍 1)集群(cluster) 一个集群(cluster)由一个或多个节点组成. 这些节点具有相同的cluster.name,它们协同工作,分享数据和负载.当加入新的节点或者删除一个节点 ...
- dedecmsv5.7 前台模版里输出变量
如何在PHP文件查询出来的数据赋值给前端页面展示出来? 例如: PHP文件:agency.php require_once(dirname(__FILE__) . '/../../include/co ...
- day048 BOM和DOM
BOM Browser Object Model(文档对象模型) > window对象 1.alert 弹出带有提示和一个确认按钮的警示框 2.confirm 弹出带有一 ...
- 构建工具build tools
构建工具是从源代码自动创建可执行应用程序的程序(例如.apk for android app).构建包括将代码编译,链接和打包成可用或可执行的形式. 基本上,构建自动化是脚本或自动化软件开发人员在日常 ...
- Cassandra集群:一,搭建一个三节点的集群
环境准备 JDK1.8 http://download.oracle.com/otn/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8 ...
- Javascript时间戳和日期时间的相互转换
跟后台对接的时候经常碰到时间格式的问题,有时返回的是时间戳,有时返回的是具体时间,需求又需要它们之间的转换,所以干脆把之前遇到过的情况都给记录下来,以供自己参考! 本文备注:(时间戳单位为毫秒ms,换 ...
- Lucene全文检索入门使用
一. 什么是全文检索 全文检索是计算机程序通过扫描文章中的每一个词,对每一个词建立一个索引,指明该词在文章中出现的次数和位置.当用户查询时根据建立的索引查找,类似于通过字典的检索字表查字的过程 全文检 ...