From 3606801b332fcd28eac881e09f353fc658151fa4 Mon Sep 17 00:00:00 2001 From: 3Xpl0it3r Date: Fri, 23 Apr 2021 09:54:16 +0800 Subject: [PATCH 1/4] fix the promtail-default-config download link in doc --- docs/sources/installation/local.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sources/installation/local.md b/docs/sources/installation/local.md index 8d37e710e6c50..91aa699ea63d5 100644 --- a/docs/sources/installation/local.md +++ b/docs/sources/installation/local.md @@ -17,7 +17,7 @@ In order to log events with Loki, you must download and install both Promtail an 5. In the command line, change directory (`cd` on most systems) to the directory with Loki and Promtail. Copy and paste the commands below into your command line to download generic configuration files: ``` wget https://raw.githubusercontent.com/grafana/loki/master/cmd/loki/loki-local-config.yaml -wget https://raw.githubusercontent.com/grafana/loki/master/cmd/promtail/promtail-local-config.yaml +wget https://raw.githubusercontent.com/grafana/loki/main/clients/cmd/promtail/promtail-local-config.yaml ``` 6. Enter the following command to start Loki: From 7caa3dcfec5b73a1231b906f02daf0847afb71eb Mon Sep 17 00:00:00 2001 From: 3Xpl0it3r Date: Tue, 11 May 2021 09:39:22 +0800 Subject: [PATCH 2/4] add debug information for extreacted in stage --- clients/pkg/logentry/stages/json.go | 2 ++ clients/pkg/logentry/stages/regex.go | 3 ++- clients/pkg/logentry/stages/replace.go | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/clients/pkg/logentry/stages/json.go b/clients/pkg/logentry/stages/json.go index c516ce5140e50..43c16d78e92da 100644 --- a/clients/pkg/logentry/stages/json.go +++ b/clients/pkg/logentry/stages/json.go @@ -1,6 +1,7 @@ package stages import ( + "fmt" "reflect" "time" @@ -163,6 +164,7 @@ func (j *jsonStage) Process(labels model.LabelSet, extracted map[string]interfac extracted[n] = string(jm) } } + level.Debug(j.logger).Log("msg", "extracted data debug in json stage", "extracted data", fmt.Sprintf("%v", extracted)) } diff --git a/clients/pkg/logentry/stages/regex.go b/clients/pkg/logentry/stages/regex.go index d91f89c841d64..32dfefb773496 100644 --- a/clients/pkg/logentry/stages/regex.go +++ b/clients/pkg/logentry/stages/regex.go @@ -1,6 +1,7 @@ package stages import ( + "fmt" "reflect" "regexp" "time" @@ -127,7 +128,7 @@ func (r *regexStage) Process(labels model.LabelSet, extracted map[string]interfa extracted[name] = match[i] } } - + level.Debug(r.logger).Log("msg", "extracted data debug in regex stage", "extracted data", fmt.Sprintf("%v", extracted)) } // Name implements Stage diff --git a/clients/pkg/logentry/stages/replace.go b/clients/pkg/logentry/stages/replace.go index cdd4833b1adeb..a8c58903eae90 100644 --- a/clients/pkg/logentry/stages/replace.go +++ b/clients/pkg/logentry/stages/replace.go @@ -2,6 +2,7 @@ package stages import ( "bytes" + "fmt" "reflect" "regexp" "text/template" @@ -160,6 +161,7 @@ func (r *replaceStage) Process(labels model.LabelSet, extracted map[string]inter } } } + level.Debug(r.logger).Log("msg", "extracted data debug in replace stage", "extracted data", fmt.Sprintf("%v", extracted)) } func (r *replaceStage) getReplacedEntry(matchAllIndex [][]int, input string, td map[string]string, templ *template.Template) (string, map[string]string, error) { From 4f1679516530b3aaa10a4acc4b71473d1ad607bb Mon Sep 17 00:00:00 2001 From: 3Xpl0it3r Date: Tue, 11 May 2021 22:31:28 +0800 Subject: [PATCH 3/4] add Debug variable --- clients/pkg/logentry/stages/json.go | 5 +++-- clients/pkg/logentry/stages/regex.go | 4 +++- clients/pkg/logentry/stages/replace.go | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/clients/pkg/logentry/stages/json.go b/clients/pkg/logentry/stages/json.go index 43c16d78e92da..74094bfaec2cd 100644 --- a/clients/pkg/logentry/stages/json.go +++ b/clients/pkg/logentry/stages/json.go @@ -164,8 +164,9 @@ func (j *jsonStage) Process(labels model.LabelSet, extracted map[string]interfac extracted[n] = string(jm) } } - level.Debug(j.logger).Log("msg", "extracted data debug in json stage", "extracted data", fmt.Sprintf("%v", extracted)) - + if Debug{ + level.Debug(j.logger).Log("msg", "extracted data debug in json stage", "extracted data", fmt.Sprintf("%v", extracted)) + } } // Name implements Stage diff --git a/clients/pkg/logentry/stages/regex.go b/clients/pkg/logentry/stages/regex.go index 32dfefb773496..1364a2eaca8bb 100644 --- a/clients/pkg/logentry/stages/regex.go +++ b/clients/pkg/logentry/stages/regex.go @@ -128,7 +128,9 @@ func (r *regexStage) Process(labels model.LabelSet, extracted map[string]interfa extracted[name] = match[i] } } - level.Debug(r.logger).Log("msg", "extracted data debug in regex stage", "extracted data", fmt.Sprintf("%v", extracted)) + if Debug{ + level.Debug(r.logger).Log("msg", "extracted data debug in regex stage", "extracted data", fmt.Sprintf("%v", extracted)) + } } // Name implements Stage diff --git a/clients/pkg/logentry/stages/replace.go b/clients/pkg/logentry/stages/replace.go index a8c58903eae90..0ac1e0bbd46d2 100644 --- a/clients/pkg/logentry/stages/replace.go +++ b/clients/pkg/logentry/stages/replace.go @@ -161,7 +161,9 @@ func (r *replaceStage) Process(labels model.LabelSet, extracted map[string]inter } } } - level.Debug(r.logger).Log("msg", "extracted data debug in replace stage", "extracted data", fmt.Sprintf("%v", extracted)) + if Debug{ + level.Debug(r.logger).Log("msg", "extracted data debug in replace stage", "extracted data", fmt.Sprintf("%v", extracted)) + } } func (r *replaceStage) getReplacedEntry(matchAllIndex [][]int, input string, td map[string]string, templ *template.Template) (string, map[string]string, error) { From cbe99efc8435825ce1bca1e3ba30e8d484c9cce9 Mon Sep 17 00:00:00 2001 From: 3Xpl0it3r Date: Tue, 11 May 2021 22:39:22 +0800 Subject: [PATCH 4/4] format --- clients/pkg/logentry/stages/json.go | 2 +- clients/pkg/logentry/stages/regex.go | 2 +- clients/pkg/logentry/stages/replace.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clients/pkg/logentry/stages/json.go b/clients/pkg/logentry/stages/json.go index 74094bfaec2cd..b766540208961 100644 --- a/clients/pkg/logentry/stages/json.go +++ b/clients/pkg/logentry/stages/json.go @@ -164,7 +164,7 @@ func (j *jsonStage) Process(labels model.LabelSet, extracted map[string]interfac extracted[n] = string(jm) } } - if Debug{ + if Debug { level.Debug(j.logger).Log("msg", "extracted data debug in json stage", "extracted data", fmt.Sprintf("%v", extracted)) } } diff --git a/clients/pkg/logentry/stages/regex.go b/clients/pkg/logentry/stages/regex.go index 1364a2eaca8bb..f89d59f32b2de 100644 --- a/clients/pkg/logentry/stages/regex.go +++ b/clients/pkg/logentry/stages/regex.go @@ -128,7 +128,7 @@ func (r *regexStage) Process(labels model.LabelSet, extracted map[string]interfa extracted[name] = match[i] } } - if Debug{ + if Debug { level.Debug(r.logger).Log("msg", "extracted data debug in regex stage", "extracted data", fmt.Sprintf("%v", extracted)) } } diff --git a/clients/pkg/logentry/stages/replace.go b/clients/pkg/logentry/stages/replace.go index 0ac1e0bbd46d2..dbad84825cb1d 100644 --- a/clients/pkg/logentry/stages/replace.go +++ b/clients/pkg/logentry/stages/replace.go @@ -161,7 +161,7 @@ func (r *replaceStage) Process(labels model.LabelSet, extracted map[string]inter } } } - if Debug{ + if Debug { level.Debug(r.logger).Log("msg", "extracted data debug in replace stage", "extracted data", fmt.Sprintf("%v", extracted)) } }