Skip to content

Commit

Permalink
Only log error (don't also index it) if xpack is enabled. (#12353)
Browse files Browse the repository at this point in the history
* Only log error (don't also index it) if xpack is enabled.

* Adding CHANGELOG entry
  • Loading branch information
ycombinator authored May 31, 2019
1 parent e9717b6 commit 7f0ac09
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ https://github.com/elastic/beats/compare/v7.1.1...7.1[Check the HEAD diff]
- Ignore prometheus metrics when their values are NaN or Inf. {pull}12084[12084] {issue}10849[10849]
- Require client_auth by default when ssl is enabled for module http metricset server{pull}12333[12333]
- Require certificate authorities, certificate file, and key when SSL is enabled for module http metricset server. {pull}12355[12355]
- In the kibana/stats metricset, only log error (don't also index it) if xpack is enabled. {pull}12353[12353]

*Packetbeat*

Expand Down
44 changes: 21 additions & 23 deletions metricbeat/module/kibana/stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,25 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
func (m *MetricSet) Fetch(r mb.ReporterV2) {
now := time.Now()

m.fetchStats(r, now)
err := m.fetchStats(r, now)
if err != nil {
if m.XPackEnabled {
m.Log.Error(err)
} else {
elastic.ReportAndLogError(err, r, m.Log)
}
return
}

if m.XPackEnabled {
m.fetchSettings(r, now)
err = m.fetchSettings(r, now)
if err != nil {
m.Log.Error(err)
}
}
}

func (m *MetricSet) fetchStats(r mb.ReporterV2, now time.Time) {
func (m *MetricSet) fetchStats(r mb.ReporterV2, now time.Time) error {
// Collect usage stats only once every usageCollectionPeriod
if m.isUsageExcludable {
origURI := m.statsHTTP.GetURI()
Expand All @@ -152,39 +164,25 @@ func (m *MetricSet) fetchStats(r mb.ReporterV2, now time.Time) {

content, err := m.statsHTTP.FetchContent()
if err != nil {
elastic.ReportAndLogError(err, r, m.Log)
return
return err
}

if m.XPackEnabled {
intervalMs := m.calculateIntervalMs()
err = eventMappingStatsXPack(r, intervalMs, now, content)
if err != nil {
m.Log.Error(err)
return
}
return eventMappingStatsXPack(r, intervalMs, now, content)
} else {
err = eventMapping(r, content)
if err != nil {
elastic.ReportAndLogError(err, r, m.Log)
return
}
return eventMapping(r, content)
}
}

func (m *MetricSet) fetchSettings(r mb.ReporterV2, now time.Time) {
func (m *MetricSet) fetchSettings(r mb.ReporterV2, now time.Time) error {
content, err := m.settingsHTTP.FetchContent()
if err != nil {
m.Log.Error(err)
return
return err
}

intervalMs := m.calculateIntervalMs()
err = eventMappingSettingsXPack(r, intervalMs, now, content)
if err != nil {
m.Log.Error(err)
return
}
return eventMappingSettingsXPack(r, intervalMs, now, content)
}

func (m *MetricSet) calculateIntervalMs() int64 {
Expand Down

0 comments on commit 7f0ac09

Please sign in to comment.