Skip to content

Commit

Permalink
[release-2.7.x] promtail: Handle nil error on target Details() call (#…
Browse files Browse the repository at this point in the history
…8604)

Backport d3615f7 from #7771

---------

Co-authored-by: George Tsilias <tsiliasg@gmail.com>
Co-authored-by: Dylan Guedes <djmgguedes@gmail.com>
  • Loading branch information
3 people authored Feb 23, 2023
1 parent 0ec4d88 commit 356c2c3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@

#### Promtail

##### Enhancements

##### Fixes

* [7771](https://github.com/grafana/loki/pull/7771) **GeorgeTsilias**: Handle nil error on target Details() call.
* [7461](https://github.com/grafana/loki/pull/7461) **MarNicGit**: Promtail: Fix collecting userdata field from Windows Event Log

## 2.7.3 (2023-02-01)
Expand Down
6 changes: 5 additions & 1 deletion clients/pkg/promtail/targets/cloudflare/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,13 @@ func (t *Target) Ready() bool {

func (t *Target) Details() interface{} {
fields, _ := Fields(FieldsType(t.config.FieldsType))
var errMsg string
if t.err != nil {
errMsg = t.err.Error()
}
return map[string]string{
"zone_id": t.config.ZoneID,
"error": t.err.Error(),
"error": errMsg,
"position": t.positions.GetString(positions.CursorKey(t.config.ZoneID)),
"last_timestamp": t.to.String(),
"fields": strings.Join(fields, ","),
Expand Down
6 changes: 5 additions & 1 deletion clients/pkg/promtail/targets/docker/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,13 @@ func (t *Target) Labels() model.LabelSet {

// Details returns target-specific details.
func (t *Target) Details() interface{} {
var errMsg string
if t.err != nil {
errMsg = t.err.Error()
}
return map[string]string{
"id": t.containerName,
"error": t.err.Error(),
"error": errMsg,
"position": t.positions.GetString(positions.CursorKey(t.containerName)),
"running": strconv.FormatBool(t.running.Load()),
}
Expand Down

0 comments on commit 356c2c3

Please sign in to comment.