From 9290a5d228fef7bf4edd29a34b03e29e9d2942d3 Mon Sep 17 00:00:00 2001 From: Cyril Tovena <cyril.tovena@gmail.com> Date: Tue, 7 May 2019 11:10:11 -0400 Subject: [PATCH] rename __filename__ label to filename --- docs/promtail.md | 3 ++- pkg/promtail/promtail_test.go | 4 ++-- pkg/promtail/targets/filetarget.go | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/promtail.md b/docs/promtail.md index ff8b3bc9..2b0e5dff 100644 --- a/docs/promtail.md +++ b/docs/promtail.md @@ -32,7 +32,8 @@ The term "label" here is used in more than one different way and they can be eas will have a label \_\_meta_kubernetes_pod_label_name with value set to "foobar". * There are other \_\_meta_kubernetes_* labels based on the Kubernetes metadadata, such as the namespace the pod is running (\_\_meta_kubernetes_namespace) or the name of the container inside the pod (\_\_meta_kubernetes_pod_container_name) -* The label \_\_path\_\_ is a special label which Promtail will read to find out where the log files are to be read in. +* The label \_\_path\_\_ is a special label which Promtail will read to find out where the log files are to be read in, + it will be translated into a label named `filename` to ensure uniqueness of the streams. The most important part of each entry is the *relabel_configs* which are a list of operations which creates, renames, modifies or alters labels. A single scrape_config can also reject logs by doing an "action: drop" if diff --git a/pkg/promtail/promtail_test.go b/pkg/promtail/promtail_test.go index 02cfa5c1..10d099a5 100644 --- a/pkg/promtail/promtail_test.go +++ b/pkg/promtail/promtail_test.go @@ -380,13 +380,13 @@ func (h *testServerHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } file := "" for _, label := range labels { - if label.Name == "__filename__" { + if label.Name == "filename" { file = label.Value continue } } if file == "" { - h.t.Error("Expected to find a label with name __filename__ but did not!") + h.t.Error("Expected to find a label with name `filename` but did not!") return } if _, ok := h.receivedMap[file]; ok { diff --git a/pkg/promtail/targets/filetarget.go b/pkg/promtail/targets/filetarget.go index 755e997d..0b0d19cf 100644 --- a/pkg/promtail/targets/filetarget.go +++ b/pkg/promtail/targets/filetarget.go @@ -46,7 +46,7 @@ var ( ) const ( - filenameLabel = "__filename__" + filenameLabel = "filename" ) // Config describes behavior for Target -- GitLab