Skip to content

Commit

Permalink
Fix log level on output clients
Browse files Browse the repository at this point in the history
Fix the log level for event data on all outputs. Now the log level
from the message containing the evnt matches the one that does not
contain it.
  • Loading branch information
belimawr committed Apr 10, 2024
1 parent 6762542 commit bbd134f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion filebeat/tests/integration/event_log_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ output:
password: testing
logging:
level: debug
level: info
event_data:
files:
name: filebeat-my-event-log
Expand Down
6 changes: 3 additions & 3 deletions libbeat/outputs/elasticsearch/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,11 @@ func (client *Client) bulkCollectPublishFails(result eslegclient.BulkResult, dat
if result {
stats.nonIndexable++
client.log.Errorf("Can't deliver to dead letter index event (status=%v). Look at the event log to view the event and cause.", status)
client.log.Debugw(fmt.Sprintf("Can't deliver to dead letter index event %#v (status=%v): %s", data[i], status, msg), "log.type", "event")
client.log.Errorw(fmt.Sprintf("Can't deliver to dead letter index event %#v (status=%v): %s", data[i], status, msg), "log.type", "event")
// poison pill - this will clog the pipeline if the underlying failure is non transient.
} else if client.deadLetterIndex != "" {
client.log.Warnf("Cannot index event (status=%v), trying dead letter index. Look at the event log to view the event and cause.", status)
client.log.Debugw(fmt.Sprintf("Cannot index event %#v (status=%v): %s, trying dead letter index", data[i], status, msg), "log.type", "event")
client.log.Warnw(fmt.Sprintf("Cannot index event %#v (status=%v): %s, trying dead letter index", data[i], status, msg), "log.type", "event")
if data[i].Content.Meta == nil {
data[i].Content.Meta = mapstr.M{
dead_letter_marker_field: true,
Expand All @@ -451,7 +451,7 @@ func (client *Client) bulkCollectPublishFails(result eslegclient.BulkResult, dat
} else { // drop
stats.nonIndexable++
client.log.Warnf("Cannot index event (status=%v): dropping event! Look at the event log to view the event and cause.", status)
client.log.Debugw(fmt.Sprintf("Cannot index event %#v (status=%v): %s, dropping event!", data[i], status, msg), "log.type", "event")
client.log.Warnw(fmt.Sprintf("Cannot index event %#v (status=%v): %s, dropping event!", data[i], status, msg), "log.type", "event")
continue
}
}
Expand Down
4 changes: 2 additions & 2 deletions libbeat/outputs/redis/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func serializeEvents(
serializedEvent, err := codec.Encode(index, &d.Content)
if err != nil {
log.Errorf("Encoding event failed with error: %+v. Look at the event log file to view the event", err)
log.Debugw(fmt.Sprintf("Failed event: %v", d.Content), "log.type", "event")
log.Errorw(fmt.Sprintf("Failed event: %v", d.Content), "log.type", "event")
goto failLoop
}

Expand All @@ -339,7 +339,7 @@ failLoop:
serializedEvent, err := codec.Encode(index, &d.Content)
if err != nil {
log.Errorf("Encoding event failed with error: %+v. Look at the event log file to view the event", err)
log.Debugw(fmt.Sprintf("Failed event: %v", d.Content), "log.type", "event")
log.Errorw(fmt.Sprintf("Failed event: %v", d.Content), "log.type", "event")
i++
continue
}
Expand Down

0 comments on commit bbd134f

Please sign in to comment.