-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[filebeat][filestream] Enable status reporter for filestream input #40121
[filebeat][filestream] Enable status reporter for filestream input #40121
Conversation
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
…lastic#40121) * initial commit filestream status * fix: test cleanup * fix: move the statusReporter to correct place * fix: remove test cases for now * chore: add changelog * fix: address review comments
@@ -163,7 +164,11 @@ func (inp *filestream) Run( | |||
}) | |||
defer streamCancel() | |||
|
|||
return inp.readFromSource(ctx, log, r, fs.newPath, state, publisher, metrics) | |||
if err := inp.readFromSource(ctx, log, r, fs.newPath, state, publisher, metrics); err != nil { | |||
ctx.UpdateStatus(status.Degraded, fmt.Sprintf("error while reading from source: %v", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late comment, if this exits with a transient error, what is setting the input state back to healthy?
In general the thing I am watching out for in the status reporting PRs situations where we permanently mark inputs as degraded or failed after the error condition has cleared.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cmacknz I understand your concern.
I did some digging and turns out that readFromSource
only throws an error when it calls Publish()
beats/filebeat/input/filestream/input.go
Lines 394 to 397 in d87d15b
if err := p.Publish(message.ToEvent(), s); err != nil { | |
metrics.ProcessingErrors.Inc() | |
return err | |
} |
The above error is returned when the context is cancelled.
beats/filebeat/input/filestream/internal/input-logfile/publish.go
Lines 91 to 97 in d87d15b
func (c *cursorPublisher) forward(event beat.Event) error { | |
c.client.Publish(event) | |
if c.canceler == nil { | |
return nil | |
} | |
return c.canceler.Err() | |
} |
For other cases (EOF, reader was closed etc.), we just log the error and return nil
. So, we will not mark the input as degraded, as they are transient in nature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cmacknz maybe we don't need this particular ctx.UpdateStatus
? I don't think we need to mark input as degraded when the context is cancelled (which should ideally happen during beat shutdown).
I overlooked this particular ctx.UpdateStatus
.
Proposed commit message
Enable
StatusReporter
forfilestream
input which was introduced in #39209Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Related issues
Use cases
This PR allows the filestream to report its status to elastic-agent. This would keep the status of the unit up-to-date and would help with diagnostics.
Screenshots
Logs