[8.x](backport #40742) azure-eventhub: expand input sanitizer's invalid JSON coverage #40854
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed commit message
replace_allsanitizerinvalid_json_messages_totalinput metric to count the number of messages that contain invalid JSON strings.The
replace_allsanitizer replaces all the occurrences of substring matching the regex expressionpatternwith a fixed literal stringreplacement.Here is a sample configuration:
For example, if the diagnostic settings send the following message:
{ "AppImage": "orcas/postgres_standalone_16_u18:38.1.240825", "AppType": "PostgreSQL", "properties": [ 218 B blob data ] }With the previous sample configuration, the input will replace the invalid JSON, updating the message to the following version:
{ "AppImage": "orcas/postgres_standalone_16_u18:38.1.240825", "AppType": "PostgreSQL", "properties": {} }The
replace_allsanitizer aims to restore JSON syntax validity by replacing invalid, unfixable JSON with literal values that make sense for the context.The invalid JSON sanitization became a thing when we faced Azure services producing malformed JSON documents.
Here is a list of previous occurrences of this problem:
In all cases, we first reached out to Azure support, but they didn't fix the invalid JSON.
Checklist
CHANGELOG.next.asciidocorCHANGELOG-developer.next.asciidoc.Disruptive User Impact
Author's Checklist
How to test this PR locally
Related issues
Use cases
Screenshots
Logs
This is an automatic backport of pull request #40742 done by [Mergify](https://mergify.com).