English | 中文
plugins: #Plugin configuration.
metrics: #Reference metrics.
prometheus: #Start prometheus.
ip: 0.0.0.0 #Prometheus bind address.
port: 8090 #Prometheus bind port.
path: /metrics #Metrics path.
namespace: Development #Namespace.
subsystem: trpc #Subsystem.
rawmode: false #Raw mode, no conversion of special characters for metrics.
enablepush: true #Enable push mode, not enabled by default.
gateway: http://localhost:9091 #Prometheus gateway address.
password: username:MyPassword #Set the account password, username and MyPassword are split by a colon.
job: job #Job name.
pushinterval: 1 #Push data every 1 second by default
Reference it in main.go and configure the parameters in yaml.
import _ "trpc.group/trpc-go/trpc-metrics-prometheus"
trpc metrics usage guidelines trpc metrics
Query the metrics locally via curl to see if the metrics were generated successfully.
curl ${ip}:${port}/$path |grep ${namespace}_${subsystem}
Add configuration
filter:
- prometheus #Add prometheus filter
The call data currently supports both Histogram for request time and SUM for request volume. The metric names are prefixed with ClientFilter and ServerFilter.
- Prometheus currently only supports PolicySUM/PolicySET/PolicyHistogram type reporting, other types of support please submit pr.
- Prometheus metric does not support Chinese and special characters, illegal characters will be automatically converted to '' in the acsii table, Chinese and other utf8 characters are converted to the corresponding data, such as "trpc.Chinese metric" -> "trpc_20013_25991_25351_26631", close this function can be used to set rawmode is true, exception reporting will fail directly.
- The plugin only provides exporter, not Pushgateway and Prometheus server.
- Multi-dimension reporting uses the metrics.NewMultiDimensionMetricsX interface to set multi-dimension names, otherwise conflicts may occur.
- If you need to push custom data, you can call the GetDefaultPusher method after the plugin is initialized, otherwise the returned pusher is empty.