Skip to content

Commit

Permalink
add debug information for extracted data (#3711)
Browse files Browse the repository at this point in the history
* fix the promtail-default-config download link in doc

* add debug information for extreacted in stage

* add Debug variable

* format
  • Loading branch information
3Xpl0it3r authored May 18, 2021
1 parent 38e0601 commit 89bdc9c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion clients/pkg/logentry/stages/json.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package stages

import (
"fmt"
"reflect"
"time"

Expand Down Expand Up @@ -163,7 +164,9 @@ func (j *jsonStage) Process(labels model.LabelSet, extracted map[string]interfac
extracted[n] = string(jm)
}
}

if Debug {
level.Debug(j.logger).Log("msg", "extracted data debug in json stage", "extracted data", fmt.Sprintf("%v", extracted))
}
}

// Name implements Stage
Expand Down
5 changes: 4 additions & 1 deletion clients/pkg/logentry/stages/regex.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package stages

import (
"fmt"
"reflect"
"regexp"
"time"
Expand Down Expand Up @@ -127,7 +128,9 @@ func (r *regexStage) Process(labels model.LabelSet, extracted map[string]interfa
extracted[name] = match[i]
}
}

if Debug {
level.Debug(r.logger).Log("msg", "extracted data debug in regex stage", "extracted data", fmt.Sprintf("%v", extracted))
}
}

// Name implements Stage
Expand Down
4 changes: 4 additions & 0 deletions clients/pkg/logentry/stages/replace.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package stages

import (
"bytes"
"fmt"
"reflect"
"regexp"
"text/template"
Expand Down Expand Up @@ -160,6 +161,9 @@ func (r *replaceStage) Process(labels model.LabelSet, extracted map[string]inter
}
}
}
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) {
Expand Down

0 comments on commit 89bdc9c

Please sign in to comment.