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 人赞同 ...
随机推荐
- C# 虹软离线SDK引擎 人脸识别
一,背景 整体来说虹软的人脸识别SDK还是不错的.我们测试过Face++的,百度的,腾讯的,都是在线联网的,需要把上传数据到它们服务器,不利商业用途:虹软SDK支持离线. 二,下载虹软SDK 1.注册 ...
- opencv的resize和matlab的imresize函数的计算
在用c++代码复现matlab代码时,遇到两者resize函数的结果不相同的问题. opencv: resize(image1, reTmp, Size(, ), , , cv::INTER_LINE ...
- 【Mysql】Mysql Json类型或Text类型可以建索引吗?
一.JSON类型 答案是不可以 为Json类型建索引会报错 mysql)); ERROR (): JSON column 'card_pay_data' cannot be used in key s ...
- DFS 之 全排列
题目描述输出自然数1到n所有不重复的排列,即n的全排列,要求所产生的任一数字序列中不允许出现重复的数字. 我们可以模拟出n个盒子和n张卡片,我们需要将n张卡片分别放到n个盒子里,且每个盒子只能放1张卡 ...
- python----常用模块(hashlib加密,Base64,json)
一.hashlib模块 1.1 hashlib模块,主要用于加密相关的操作,在python3的版本里,代替了md5和sha模块,主要提供 SHA1, SHA224, SHA256, SHA384, S ...
- anguar6中 无法在Element上找到属性 (eg 原DOM的offsetTop)
let aa=this.elementRef.nativeElement.querySelector('.logBox') ;
- analyse web.xml of hello1
web.xml注释分析: 补充: 一.XML文档的xmlns.xmlns:xsi和xsi:schemaLocation (参考博客:https://www.cnblogs.com/osttwz/p/6 ...
- gcc4.9.1新特性
C family Support for colorizing diagnostics emitted by GCC has been added. The -fdiagnostics-color=a ...
- learning makefile = and :=
- JS的防抖和节流
数个月之前,在一次前端的性能优化中,接触到了JS中防抖和节流,一开始还不明白他们的应用在哪里,可后来才知道,这是前端中最基础的性能优化,在绑定 scroll .resize 这类事件时,当它发生时,它 ...