Skip to content

Commit

Permalink
[metricbeat] [gcp] add redis regions support (#33728)
Browse files Browse the repository at this point in the history
* add redis regions support

* add changelog entry
  • Loading branch information
gpop63 authored and chrisberkhout committed Jun 1, 2023
1 parent ee3c4e8 commit 457c3e9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ https://github.com/elastic/beats/compare/v8.2.0\...main[Check the HEAD diff]
- Update README file on how to run Metricbeat on Kubernetes. {pull}33308[33308]
- Add per-thread metrics to system_summary {pull}33614[33614]
- Add GCP CloudSQL metadata {pull}33066[33066]
- Add GCP Redis regions support {pull}33728[33728]

*Packetbeat*

Expand Down
4 changes: 3 additions & 1 deletion x-pack/metricbeat/module/gcp/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ const (
ServiceFirestore = "firestore"
ServiceDataproc = "dataproc"
ServiceCloudSQL = "cloudsql"
ServiceRedis = "redis"
)

//Paths within the GCP monitoring.TimeSeries response, if converted to JSON, where you can find each ECS field required for the output event
// Paths within the GCP monitoring.TimeSeries response, if converted to JSON, where you can find each ECS field required for the output event
const (
TimeSeriesResponsePathForECSAvailabilityZone = "zone"
TimeSeriesResponsePathForECSAccountID = "project_id"
Expand Down Expand Up @@ -84,6 +85,7 @@ const (
StorageResourceLabelLocation = "resource.label.location"
CloudSQLResourceLabelRegion = "resource.labels.region"
DataprocResourceLabelLocation = "resource.label.region"
RedisResourceLabelRegion = "resource.label.region"
)

// AlignersMapToGCP map contains available perSeriesAligner
Expand Down
13 changes: 13 additions & 0 deletions x-pack/metricbeat/module/gcp/metrics/metrics_requester.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,19 @@ func (r *metricsRequester) getFilterForMetric(serviceName, m string) string {
regionsFilter := r.buildRegionsFilter(r.config.Regions, gcp.CloudSQLResourceLabelRegion)
f = fmt.Sprintf("%s AND %s", f, regionsFilter)
}
case gcp.ServiceRedis:
if r.config.Region != "" && len(r.config.Regions) != 0 {
r.logger.Warnf("when region %s and regions config parameters are both provided, use region", r.config.Region)
}

switch {
case r.config.Region != "":
region := strings.TrimSuffix(r.config.Region, "*")
f = fmt.Sprintf("%s AND %s = starts_with(\"%s\")", f, gcp.RedisResourceLabelRegion, region)
case len(r.config.Regions) != 0:
regionsFilter := r.buildRegionsFilter(r.config.Regions, gcp.RedisResourceLabelRegion)
f = fmt.Sprintf("%s AND %s", f, regionsFilter)
}
default:
if r.config.Region != "" && r.config.Zone != "" {
r.logger.Warnf("when region %s and zone %s config parameter "+
Expand Down

0 comments on commit 457c3e9

Please sign in to comment.