Skip to content

Commit

Permalink
ingest: translate known OpenTelemetry JVM metrics
Browse files Browse the repository at this point in the history
Copy well-known JVM metrics from their OpenTelemetry
names and associated labels to their counterparts
produced by the Elastic APM Java agent. This enables
users to visualise the metrics in the Elastic APM
app in Kibana.

Metrics are duplicated to avoid surprising users by
silently dropping the OpenTelemetry names. Users can
drop either one of the duplicates with ingest pipeline
customisation.
  • Loading branch information
axw committed Mar 24, 2021
1 parent 330b543 commit 7190052
Show file tree
Hide file tree
Showing 13 changed files with 395 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"description": "Populate Elastic APM metric fields from well-known OpenTelemetry metric counterparts",
"processors": [
{
"set": {
"field": "jvm.memory.{{labels.area}}.{{labels.type}}",
"copy_from": "runtime.jvm.memory.area",
"if": "ctx.runtime?.jvm?.memory?.area != null && ctx.labels?.area != null && ctx.labels?.type != null"
}
},
{
"set": {
"field": "jvm.gc.time",
"copy_from": "runtime.jvm.gc.time",
"if": "ctx.runtime?.jvm?.gc?.time != null"
}
},
{
"set": {
"field": "jvm.gc.count",
"copy_from": "runtime.jvm.gc.count",
"if": "ctx.runtime?.jvm?.gc?.count != null"
}
},
{
"set": {
"field": "jvm.gc.time",
"copy_from": "runtime.jvm.gc.collection",
"if": "ctx.runtime?.jvm?.gc?.collection != null"
}
},
{
"set": {
"field": "labels.name",
"copy_from": "labels.gc",
"override": false,
"if": "ctx.labels?.gc != null"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
"name": "metrics-apm.app-0.1.0-apm_error_grouping_name",
"if": "ctx.processor?.event == 'error'"
}
},
{
"pipeline": {
"name": "metrics-apm.app-0.1.0-apm_opentelemetry_metrics",
"if": "ctx.processor?.event == 'metric'"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"description": "Populate Elastic APM metric fields from well-known OpenTelemetry metric counterparts",
"processors": [
{
"set": {
"field": "jvm.memory.{{labels.area}}.{{labels.type}}",
"copy_from": "runtime.jvm.memory.area",
"if": "ctx.runtime?.jvm?.memory?.area != null && ctx.labels?.area != null && ctx.labels?.type != null"
}
},
{
"set": {
"field": "jvm.gc.time",
"copy_from": "runtime.jvm.gc.time",
"if": "ctx.runtime?.jvm?.gc?.time != null"
}
},
{
"set": {
"field": "jvm.gc.count",
"copy_from": "runtime.jvm.gc.count",
"if": "ctx.runtime?.jvm?.gc?.count != null"
}
},
{
"set": {
"field": "jvm.gc.time",
"copy_from": "runtime.jvm.gc.collection",
"if": "ctx.runtime?.jvm?.gc?.collection != null"
}
},
{
"set": {
"field": "labels.name",
"copy_from": "labels.gc",
"override": false,
"if": "ctx.labels?.gc != null"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
"name": "logs-apm.error-0.1.0-apm_error_grouping_name",
"if": "ctx.processor?.event == 'error'"
}
},
{
"pipeline": {
"name": "logs-apm.error-0.1.0-apm_opentelemetry_metrics",
"if": "ctx.processor?.event == 'metric'"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"description": "Populate Elastic APM metric fields from well-known OpenTelemetry metric counterparts",
"processors": [
{
"set": {
"field": "jvm.memory.{{labels.area}}.{{labels.type}}",
"copy_from": "runtime.jvm.memory.area",
"if": "ctx.runtime?.jvm?.memory?.area != null && ctx.labels?.area != null && ctx.labels?.type != null"
}
},
{
"set": {
"field": "jvm.gc.time",
"copy_from": "runtime.jvm.gc.time",
"if": "ctx.runtime?.jvm?.gc?.time != null"
}
},
{
"set": {
"field": "jvm.gc.count",
"copy_from": "runtime.jvm.gc.count",
"if": "ctx.runtime?.jvm?.gc?.count != null"
}
},
{
"set": {
"field": "jvm.gc.time",
"copy_from": "runtime.jvm.gc.collection",
"if": "ctx.runtime?.jvm?.gc?.collection != null"
}
},
{
"set": {
"field": "labels.name",
"copy_from": "labels.gc",
"override": false,
"if": "ctx.labels?.gc != null"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
"name": "metrics-apm.internal-0.1.0-apm_error_grouping_name",
"if": "ctx.processor?.event == 'error'"
}
},
{
"pipeline": {
"name": "metrics-apm.internal-0.1.0-apm_opentelemetry_metrics",
"if": "ctx.processor?.event == 'metric'"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"description": "Populate Elastic APM metric fields from well-known OpenTelemetry metric counterparts",
"processors": [
{
"set": {
"field": "jvm.memory.{{labels.area}}.{{labels.type}}",
"copy_from": "runtime.jvm.memory.area",
"if": "ctx.runtime?.jvm?.memory?.area != null && ctx.labels?.area != null && ctx.labels?.type != null"
}
},
{
"set": {
"field": "jvm.gc.time",
"copy_from": "runtime.jvm.gc.time",
"if": "ctx.runtime?.jvm?.gc?.time != null"
}
},
{
"set": {
"field": "jvm.gc.count",
"copy_from": "runtime.jvm.gc.count",
"if": "ctx.runtime?.jvm?.gc?.count != null"
}
},
{
"set": {
"field": "jvm.gc.time",
"copy_from": "runtime.jvm.gc.collection",
"if": "ctx.runtime?.jvm?.gc?.collection != null"
}
},
{
"set": {
"field": "labels.name",
"copy_from": "labels.gc",
"override": false,
"if": "ctx.labels?.gc != null"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
"name": "metrics-apm.profiling-0.1.0-apm_error_grouping_name",
"if": "ctx.processor?.event == 'error'"
}
},
{
"pipeline": {
"name": "metrics-apm.profiling-0.1.0-apm_opentelemetry_metrics",
"if": "ctx.processor?.event == 'metric'"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"description": "Populate Elastic APM metric fields from well-known OpenTelemetry metric counterparts",
"processors": [
{
"set": {
"field": "jvm.memory.{{labels.area}}.{{labels.type}}",
"copy_from": "runtime.jvm.memory.area",
"if": "ctx.runtime?.jvm?.memory?.area != null && ctx.labels?.area != null && ctx.labels?.type != null"
}
},
{
"set": {
"field": "jvm.gc.time",
"copy_from": "runtime.jvm.gc.time",
"if": "ctx.runtime?.jvm?.gc?.time != null"
}
},
{
"set": {
"field": "jvm.gc.count",
"copy_from": "runtime.jvm.gc.count",
"if": "ctx.runtime?.jvm?.gc?.count != null"
}
},
{
"set": {
"field": "jvm.gc.time",
"copy_from": "runtime.jvm.gc.collection",
"if": "ctx.runtime?.jvm?.gc?.collection != null"
}
},
{
"set": {
"field": "labels.name",
"copy_from": "labels.gc",
"override": false,
"if": "ctx.labels?.gc != null"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
"name": "traces-apm-0.1.0-apm_error_grouping_name",
"if": "ctx.processor?.event == 'error'"
}
},
{
"pipeline": {
"name": "traces-apm-0.1.0-apm_opentelemetry_metrics",
"if": "ctx.processor?.event == 'metric'"
}
}
]
}
50 changes: 50 additions & 0 deletions ingest/pipeline/definition.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
"name": "apm_error_grouping_name",
"if": "ctx.processor?.event == 'error'"
}
},
{
"pipeline": {
"name": "apm_opentelemetry_metrics",
"if": "ctx.processor?.event == 'metric'"
}
}
]
}
Expand Down Expand Up @@ -137,5 +143,49 @@
}
]
}
},
{
"id": "apm_opentelemetry_metrics",
"body": {
"description": "Populate Elastic APM metric fields from well-known OpenTelemetry metric counterparts",
"processors": [
{
"set": {
"field": "jvm.memory.{{labels.area}}.{{labels.type}}",
"copy_from": "runtime.jvm.memory.area",
"if": "ctx.runtime?.jvm?.memory?.area != null && ctx.labels?.area != null && ctx.labels?.type != null"
}
},
{
"set": {
"field": "jvm.gc.time",
"copy_from": "runtime.jvm.gc.time",
"if": "ctx.runtime?.jvm?.gc?.time != null"
}
},
{
"set": {
"field": "jvm.gc.count",
"copy_from": "runtime.jvm.gc.count",
"if": "ctx.runtime?.jvm?.gc?.count != null"
}
},
{
"set": {
"field": "jvm.gc.time",
"copy_from": "runtime.jvm.gc.collection",
"if": "ctx.runtime?.jvm?.gc?.collection != null"
}
},
{
"set": {
"field": "labels.name",
"copy_from": "labels.gc",
"override": false,
"if": "ctx.labels?.gc != null"
}
}
]
}
}
]
35 changes: 35 additions & 0 deletions ingest/pipeline/definition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ apm:
- pipeline:
name: apm_error_grouping_name
if: ctx.processor?.event == 'error'
- pipeline:
name: apm_opentelemetry_metrics
if: ctx.processor?.event == 'metric'

apm_user_agent:
description: Add user agent information for APM events
Expand Down Expand Up @@ -74,3 +77,35 @@ apm_error_grouping_name:
field: error.grouping_name
copy_from: error.log.message
if: ctx.error?.log?.message != null

apm_opentelemetry_metrics:
description: Populate Elastic APM metric fields from well-known OpenTelemetry metric counterparts
processors:
- set:
# Copy `runtime.jvm.memory.area` (OpenTelemetry) to `jvm.memory.{area}.{type}` (Elastic APM).
field: jvm.memory.{{labels.area}}.{{labels.type}}
copy_from: runtime.jvm.memory.area
if: ctx.runtime?.jvm?.memory?.area != null && ctx.labels?.area != null && ctx.labels?.type != null
- set:
# Copy `runtime.jvm.gc.time` (OpenTelemetry) to `jvm.gc.time` (Elastic APM).
# Both are defined in milliseconds.
field: jvm.gc.time
copy_from: runtime.jvm.gc.time
if: ctx.runtime?.jvm?.gc?.time != null
- set:
# Copy `runtime.jvm.gc.count` (OpenTelemetry) to `jvm.gc.count` (Elastic APM).
field: jvm.gc.count
copy_from: runtime.jvm.gc.count
if: ctx.runtime?.jvm?.gc?.count != null
- set:
# Copy `runtime.jvm.gc.collection` (OpenTelemetry) to `jvm.gc.time` (Elastic APM).
# Both are defined in milliseconds. This is the old name for `runtime.jvm.gc.time`.
field: jvm.gc.time
copy_from: runtime.jvm.gc.collection
if: ctx.runtime?.jvm?.gc?.collection != null
- set:
# Copy `labels.gc` (OpenTelemetry) to `labels.name` (Elastic APM), for jvm.gc.{time,count}.
field: labels.name
copy_from: labels.gc
override: false # don't replace existing labels.name field, if any
if: ctx.labels?.gc != null
Loading

0 comments on commit 7190052

Please sign in to comment.