add hostname label
This commit is contained in:
@@ -16,23 +16,20 @@ loki.source.file "system_logs" {
|
||||
forward_to = [loki.relabel.add_labels.receiver]
|
||||
}
|
||||
|
||||
// Add hostname as a label explicitly
|
||||
loki.process "add_hostname" {
|
||||
forward_to = [loki.relabel.add_labels.receiver]
|
||||
stage.static_labels {
|
||||
values = {
|
||||
hostname = env("HOSTNAME"), // Pulls from $HOSTNAME, defaults to "unknown-host"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add hostname and job labels
|
||||
// Relabel logs to add hostname and job labels
|
||||
loki.relabel "add_labels" {
|
||||
forward_to = [loki.write.loki.receiver]
|
||||
|
||||
rule {
|
||||
action = "replace"
|
||||
source_labels = ["__host__"]
|
||||
target_label = "hostname"
|
||||
}
|
||||
|
||||
rule {
|
||||
action = "replace"
|
||||
target_label = "job"
|
||||
replacement = "syslogs" // Or any name you prefer, e.g., "syslogs"
|
||||
replacement = "syslogs"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user