Skip to content

Commit 1636258

Browse files
committed
Revert "[filebeat][winlog] implement status reporter for winlog input (#40163)"
This reverts commit 5e4e7e5.
1 parent 7aae4c8 commit 1636258

1 file changed

Lines changed: 5 additions & 20 deletions

File tree

filebeat/input/winlog/input.go

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
input "github.com/elastic/beats/v7/filebeat/input/v2"
2727
cursor "github.com/elastic/beats/v7/filebeat/input/v2/input-cursor"
2828
"github.com/elastic/beats/v7/libbeat/feature"
29-
"github.com/elastic/beats/v7/libbeat/management/status"
3029
"github.com/elastic/elastic-agent-libs/logp"
3130
"github.com/elastic/go-concert/ctxtool"
3231
"github.com/elastic/go-concert/timed"
@@ -40,10 +39,6 @@ type eventlogRunner struct{}
4039

4140
const pluginName = "winlog"
4241

43-
const channelNotFoundError = "Encountered channel not found error when opening Windows Event Log"
44-
const eventLogReadingError = "Error occurred while reading from Windows Event Log"
45-
const resetError = "Error resetting Windows Event Log handle"
46-
4742
// Plugin create a stateful input Plugin collecting logs from Windows Event Logs.
4843
func Plugin(log *logp.Logger, store cursor.StateStore) input.Plugin {
4944
return input.Plugin{
@@ -104,7 +99,6 @@ func (eventlogRunner) Run(
10499

105100
// Flag used to detect repeat "channel not found" errors, eliminating log spam.
106101
channelNotFoundErrDetected := false
107-
ctx.UpdateStatus(status.Running, "")
108102

109103
runLoop:
110104
for {
@@ -115,9 +109,6 @@ runLoop:
115109

116110
evtCheckpoint := initCheckpoint(log, cursor)
117111
openErr := api.Open(evtCheckpoint)
118-
// Mark the input running.
119-
// Status will be changed to "Degraded" if any error are encountered during opening/reading
120-
ctx.UpdateStatus(status.Running, "")
121112

122113
switch {
123114
case eventlog.IsRecoverable(openErr):
@@ -126,16 +117,14 @@ runLoop:
126117
continue
127118
case !api.IsFile() && eventlog.IsChannelNotFound(openErr):
128119
if !channelNotFoundErrDetected {
129-
log.Errorw(channelNotFoundError, "error", openErr)
120+
log.Errorw("Encountered channel not found error when opening Windows Event Log", "error", openErr)
130121
} else {
131-
log.Debugw(channelNotFoundError, "error", openErr)
122+
log.Debugw("Encountered channel not found error when opening Windows Event Log", "error", openErr)
132123
}
133-
ctx.UpdateStatus(status.Degraded, fmt.Sprintf("%s: %v", channelNotFoundError, openErr))
134124
channelNotFoundErrDetected = true
135125
_ = timed.Wait(cancelCtx, 5*time.Second)
136126
continue
137127
case openErr != nil:
138-
ctx.UpdateStatus(status.Degraded, fmt.Sprintf("failed to open Windows Event Log channel %q: %v", api.Channel(), openErr))
139128
return fmt.Errorf("failed to open Windows Event Log channel %q: %w", api.Channel(), openErr)
140129
}
141130
channelNotFoundErrDetected = false
@@ -148,16 +137,14 @@ runLoop:
148137
if eventlog.IsRecoverable(err) {
149138
log.Errorw("Encountered recoverable error when reading from Windows Event Log", "error", err)
150139
if resetErr := api.Reset(); resetErr != nil {
151-
log.Errorw(resetError, "error", resetErr)
152-
ctx.UpdateStatus(status.Degraded, fmt.Sprintf("%s: %v", resetError, resetErr))
140+
log.Errorw("Error resetting Windows Event Log handle", "error", resetErr)
153141
}
154142
continue runLoop
155143
}
156144
if !api.IsFile() && eventlog.IsChannelNotFound(err) {
157145
log.Errorw("Encountered channel not found error when reading from Windows Event Log", "error", err)
158146
if resetErr := api.Reset(); resetErr != nil {
159-
log.Errorw(resetError, "error", resetErr)
160-
ctx.UpdateStatus(status.Degraded, fmt.Sprintf("%s: %v", resetError, resetErr))
147+
log.Errorw("Error resetting Windows Event Log handle", "error", resetErr)
161148
}
162149
continue runLoop
163150
}
@@ -173,8 +160,7 @@ runLoop:
173160
return nil
174161
}
175162

176-
log.Errorw(eventLogReadingError, "error", err)
177-
ctx.UpdateStatus(status.Degraded, fmt.Sprintf("%s: %v", eventLogReadingError, err))
163+
log.Errorw("Error occurred while reading from Windows Event Log", "error", err)
178164
return err
179165
}
180166
if len(records) == 0 {
@@ -187,7 +173,6 @@ runLoop:
187173
if err := publisher.Publish(event, record.Offset); err != nil {
188174
// Publisher indicates disconnect when returning an error.
189175
// stop trying to publish records and quit
190-
ctx.UpdateStatus(status.Degraded, fmt.Sprintf("Error occurred while publishing from winlog: %v", err))
191176
return err
192177
}
193178
}

0 commit comments

Comments
 (0)