Skip to content
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

[system/process]: mark module as healthy if metrics are partially filled for single process as well. #40924

Merged
merged 5 commits into from
Oct 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions metricbeat/module/system/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
return nil, err
}

sys := base.Module().(resolve.Resolver)
sys, ok := base.Module().(resolve.Resolver)
if !ok {
return nil, fmt.Errorf("resolver cannot be cast from the module")
}
enableCgroups := false
if runtime.GOOS == "linux" {
if config.Cgroups == nil || *config.Cgroups {
Expand Down Expand Up @@ -131,14 +134,17 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) error {
return err
} else {
proc, root, err := m.stats.GetOneRootEvent(m.setpid)
if err != nil {
if err != nil && !errors.Is(err, process.NonFatalErr{}) {
// return only if the error is fatal in nature
return fmt.Errorf("error fetching pid %d: %w", m.setpid, err)
} else if (err != nil && errors.Is(err, process.NonFatalErr{})) {
err = mb.PartialMetricsError{Err: err}
}
// if error is non-fatal, emit partial metrics.
r.Event(mb.Event{
MetricSetFields: proc,
RootFields: root,
})
return err
}

return nil
VihasMakwana marked this conversation as resolved.
Show resolved Hide resolved
}
Loading