Skip to content

Commit

Permalink
[beats] reduce log noise (#34460)
Browse files Browse the repository at this point in the history
  • Loading branch information
klacabane authored Feb 8, 2023
1 parent 78c035e commit 83422d5
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions metricbeat/module/beat/stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
package stats

import (
"github.com/pkg/errors"
"errors"
"fmt"
"time"

"github.com/elastic/beats/v7/metricbeat/mb"
"github.com/elastic/beats/v7/metricbeat/mb/parse"
Expand All @@ -45,6 +47,7 @@ var (
// MetricSet defines all fields of the MetricSet
type MetricSet struct {
*beat.MetricSet
lastClusterUUIDMessageTimestamp time.Time
}

// New create a new instance of the MetricSet
Expand All @@ -70,6 +73,14 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) error {

clusterUUID, err := m.getClusterUUID()
if err != nil {
if errors.Is(err, beat.ErrClusterUUID) {
if time.Since(m.lastClusterUUIDMessageTimestamp) > 5*time.Minute {
m.lastClusterUUIDMessageTimestamp = time.Now()
m.Logger().Debug(err)
}
return nil
}

return err
}

Expand All @@ -79,7 +90,7 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) error {
func (m *MetricSet) getClusterUUID() (string, error) {
state, err := beat.GetState(m.MetricSet)
if err != nil {
return "", errors.Wrap(err, "could not get state information")
return "", fmt.Errorf("could not get state information: %w", err)
}

clusterUUID := state.Monitoring.ClusterUUID
Expand Down

0 comments on commit 83422d5

Please sign in to comment.