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

[6.8] Only log error (don't also index it) if xpack is enabled. (#12353) #12379

Merged
merged 1 commit into from
Jun 3, 2019
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ https://github.com/elastic/beats/compare/v6.7.2...6.8[Check the HEAD diff]
- Validate that kibana/status metricset cannot be used when xpack is enabled. {pull}12264[12264]
- 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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should stay as before as we don't have the new framework in 6.8?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note the name of this function. It's a function that is specific to this metricset, not part of the mb.MetricSet interface.

}
}

func (m *MetricSet) fetchSettings(r mb.ReporterV2, now time.Time) {
func (m *MetricSet) fetchSettings(r mb.ReporterV2, now time.Time) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm now confused. Do we already support this in 6.8?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note the name of this function. It's a function that is specific to this metricset, not part of the mb.MetricSet interface.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂ Got it.

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