-
Notifications
You must be signed in to change notification settings - Fork 31
Description
Hi,
APM server seems to break Scope Metrics into different documents (as seen on Kibana) if metrics are instrumented via SDK, instead of all metrics from the same scope in one document, due to metrics having different timestamp. Not sure if this is a feature or an issue
Issue Statement
We're instrumenting via Opentelemetry-go SDK and have different types of metrics organized around scopes (i.e., different Meter). Then all metrics are pipelined through OTeL collector, then onto APM server.
Below is the snippets of the metrics from one Scope, as output by Otel collector. 5 metrics under scope1 with the same attributes but different timestamp
ResourceMetrics #1
Resource SchemaURL:
Resource attributes:
-> collector: Str(xxxx)
-> env: Str(TEST)
-> host: Str(xxxx)
-> service.name: Str(xxx)
-> telemetry.sdk.language: Str(go)
-> host.name: Str(otelcol-deployment-collector-6475d6969b-kt28r)
-> os.type: Str(linux)
-> k8s.cluster.name: Str(xxxxx)
ScopeMetrics #0
ScopeMetrics SchemaURL:
InstrumentationScope scope1
Metric #0
Descriptor:
-> Name: metric0
-> Description:
-> Unit:
-> DataType: Gauge
NumberDataPoints #0
Data point attributes:
-> attribute1: Str(attr1)
-> attribute2: Str(attr1)
StartTimestamp: 2024-09-23 06:01:13.822721145 +0000 UTC
Timestamp: 2024-09-23 06:25:08.022659417 +0000 UTC
Value: 101320
Metric #1
Descriptor:
-> Name: metric1
-> Description:
-> Unit:
-> DataType: Gauge
NumberDataPoints #0
Data point attributes:
-> attribute1: Str(attr1)
-> attribute2: Str(attr1)
StartTimestamp: 2024-09-23 06:01:13.822745402 +0000 UTC
Timestamp: 2024-09-23 06:25:08.022674989 +0000 UTC
Value: 101556
Metric #2
Descriptor:
-> Name: metric2
-> Description:
-> Unit:
-> DataType: Gauge
NumberDataPoints #0
Data point attributes:
-> attribute1: Str(attr1)
-> attribute2: Str(attr1)
StartTimestamp: 2024-09-23 06:01:13.822749919 +0000 UTC
Timestamp: 2024-09-23 06:25:08.022675672 +0000 UTC
Value: 3584
Metric #3
Descriptor:
-> Name: metric3
-> Description:
-> Unit:
-> DataType: Gauge
NumberDataPoints #0
Data point attributes:
-> attribute1: Str(attr1)
-> attribute2: Str(attr1)
StartTimestamp: 2024-09-23 06:01:13.822753575 +0000 UTC
Timestamp: 2024-09-23 06:25:08.022676329 +0000 UTC
Value: 3586
Metric #4
Descriptor:
-> Name: metric4
-> Description:
-> Unit:
-> DataType: Gauge
NumberDataPoints #0
Data point attributes:
-> attribute1: Str(attr1)
-> attribute2: Str(attr1)
StartTimestamp: 2024-09-23 06:01:13.82275741 +0000 UTC
Timestamp: 2024-09-23 06:25:08.022676819 +0000 UTC
Value: 1
Metric #5
Descriptor:
-> Name: metric5
-> Description:
-> Unit:
-> DataType: Gauge
NumberDataPoints #0
Data point attributes:
-> attribute1: Str(attr1)
-> attribute2: Str(attr1)
StartTimestamp: 2024-09-23 06:01:13.822796019 +0000 UTC
Timestamp: 2024-09-23 06:25:08.022677264 +0000 UTC
Value: 2
Current result seen on Kibana: 5 documents with each containing one metric
collector: Str(xxxx)
env: Str(TEST)
host: Str(xxxx)
service.name: Str(xxx)
telemetry.sdk.language: Str(go)
host.name: Str(otelcol-deployment-collector-6475d6969b-kt28r)
os.type: Str(linux)
k8s.cluster.name: Str(xxxxx)
metric1: value1
Expected result seen on Kibana: one document with 5 metrics
collector: Str(xxxx)
env: Str(TEST)
host: Str(xxxx)
service.name: Str(xxx)
telemetry.sdk.language: Str(go)
host.name: Str(otelcol-deployment-collector-6475d6969b-kt28r)
os.type: Str(linux)
k8s.cluster.name: Str(xxxxx)
metric0: value0
metric1: value1
metric2: value2
metric3: value3
metric4: value4
Possible cause
The group key is the combination of timestamp and attributes on Datapoint as seen here
key := metricsetKey{timestamp: timestamp, signature: signatureBuilder.String()}
So if the metrics come in with different timestamp, they will end up in different metricset.
Version
8.15
Proposal
It makes sense that all metrics from one scope be seen in one document. This makes it easier to later use them for alerting and dashboard. Without knowing how data is stored in Elastic, I feel like this may save some storage as well
So it seems reasonable to only use attributes on Datapoint as group key since metrics will certainly have different timestamp if generated by SDK. To my knowledge, there is no way to set timestamp while instrumenting.
From:
type metricsetKey struct {
timestamp time.Time
signature string // combination of all attributes
}
To:
type metricsetKey struct {
signature string // combination of all attributes
}