Sentinel icon indicating copy to clipboard operation
Sentinel copied to clipboard

Use a fixed metric name for sentinel prometheus exporter

Open flearc opened this issue 1 year ago • 1 comments

Issue Description

Type: Enhancement

I have followed this README to set up sentinel prometheus exporter. However, I've observed that the metric name is currently tied to the appName, which is typically the JAR's name or specified by the VM option csp.sentinel.prometheus.app. The logic can be found at SentinelCollector.java#L83.

Querying metrics using appName in PromQL seems unconventional and inconvenient. In scenarios where multiple services enable the Prometheus exporter feature, prometheus will receive numerous distinct metrics that essentially convey the same information.

I propose using a fixed metric name and introducing an additional label (app_name) representing the appName.

Desired Feature

I would like the Prometheus exporter to provide a fixed metric name and an extra label (app_name). This would enable querying with a consistent PromQL expression like sentinel_metric_log{app_name="xx", resource="xxx", type="xxx"}. With this enhancement, every service can be queried using the same PromQL, requiring only the label's value to be adjusted.

flearc avatar Jan 30 '24 09:01 flearc

PTAL @sczyh30

flearc avatar Feb 05 '24 02:02 flearc