Skip to content

Commit baa3937

Browse files
authored
[azure] rename azure.platformlogs.properties as .raw when it contains a string value (#11732)
Mitigates #11729 If the `azure.platformlogs.properties` field contains a string instead of the expected object, the pipeline renames it as `azure.platformlogs.properties.raw` field. This allows: - Elasticsearch to index the log events instead of dropping them (status 400) - Users to customize parsing of the `.raw` field in the `logs-azure.platformlogs@custom pipeline` This avoids dropping log events while we build a complete and more robust [invalid JSON](#11729) handling solution with #11728
1 parent deaf575 commit baa3937

File tree

5 files changed

+57
-1
lines changed

5 files changed

+57
-1
lines changed

packages/azure/changelog.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
- version: "1.19.2"
2+
changes:
3+
- description: Rename the `properties` field to `properties.raw` to avoid parse errors when the `properties` field contains a string.
4+
type: bugfix
5+
link: https://github.com/elastic/integrations/pull/11732
16
- version: "1.19.1"
27
changes:
38
- description: Fix an error and clarify the docs about the Storage Account container.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"time": "2023-03-07T22:19:49Z","resourceId": "/SUBSCRIPTIONS/0E073EC1-C22F-4488-ADDE-DA35ED609CCD/RESOURCEGROUPS/MBRANCA-MALFORMED-JSON-RG/PROVIDERS/MICROSOFT.WEB/SITES/MBRANCA-HELLO-WORLD2","category": "FunctionAppLogs","operationName": "Microsoft.Web/sites/functions/log","level": "Informational","location": "East US","properties": "{'appName':'mbranca-hello-world2','roleInstance':'A6CE8668-638138213605792171','message':'Executing Functions.hello (Reason=This function was programmatically called via the host APIs., Id=0738eec6-ad5e-48f9-a949-5ac36ba84161)','category':'Function.hello','hostVersion':'4.15.1.1','functionInvocationId':'0738eec6-ad5e-48f9-a949-5ac36ba84161','functionName':'Functions.hello','hostInstanceId':'9eb66127-a244-467e-b6a2-01879ad19da2','level':'Information','levelId': 2,'processId': 55,'eventId': 1,'eventName':'FunctionStarted'}"}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"expected": [
3+
{
4+
"@timestamp": "2023-03-07T22:19:49.000Z",
5+
"azure": {
6+
"platformlogs": {
7+
"category": "FunctionAppLogs",
8+
"event_category": "Administrative",
9+
"operation_name": "Microsoft.Web/sites/functions/log",
10+
"properties": {
11+
"raw": "{'appName':'mbranca-hello-world2','roleInstance':'A6CE8668-638138213605792171','message':'Executing Functions.hello (Reason=This function was programmatically called via the host APIs., Id=0738eec6-ad5e-48f9-a949-5ac36ba84161)','category':'Function.hello','hostVersion':'4.15.1.1','functionInvocationId':'0738eec6-ad5e-48f9-a949-5ac36ba84161','functionName':'Functions.hello','hostInstanceId':'9eb66127-a244-467e-b6a2-01879ad19da2','level':'Information','levelId': 2,'processId': 55,'eventId': 1,'eventName':'FunctionStarted'}"
12+
}
13+
},
14+
"resource": {
15+
"group": "MBRANCA-MALFORMED-JSON-RG",
16+
"id": "/SUBSCRIPTIONS/0E073EC1-C22F-4488-ADDE-DA35ED609CCD/RESOURCEGROUPS/MBRANCA-MALFORMED-JSON-RG/PROVIDERS/MICROSOFT.WEB/SITES/MBRANCA-HELLO-WORLD2",
17+
"name": "MBRANCA-HELLO-WORLD2",
18+
"provider": "MICROSOFT.WEB/SITES"
19+
},
20+
"subscription_id": "0E073EC1-C22F-4488-ADDE-DA35ED609CCD"
21+
},
22+
"cloud": {
23+
"provider": "azure"
24+
},
25+
"ecs": {
26+
"version": "8.11.0"
27+
},
28+
"event": {
29+
"action": "Microsoft.Web/sites/functions/log",
30+
"kind": "event",
31+
"original": "{\"time\": \"2023-03-07T22:19:49Z\",\"resourceId\": \"/SUBSCRIPTIONS/0E073EC1-C22F-4488-ADDE-DA35ED609CCD/RESOURCEGROUPS/MBRANCA-MALFORMED-JSON-RG/PROVIDERS/MICROSOFT.WEB/SITES/MBRANCA-HELLO-WORLD2\",\"category\": \"FunctionAppLogs\",\"operationName\": \"Microsoft.Web/sites/functions/log\",\"level\": \"Informational\",\"location\": \"East US\",\"properties\": \"{'appName':'mbranca-hello-world2','roleInstance':'A6CE8668-638138213605792171','message':'Executing Functions.hello (Reason=This function was programmatically called via the host APIs., Id=0738eec6-ad5e-48f9-a949-5ac36ba84161)','category':'Function.hello','hostVersion':'4.15.1.1','functionInvocationId':'0738eec6-ad5e-48f9-a949-5ac36ba84161','functionName':'Functions.hello','hostInstanceId':'9eb66127-a244-467e-b6a2-01879ad19da2','level':'Information','levelId': 2,'processId': 55,'eventId': 1,'eventName':'FunctionStarted'}\"}"
32+
},
33+
"geo": {
34+
"name": "East US"
35+
},
36+
"log": {
37+
"level": "Informational"
38+
},
39+
"tags": [
40+
"preserve_original_event"
41+
]
42+
}
43+
]
44+
}

packages/azure/data_stream/platformlogs/elasticsearch/ingest_pipeline/default.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ processors:
5454
field: tags
5555
value: ["preserve_original_event"]
5656
ignore_failure: true
57+
- rename:
58+
field: azure.platformlogs.properties
59+
if: "ctx.azure?.platformlogs?.properties instanceof String"
60+
target_field: azure.platformlogs.properties.raw
61+
ignore_missing: true
62+
description: 'Rename the field to `properties.raw` to avoid parse errors with the `properties` containing a string.'
5763
- rename:
5864
field: azure.platformlogs.identity
5965
if: "ctx.azure?.platformlogs?.identity instanceof String"

packages/azure/manifest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: azure
22
title: Azure Logs
3-
version: 1.19.1
3+
version: 1.19.2
44
description: This Elastic integration collects logs from Azure
55
type: integration
66
icons:

0 commit comments

Comments
 (0)