Fix metric names: strip loki_process_custom_ prefix, drop internal labels

Alloy's stage.metrics prefixes all metric names with
loki_process_custom_. Add a relabel rule to strip the prefix so
dashboards can query clean names (flyio_nginx_http_requests_total
etc). Also drop component_id/component_path/filename labels.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Erich Blume 2026-02-08 09:50:07 -08:00
commit 176d38be68

View file

@ -110,10 +110,24 @@ prometheus.scrape "self" {
scrape_interval = "15s"
}
// Add instance label to all metrics
// Strip the "loki_process_custom_" prefix that Alloy adds to stage.metrics,
// then add instance label. This keeps dashboard queries clean.
prometheus.relabel "instance" {
forward_to = [prometheus.remote_write.prometheus.receiver]
rule {
source_labels = ["__name__"]
regex = "loki_process_custom_(.*)"
target_label = "__name__"
replacement = "$1"
}
// Drop internal labels added by the loki pipeline
rule {
regex = "component_id|component_path|filename"
action = "labeldrop"
}
rule {
target_label = "instance"
replacement = "flyio-proxy"