add hostname label

This commit is contained in:
Arne Teuke
2025-03-11 12:24:46 +01:00
parent c4654a9259
commit 1c7c40b759

View File

@@ -26,18 +26,19 @@ loki.process "add_hostname" {
}
}
// Add hostname using system.hostname
loki.process "add_hostname" {
forward_to = [loki.relabel.add_labels.receiver]
stage.static_labels {
values = {
hostname = system.hostname, // Grabs the local hostname (e.g., fm002)
}
}
}
// Add hostname and job labels
loki.relabel "add_labels" {
forward_to = [loki.write.loki.receiver]
rule {
source_labels = ["__host__"] // Internal hostname from constants.hostname
target_label = "hostname"
}
rule {
action = "replace"
target_label = "hostname"
replacement = "$HOSTNAME"
}
rule {
action = "replace"
target_label = "job"