dynatrace-oss / dynatrace-azure-log-forwarder

This project provides a mechanism that allows streaming Azure logs from Azure Event Hub into Dynatrace Logs via Azure Function App. It supports both: Azure Resource Logs and Azure Activity Logs.
https://www.dynatrace.com/support/help/technology-support/cloud-platforms/microsoft-azure-services/set-up-log-forwarder-azure/
Apache License 2.0
21 stars 16 forks source link

APM-362864 Throttling handling of logging was fixed #50

Closed IrynaKudlaienko closed 2 years ago

IrynaKudlaienko commented 2 years ago

Throttling handling of logging was fixed, JSONDecodeError handling was added

sonarcloud[bot] commented 2 years ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

mswiatkowska commented 2 years ago

Could you paste here example of log with JSONDecodeError after your changes?

IrynaKudlaienko commented 2 years ago

The example of log with JSONDecodeError:

2022-04-04T10:52:20.987 [Error] [0.0.2] Failed to decode JSON for the record:
{'level': 'Informational', 'resourceId': '/SUBSCRIPTIONS/69B51384-146C-4685-9DAB-5AE01877D7B8/RESOURCEGROUPS/LOGS-INGEST-FUNCTION/PROVIDERS/MICROSOFT.WEB/SITES/IK-LOG-FORWARDER-FUNCTION', 'operationName': 'Microsoft.Web/sites/functions/log', 'category': 'FunctionAppLogs', 'time': '04/04/2022 10:51:02', 'properties': "{'appName':'ik-log-forwarder-function','roleInstance':'2b261bc217ca563c1dbab7acbf33b1bfe0d40640c43abfd5946eaec8d2ce0295','message':'Host Status: {\\n  \\'id\\': \\'ik-log-forwarder-function\\',\\n  \\'state\\': \\'Running\\',\\n  \\'version\\': \\'3.5.2.0\\',\\n  \\'versionDetails\\': \\'3.5.2-2 Commit hash: 76ad447706084a3cd4232cc7c1fa78367625c407\\',\\n  \\'platformVersion\\': \\'97.0.7.625\\',\\n  \\'instanceId\\': \\'2b261bc217ca563c1dbab7acbf33b1bfe0d40640c43abfd5946eaec8d2ce0295\\',\\n  \\'computerName\\': \\'lw1sdlwk0007DK\\',\\n  \\'processUptime\\': 888376,\\n  \\'functionAppContentEditingState\\': \\'Unknown\\',\\n  \\'extensionBundle\\': {\\n    \\'id\\': \\'Microsoft.Azure.Functions.ExtensionBundle\\',\\n    \\'version\\': \\'1.8.1\\'\\n  }\\n}','category':'Host.Controllers.Host','hostVersion':'3.5.2.0','hostInstanceId':'cbecc789-3cb0-444d-bdce-c0a0d9bff1fc','level':'Information','levelId':2,'processId':24}", 'EventStampType': 'Stamp', 'EventPrimaryStampName': 'waws-prod-am2-373', 'EventStampName': 'waws-prod-am2-373', 'Host': 'lw1sdlwk0007DK', 'EventIpAddress': '10.51.0.105'}
The reason:
Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
Traceback (most recent call last):
  File "/home/site/wwwroot/logs_ingest/main.py", line 68, in process_logs
    process_record(dt_payload, record, self_monitoring)
  File "/home/site/wwwroot/logs_ingest/main.py", line 92, in process_record
    deserialize_properties(record)
  File "/home/site/wwwroot/logs_ingest/main.py", line 121, in deserialize_properties
    record["properties"] = json.loads(properties)
  File "/usr/local/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.8/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)