配置 OBI Prometheus 和 OpenTelemetry 指标直方图
配置 Prometheus 和 OpenTelemetry 的指标直方图,以及是否使用原生直方图和指数直方图。
您可以配置 OBI Prometheus 和 OpenTelemetry 的指标直方图。您还可以选择使用原生直方图和指数直方图。
覆盖直方图存储桶
通过设置 buckets YAML 配置选项,您可以覆盖 OpenTelemetry 和 Prometheus 指标导出器的直方图存储桶边界
YAML 部分:otel_metrics_export.buckets
例如
otel_metrics_export:
buckets:
duration_histogram: [0, 1, 2]
| YAML | 类型 |
|---|---|
duration_histogram | []float64 |
为与请求持续时间相关的指标设置存储桶边界。具体来说:
http.server.request.duration(OTel) /http_server_request_duration_seconds(Prometheus)http.client.request.duration(OTel) /http_client_request_duration_seconds(Prometheus)rpc.server.duration(OTel) /rpc_server_duration_seconds(Prometheus)rpc.client.duration(OTel) /rpc_client_duration_seconds(Prometheus)
如果未设置该值,OBI 将使用 OpenTelemetry 语义约定 中的默认存储桶边界
0, 0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10
YAML 部分:prometheus_export.buckets
prometheus_export:
buckets:
request_size_histogram: [0, 10, 20, 22]
response_size_histogram: [0, 10, 20, 22]
| YAML | 类型 |
|---|---|
request_size_histogram | []float64 |
response_size_histogram | []float64 |
为与请求和响应大小相关的指标设置存储桶边界
http.server.request.body.size(OTel) /http_server_request_body_size_bytes(Prometheus)http.client.request.body.size(OTel) /http_client_request_body_size_bytes(Prometheus)http.server.response.body.size(OTel) /http_server_response_body_size_bytes(Prometheus)http.client.response.body.size(OTel) /http_client_response_body_size_bytes(Prometheus)
如果未设置该值,OBI 将使用这些默认存储桶边界
0, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192
这些默认值是**不稳定的**,如果 Prometheus 或 OpenTelemetry 语义约定建议不同的存储桶边界,它们可能会发生变化。
使用原生直方图和指数直方图
对于 Prometheus,您可以通过 在 Prometheus collector 中启用 native-histograms 功能来启用 原生直方图。
对于 OpenTelemetry,您可以使用预定义直方图的 指数直方图,而不是手动定义存储桶。设置标准的 OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION 环境变量。有关更多信息,请参阅 OTel 指标导出器 部分的 histogram_aggregation 部分。