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

fix(node_stats/data.go):修复es,当一个指标没有,整个node_stats指标集不上报 refs MONITOR-… #36

Merged
merged 1 commit into from
Oct 14, 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
17 changes: 14 additions & 3 deletions metricbeat/module/elasticsearch/node_stats/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

import (
"encoding/json"
"fmt"

Check failure on line 22 in metricbeat/module/elasticsearch/node_stats/data.go

View workflow job for this annotation

GitHub Actions / lint (windows)

File is not `goimports`-ed with -local github.com/elastic (goimports)

Check failure on line 22 in metricbeat/module/elasticsearch/node_stats/data.go

View workflow job for this annotation

GitHub Actions / lint (linux)

File is not `goimports`-ed with -local github.com/elastic (goimports)

Check failure on line 22 in metricbeat/module/elasticsearch/node_stats/data.go

View workflow job for this annotation

GitHub Actions / lint (darwin)

File is not `goimports`-ed with -local github.com/elastic (goimports)

"github.com/elastic/beats/v7/metricbeat/helper/elastic"
"github.com/elastic/elastic-agent-libs/mapstr"
"github.com/pkg/errors"

"github.com/joeshaw/multierror"

Expand Down Expand Up @@ -381,8 +381,19 @@

event.MetricSetFields, err = schema.Apply(node)
if err != nil {
errs = append(errs, fmt.Errorf("failure to apply node schema: %w", err))
continue
allKeyNotFoundErr := true
for _, e := range err.(*multierror.MultiError).Errors {

Check failure on line 385 in metricbeat/module/elasticsearch/node_stats/data.go

View workflow job for this annotation

GitHub Actions / lint (windows)

type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors (errorlint)

Check failure on line 385 in metricbeat/module/elasticsearch/node_stats/data.go

View workflow job for this annotation

GitHub Actions / lint (linux)

type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors (errorlint)

Check failure on line 385 in metricbeat/module/elasticsearch/node_stats/data.go

View workflow job for this annotation

GitHub Actions / lint (darwin)

type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors (errorlint)
var keyNotFoundError *s.KeyNotFoundError
if !errors.As(e, &keyNotFoundError) {
allKeyNotFoundErr = false
break
}
}

if !allKeyNotFoundErr {
errs = append(errs, errors.Wrap(err, "failure to apply node schema"))
continue
}
}

name, err := event.MetricSetFields.GetValue("name")
Expand Down
Loading