English | 中文
plugins: #插件配置
metrics: #引用metrics
prometheus: #启动prometheus
ip: 0.0.0.0 #prometheus绑定地址
port: 8090 #prometheus绑定端口
path: /metrics #metrics路径
namespace: Development #命名空间
subsystem: trpc #子系统
rawmode: false #原始模式,不会对metrics的特殊字符进行转换
enablepush: true #启用push模式,默认不启用
gateway: http://localhost:9091 #prometheus gateway地址
password: username:MyPassword #设置账号密码, 以冒号分割
job: job #job名称
pushinterval: 1 #push间隔,默认1s上报一次
在main.go中引用,并在yaml中配置好参数
import _ "trpc.group/trpc-go/trpc-metrics-prometheus"
trpc metrics 使用指引 trpc metrics
本地通过curl查询指标,查看指标是否生成成功
curl ${ip}:${port}/$path |grep ${namespace}_${subsystem}
增加配置
filter:
- prometheus #增加prometheus filter
调用数据目前支持请求耗时的Histogram和请求量的SUM两个指标 指标名前缀为ClientFilter与ServerFilter
- prometheus目前只支持PolicySUM/PolicySET/PolicyHistogram类型上报,其它类型支持请提pr
- prometheus指标不支持中文与特殊字符,非法字符将会自动转换,acsii表内的非法字符转换为'',中文等utf8字符转换为对应的数据,比如"trpc.中文指标"->"trpc_20013_25991_25351_26631",关闭此功能可以使用设置rawmode为true,异常上报将直接失败
- 插件只提供exporter,不提供平台与对接
- 多维度上报使用 metrics.NewMultiDimensionMetricsX 接口设置多维度名,否则可能会出现冲突
- 如果需要推送自定义数据,可以在插件初始化完之后调用GetDefaultPusher方法,否则返回的pusher为空