Closed IrynaKudlaienko closed 2 years ago
Kudos, SonarCloud Quality Gate passed!
0 Bugs
0 Vulnerabilities
0 Security Hotspots
0 Code Smells
No Coverage information
0.0% Duplication
Could you paste here example of log with JSONDecodeError after your changes?
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)
Throttling handling of logging was fixed, JSONDecodeError handling was added