From b03b3b4b918395d5f4234f8505b959a5e8a3bea9 Mon Sep 17 00:00:00 2001 From: Andrew Wilkins Date: Tue, 12 Oct 2021 16:42:26 +0800 Subject: [PATCH] txmetrics: group by service.node.name, cloud (#6323) --- changelogs/head.asciidoc | 1 + docs/metricset-indices.asciidoc | 4 ++ .../aggregation/txmetrics/aggregator.go | 45 +++++++++++++------ .../aggregation/txmetrics/aggregator_test.go | 4 ++ 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/changelogs/head.asciidoc b/changelogs/head.asciidoc index de6e4968a08..5fd10c42688 100644 --- a/changelogs/head.asciidoc +++ b/changelogs/head.asciidoc @@ -41,6 +41,7 @@ https://github.com/elastic/apm-server/compare/7.15\...master[View commits] - We now record the direct network peer for incoming requests as `source.ip` and `source.port`; origin IP is recorded in `client.ip` {pull}6152[6152] - We now collect span destination metrics for transactions with too many spans (for example due to transaction_max_spans or exit_span_min_duration) when collected and sent by APM agents {pull}6200[6200] - `output.elasticsearch.experimental` can be used to enable a new, experimental Elasticsearch output using the go-elasticsearch client {pull}5970[5970] +- Transaction metrics now also group by `service.node.name`, `cloud.provider`, `cloud.region`, `cloud.availability_zone` {pull}6323[6323] [float] ==== Deprecated diff --git a/docs/metricset-indices.asciidoc b/docs/metricset-indices.asciidoc index 64614860950..cca49e26583 100644 --- a/docs/metricset-indices.asciidoc +++ b/docs/metricset-indices.asciidoc @@ -88,10 +88,14 @@ You can filter and group by these dimensions (some of which are optional, for ex * `agent.name`: The name of the APM agent that instrumented the transaction, for example `java` * `service.name`: The name of the service that served the transaction * `service.version`: The version of the service that served the transaction +* `service.node.name`: The name of the service instance that served the transaction * `service.environment`: The environment of the service that served the transaction * `host.hostname`: The hostname of the service that served the transaction * `container.id`: The container ID of the service that served the transaction * `kubernetes.pod.name`: The name of the Kubernetes pod running the service that served the transaction +* `cloud.provider`: The cloud provider hosting the service instance that served the transaction +* `cloud.region`: The cloud region hosting the service instance that served the transaction +* `cloud.availability_zone`: The cloud availability zone hosting the service instance that served the transaction -- The `@timestamp` field of these documents holds the start of the aggregation interval. diff --git a/x-pack/apm-server/aggregation/txmetrics/aggregator.go b/x-pack/apm-server/aggregation/txmetrics/aggregator.go index 936a18f699f..ed000068f86 100644 --- a/x-pack/apm-server/aggregation/txmetrics/aggregator.go +++ b/x-pack/apm-server/aggregation/txmetrics/aggregator.go @@ -351,10 +351,15 @@ func (a *Aggregator) makeTransactionAggregationKey(event model.APMEvent, interva serviceEnvironment: event.Service.Environment, serviceName: event.Service.Name, serviceVersion: event.Service.Version, + serviceNodeName: event.Service.Node.Name, hostname: event.Host.Hostname, containerID: event.Container.ID, kubernetesPodName: event.Kubernetes.PodName, + + cloudProvider: event.Cloud.Provider, + cloudRegion: event.Cloud.Region, + cloudAvailabilityZone: event.Cloud.AvailabilityZone, } } @@ -378,8 +383,14 @@ func makeMetricset( Service: model.Service{ Name: key.serviceName, Version: key.serviceVersion, + Node: model.ServiceNode{Name: key.serviceNodeName}, Environment: key.serviceEnvironment, }, + Cloud: model.Cloud{ + Provider: key.cloudProvider, + Region: key.cloudRegion, + AvailabilityZone: key.cloudAvailabilityZone, + }, Host: model.Host{ Hostname: key.hostname, }, @@ -426,19 +437,23 @@ type metricsMapEntry struct { // NOTE(axw) the dimensions should be kept in sync with docs/metricset-indices.asciidoc. type transactionAggregationKey struct { - timestamp time.Time - traceRoot bool - agentName string - containerID string - hostname string - kubernetesPodName string - serviceEnvironment string - serviceName string - serviceVersion string - transactionName string - transactionResult string - transactionType string - eventOutcome string + timestamp time.Time + traceRoot bool + agentName string + containerID string + hostname string + kubernetesPodName string + cloudProvider string + cloudRegion string + cloudAvailabilityZone string + serviceEnvironment string + serviceName string + serviceVersion string + serviceNodeName string + transactionName string + transactionResult string + transactionType string + eventOutcome string } func (k *transactionAggregationKey) hash() uint64 { @@ -453,9 +468,13 @@ func (k *transactionAggregationKey) hash() uint64 { h.WriteString(k.containerID) h.WriteString(k.hostname) h.WriteString(k.kubernetesPodName) + h.WriteString(k.cloudProvider) + h.WriteString(k.cloudRegion) + h.WriteString(k.cloudAvailabilityZone) h.WriteString(k.serviceEnvironment) h.WriteString(k.serviceName) h.WriteString(k.serviceVersion) + h.WriteString(k.serviceNodeName) h.WriteString(k.transactionName) h.WriteString(k.transactionResult) h.WriteString(k.transactionType) diff --git a/x-pack/apm-server/aggregation/txmetrics/aggregator_test.go b/x-pack/apm-server/aggregation/txmetrics/aggregator_test.go index 647dce84290..261b7e96e71 100644 --- a/x-pack/apm-server/aggregation/txmetrics/aggregator_test.go +++ b/x-pack/apm-server/aggregation/txmetrics/aggregator_test.go @@ -454,8 +454,12 @@ func TestAggregationFields(t *testing.T) { &input.Service.Environment, &input.Service.Name, &input.Service.Version, + &input.Service.Node.Name, &input.Container.ID, &input.Kubernetes.PodName, + &input.Cloud.Provider, + &input.Cloud.Region, + &input.Cloud.AvailabilityZone, } var expected []model.APMEvent