add hostname label
This commit is contained in:
@@ -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
|
// Add hostname and job labels
|
||||||
loki.relabel "add_labels" {
|
loki.relabel "add_labels" {
|
||||||
forward_to = [loki.write.loki.receiver]
|
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 {
|
rule {
|
||||||
action = "replace"
|
action = "replace"
|
||||||
target_label = "job"
|
target_label = "job"
|
||||||
|
|||||||
Reference in New Issue
Block a user