Skip to content

Commit

Permalink
Cherry-pick #17608 to 7.6: [Metricbeat] Fix "ID" event generator of G…
Browse files Browse the repository at this point in the history
…oogle Cloud module (#17612)
  • Loading branch information
sayden authored Apr 8, 2020
1 parent 76f7fdf commit 1294416
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix diskio issue for windows 32 bit on disk_performance struct alignment. {issue}16680[16680]
- Reduce memory usage in `elasticsearch/index` metricset. {issue}16503[16503] {pull}16538[16538]
- Fix issue in Jolokia module when mbean contains multiple quoted properties. {issue}17375[17375] {pull}17374[17374]
- Fix "ID" event generator of Google Cloud module {issue}17160[17160] {pull}17608[17608]

*Packetbeat*

Expand Down
13 changes: 7 additions & 6 deletions x-pack/metricbeat/module/googlecloud/stackdriver/timeseries.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,29 @@ import (
func (m *MetricSet) timeSeriesGrouped(ctx context.Context, gcpService googlecloud.MetadataService, tss []*monitoringpb.TimeSeries, e *incomingFieldExtractor) (map[string][]KeyValuePoint, error) {
eventGroups := make(map[string][]KeyValuePoint)

for _, ts := range tss {
if gcpService == nil {
gcpService = googlecloud.NewStackdriverMetadataServiceForTimeSeries(ts)
}
metadataService := gcpService

for _, ts := range tss {
keyValues, err := e.extractTimeSeriesMetricValues(ts)
if err != nil {
return nil, err
}

sdCollectorInputData := googlecloud.NewStackdriverCollectorInputData(ts, m.config.ProjectID, m.config.Zone)
if gcpService == nil {
metadataService = googlecloud.NewStackdriverMetadataServiceForTimeSeries(ts)
}

for i := range keyValues {
sdCollectorInputData.Timestamp = &keyValues[i].Timestamp

id, err := gcpService.ID(ctx, sdCollectorInputData)
id, err := metadataService.ID(ctx, sdCollectorInputData)
if err != nil {
m.Logger().Errorf("error trying to retrieve ID from metric event '%v'", err)
continue
}

metadataCollectorData, err := gcpService.Metadata(ctx, sdCollectorInputData.TimeSeries)
metadataCollectorData, err := metadataService.Metadata(ctx, sdCollectorInputData.TimeSeries)
if err != nil {
m.Logger().Error("error trying to retrieve labels from metric event")
continue
Expand Down

0 comments on commit 1294416

Please sign in to comment.