From 48def27e1e42e33ace2eb87cb72efa55d37ededf Mon Sep 17 00:00:00 2001 From: Cyril Tovena Date: Wed, 8 May 2019 09:19:59 -0400 Subject: [PATCH] fix review feedback --- docs/promtail.md | 4 ++-- pkg/promtail/promtail_test.go | 3 ++- pkg/promtail/targets/filetarget.go | 2 +- pkg/promtail/targets/tailer.go | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/promtail.md b/docs/promtail.md index 2b0e5dffc0..93c6125960 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 10d099a57e..e2c23d9e79 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 0b0d19cf66..34236f1a93 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 115e38dc79..13a6566bad 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,