Skip to content

Commit

Permalink
Replace event.metric_names_hash
Browse files Browse the repository at this point in the history
Replace it with `gcp.metric_names_fingerprint` to align this metricset
with what we are doing on other metricsets (for example, the
prometheus metricset).
  • Loading branch information
zmoog committed Oct 24, 2023
1 parent efe6a55 commit 02be686
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 18 deletions.
3 changes: 1 addition & 2 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -35303,7 +35303,7 @@ GCP module



*`event.metric_names_hash`*::
*`gcp.metric_names_fingerprint`*::
+
--
The SHA-256 hash of the comma-separated list metric names collected in the batch. For example, l3.external.ingress_packets.count,l3.external.ingress.bytes > 24848afd85b65b9e168fa5dee12bd3e121c58a504cc0b4386a15bd9bcd065a5d. Required to support TSDB.
Expand All @@ -35313,7 +35313,6 @@ type: keyword

--


*`gcp.labels`*::
+
--
Expand Down
7 changes: 2 additions & 5 deletions x-pack/metricbeat/module/gcp/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@
description: >
GCP module
fields:
- name: event
- name: gcp
type: group
fields:
- name: metric_names_hash
- name: metric_names_fingerprint
type: keyword
description: >
The SHA-256 hash of the comma-separated list metric names collected in the batch. For example, l3.external.ingress_packets.count,l3.external.ingress.bytes > 24848afd85b65b9e168fa5dee12bd3e121c58a504cc0b4386a15bd9bcd065a5d. Required to support TSDB.
- name: gcp
type: group
fields:
- name: labels
type: object
description: >
Expand Down
2 changes: 1 addition & 1 deletion x-pack/metricbeat/module/gcp/fields.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion x-pack/metricbeat/module/gcp/metrics/timeseries.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func createEventsFromGroups(service string, groups map[string][]KeyValuePoint) [
// current TSDB dimension field limit (1024).
metricNamesHash := hash(strings.Join(metricNames, ","))

_, _ = event.RootFields.Put("event.metric_names_hash", metricNamesHash)
_, _ = event.ModuleFields.Put("metric_names_fingerprint", metricNamesHash)

events = append(events, event)
}
Expand Down
12 changes: 3 additions & 9 deletions x-pack/metricbeat/module/gcp/metrics/timeseries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ func TestCreateEventsFromGroup(t *testing.T) {
{
Timestamp: timestampGroup1,
ModuleFields: mapstr.M{
"metric_names_fingerprint": "2a990d0ce61c177d3bc05def9f536de164d3ea10056b7120414ad370a0f686c0",
"labels": mapstr.M{
"user.deployment": "deploy-1",
"user.division": "div-1",
Expand All @@ -474,14 +475,12 @@ func TestCreateEventsFromGroup(t *testing.T) {
"cloud.instance.id": "1",
"cloud.provider": "gcp",
"cloud.region": "us-west",
"event": mapstr.M{
"metric_names_hash": "2a990d0ce61c177d3bc05def9f536de164d3ea10056b7120414ad370a0f686c0",
},
},
},
{
Timestamp: timestampGroup2,
ModuleFields: mapstr.M{
"metric_names_fingerprint": "f7c8d8a9a75411effbd2171a8fa984a5e618eeca3911829b03c7e3e3d6e74522",
"labels": mapstr.M{
"user.deployment": "deploy-1",
"user.division": "div-1",
Expand All @@ -503,14 +502,12 @@ func TestCreateEventsFromGroup(t *testing.T) {
"cloud.instance.id": "1",
"cloud.provider": "gcp",
"cloud.region": "us-east",
"event": mapstr.M{
"metric_names_hash": "f7c8d8a9a75411effbd2171a8fa984a5e618eeca3911829b03c7e3e3d6e74522",
},
},
},
{
Timestamp: timestampGroup3,
ModuleFields: mapstr.M{
"metric_names_fingerprint": "ce7dee36d9ab56de52176bf05d21c0bc446da9a3134727bf5e300604f2ca63ef",
"labels": mapstr.M{
"user.deployment": "deploy-1",
"user.division": "div-1",
Expand All @@ -531,9 +528,6 @@ func TestCreateEventsFromGroup(t *testing.T) {
"cloud.instance.id": "2",
"cloud.provider": "gcp",
"cloud.region": "us-east",
"event": mapstr.M{
"metric_names_hash": "ce7dee36d9ab56de52176bf05d21c0bc446da9a3134727bf5e300604f2ca63ef",
},
},
},
}
Expand Down

0 comments on commit 02be686

Please sign in to comment.