diff --git a/docs/promtail.md b/docs/promtail.md index 2b0e5dffc030779848bf7daf540dcf39ae953a21..93c61259607b7f92e6692cb20ec205688cdbba61 100644 --- a/docs/promtail.md +++ b/docs/promtail.md @@ -32,8 +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, - it will be translated into a label named `filename` to ensure uniqueness of the streams. +* 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 `filename` is added for every file found in \_\_path\_\_ to ensure uniqueness of the streams. It contains the absolute path of the file being tailed. 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 10d099a57e8a9af8a2a1da57710a33f927397c48..e2c23d9e79c353f20847f946b4416cac42187535 100644 --- a/pkg/promtail/promtail_test.go +++ b/pkg/promtail/promtail_test.go @@ -29,6 +29,7 @@ import ( "github.com/grafana/loki/pkg/promtail/api" "github.com/grafana/loki/pkg/promtail/config" "github.com/grafana/loki/pkg/promtail/scrape" + "github.com/grafana/loki/pkg/promtail/targets" ) const httpTestPort = 9080 @@ -380,7 +381,7 @@ func (h *testServerHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } file := "" for _, label := range labels { - if label.Name == "filename" { + if label.Name == targets.FilenameLabel { file = label.Value continue } diff --git a/pkg/promtail/targets/filetarget.go b/pkg/promtail/targets/filetarget.go index 0b0d19cf6668415ab80fab7a6ae605c272bab32e..34236f1a93c591f8813949cc80812dc83b0553e0 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 diff --git a/pkg/promtail/targets/tailer.go b/pkg/promtail/targets/tailer.go index 115e38dc795d8ef3c1039c12d0000042b2dad115..13a6566bada567eda9e44d7b3658a8ec567a6f02 100644 --- a/pkg/promtail/targets/tailer.go +++ b/pkg/promtail/targets/tailer.go @@ -51,7 +51,7 @@ func newTailer(logger log.Logger, handler api.EntryHandler, positions *positions tailer := &tailer{ logger: logger, - handler: api.AddLabelsMiddleware(model.LabelSet{filenameLabel: model.LabelValue(path)}).Wrap(handler), + handler: api.AddLabelsMiddleware(model.LabelSet{FilenameLabel: model.LabelValue(path)}).Wrap(handler), positions: positions, path: path,