Skip to content

Commit 9f229f0

Browse files
spurgeatoulme
andauthored
[receiver/azureeventhub] Implements support to ingest app metrics (#41367)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description * Extends the metrics unmarshaler with support for parsing metrics with type "AppMetrics" forwarded from Application Insights * Moves the appending of attributes into each record, as if there could be records from multiple resources within the same payload * Implements an optional average aggregator, configured in the component config <!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes #41343 <!--Describe what testing was performed and which tests were added.--> #### Testing Tests added for the parsing of both resource and app metrics. Maybe not of value for you, but tested in my development environment in Azure, receiving metrics from remote tenants and exporting to a managed prometheus data collection rule using the Prometheus remote writer exporter. <!--Describe the documentation added.--> #### Documentation I'm happy to extend the documentation if this code and feature is of any interest <!--Please delete paragraphs that you did not use before submitting.--> --------- Co-authored-by: Antoine Toulme <[email protected]>
1 parent 7bc2652 commit 9f229f0

File tree

8 files changed

+552
-92
lines changed

8 files changed

+552
-92
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: receiver/azureeventhub
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: "Adds support for receiving Azure app metrics from Azure Event Hubs in the azureeventhubreceiver"
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues:
14+
- 41343
15+
- 41367
16+
17+
# (Optional) One or more lines of additional information to render under the primary note.
18+
# These lines will be padded with 2 spaces and then inserted directly into the document.
19+
# Use pipe (|) for multiline entries.
20+
subtext: |
21+
The azureeventhubreceiver now supports receiving custom metrics emitted by applications to Azure Insights and forwarded using Diagnostic Settings to Azure Event Hub.
22+
There's also on optional setting to aggregate received metrics into a single metric to keep the original name, instead of multiply the metrics by added suffixes `_total`, `_sum`, `_max` etc.
23+
24+
# If your change doesn't affect end users or the exported elements of any package,
25+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
26+
# Optional: The change log or logs in which this entry should be included.
27+
# e.g. '[user]' or '[user, api]'
28+
# Include 'user' if the change is relevant to end users.
29+
# Include 'api' if there is a change to a library API.
30+
# Default: '[user]'
31+
change_logs: [user]

receiver/azureeventhubreceiver/README.md

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@
1515
<!-- end autogenerated section -->
1616

1717
## Overview
18+
1819
Azure resources and services can be
1920
[configured](https://learn.microsoft.com/en-us/azure/azure-monitor/essentials/diagnostic-settings)
20-
to send their logs to an Azure Event Hub. The Azure Event Hub receiver pulls logs from an Azure
21+
to send their telemetry to an Azure Event Hub. The Azure Event Hub receiver pulls telemetry from an Azure
2122
Event Hub, transforms them, and pushes them through the collector pipeline.
2223

24+
### Read further
25+
26+
* [Diagnostic settings in Azure Monitor](https://learn.microsoft.com/en-us/azure/azure-monitor/platform/diagnostic-settings?tabs=portal)
27+
* [Stream Azure monitoring data to an event hub and external partner](https://learn.microsoft.com/en-us/azure/azure-monitor/platform/stream-monitoring-data-event-hubs)
28+
2329
## Configuration
2430

2531
### connection (Required)
@@ -58,6 +64,21 @@ All supported time format for logs, metrics and traces. Default is `nil` (unset)
5864

5965
Default: `nil`
6066

67+
### metric_aggregation (optional)
68+
69+
Metric records received from an Azure Event Hub will contain multiple aggregated datapoints. Depending on the
70+
[type of metric](https://learn.microsoft.com/en-us/azure/azure-monitor/metrics/data-platform-metrics#types-of-metrics),
71+
these datapoints will be slightly different, but all contain a total/sum, min, max and count. This setting will manage
72+
these datapoints.
73+
74+
#### Possible values:
75+
76+
* By default, these datapoints will be mapped to metrics named with a corresponding suffix, like `_total`, `_min`, etc.
77+
See [azure format](#azure).
78+
* With `average`, datapoints will be aggregated into an average value (`sum/count`), and keep the original metric name.
79+
80+
Default: `nil`
81+
6182
> [!NOTE]
6283
> You can opt-in to use the [`azeventhubs`](https://github.com/Azure/azure-sdk-for-go/blob/main/sdk/messaging/azeventhubs) sdk by enabling the feature gate
6384
> `receiver.azureeventhubreceiver.UseAzeventhubs` when you run the OpenTelemetry Collector. See the following page
@@ -102,10 +123,13 @@ The "raw" format maps the AMQP properties and data into the
102123
attributes and body of an OpenTelemetry LogRecord, respectively.
103124
The body is represented as a raw byte array.
104125
105-
This format is not supported for Metrics.
126+
> [!WARN]
127+
> This format is not supported for Metrics.
106128
107129
### azure
108130
131+
#### Logs
132+
109133
The "azure" format extracts the Azure log records from the AMQP
110134
message data, parses them, and maps the fields to OpenTelemetry
111135
attributes. The table below summarizes the mapping between the
@@ -137,8 +161,18 @@ Notes:
137161
* JSON does not distinguish between fixed and floating point numbers. All
138162
JSON numbers are encoded as doubles.
139163
164+
#### Metrics
165+
140166
For Metrics the Azure Metric Records are an array
141-
of "records" with the following fields.
167+
of "records" with the following fields, by
168+
[type of metric](https://learn.microsoft.com/en-us/azure/azure-monitor/metrics/data-platform-metrics#types-of-metrics).
169+
170+
From this data a Metric of type Gauge is created
171+
with a Data Points that represents the values
172+
for the Metric including: Total, Minimum, Maximum,
173+
Average and Count.
174+
175+
##### Platform metric (from Azure resources)
142176
143177
| Azure | Open Telemetry |
144178
|------------|---------------------------------------------|
@@ -152,10 +186,28 @@ of "records" with the following fields.
152186
| maximum | mapped to datapoint metricName + "_MAXIMUM" |
153187
| average | mapped to datapoint metricName + "_AVERAGE" |
154188
155-
From this data a Metric of type Gauge is created
156-
with a Data Points that represents the values
157-
for the Metric including: Total, Minimum, Maximum,
158-
Average and Count.
189+
##### Application metrics (from Application Insights)
190+
191+
See: https://learn.microsoft.com/en-us/azure/azure-monitor/reference/tables/appmetrics
192+
193+
| Azure | Open Telemetry |
194+
|----------------------------|---------------------------------------------|
195+
| time | time_unix_nano (field) |
196+
| resourceId | azure.resource.id (resource attribute) |
197+
| Name | (metric name) |
198+
| AppRoleInstance | service.instance.id (resource attribute) |
199+
| AppRoleName | service.name (resource attribute) |
200+
| AppVersion | service.version (resource attribute) |
201+
| SDKVersion | telemetry.sdk.version (resource attribute) |
202+
| ClientCountryOrRegion | cloud.region (resource attribute) |
203+
| ClientOS | os.name (resource attribute) |
204+
| Properties (key/value map) | mapped to resource attributes |
205+
| Sum | mapped to datapoint metricName + "_TOTAL" |
206+
| ItemCount | mapped to datapoint metricName + "_COUNT" |
207+
| Min | mapped to datapoint metricName + "_MINIMUM" |
208+
| Max | mapped to datapoint metricName + "_MAXIMUM" |
209+
210+
#### Traces
159211
160212
Traces based on Azure Application Insights array of records from `AppRequests` & `AppDependencies` with the following fields.
161213

0 commit comments

Comments
 (0)