Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[azure-evenhub input] fail to process AppServicePlatformLogs due to unescaped newlines #34092

Closed
zmoog opened this issue Dec 21, 2022 · 1 comment · Fixed by #34874
Closed
Labels
Team:Cloud-Monitoring Label for the Cloud Monitoring team

Comments

@zmoog
Copy link
Contributor

zmoog commented Dec 21, 2022

  • Version: any
  • Operating System: any

Some events from the AppServicePlatformLogs log category can contain one or more newline characters (\n).

Here's an example received export from a Diagnostic Setting to an Event Hub:

"{\"records\": [{ \"time\": \"2022-12-17T20:21:24.4331338Z\", \n \"resourceId\": \"/SUBSCRIPTIONS/5AEB8557-CAB7-41AC-8603-9F94AD233EFC/RESOURCEGROUPS/GT-WEU-GTP-CORE-DEV-RSG/PROVIDERS/MICROSOFT.WEB/SITES/AppService-Redacted\", \"category\": \"AppServicePlatformLogs\", \"operationName\": \"AutoHealingLogEvent\", \"level\": \"Informational\", \"resultDescription\": \"Worker Process serving application pool 'AppService-Redacted' hit the 'Total Requests' limit.\\n\", \"properties\": {\"message\":\"Worker Process serving application pool 'AppService-Redacted' hit the 'Total Requests' limit.\n\"}}]}"

The message attribute contains a \n in this example.

Then this string is unmarshaled, we get an error:

package main

import (
	"encoding/json"
	"fmt"
)

func main() {
	var mapObject map[string][]interface{}
	message := "{\"records\": [{ \"time\": \"2022-12-17T20:21:24.4331338Z\", \n \"resourceId\": \"/SUBSCRIPTIONS/5AEB8557-CAB7-41AC-8603-9F94AD233EFC/RESOURCEGROUPS/GT-WEU-GTP-CORE-DEV-RSG/PROVIDERS/MICROSOFT.WEB/SITES/AppService-Redacted\", \"category\": \"AppServicePlatformLogs\", \"operationName\": \"AutoHealingLogEvent\", \"level\": \"Informational\", \"resultDescription\": \"Worker Process serving application pool 'AppService-Redacted' hit the 'Total Requests' limit.\\n\", \"properties\": {\"message\":\"Worker Process serving application pool 'AppService-Redacted' hit the 'Total Requests' limit.\n\"}}]}"

	bMessage := []byte(message)
	err := json.Unmarshal(bMessage, &mapObject)
	if err != nil {
		fmt.Println(err)
                return
	}

	fmt.Println(mapObject)
}

The result is:

invalid character '\n' in string literal
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Dec 21, 2022
@zmoog zmoog added the Team:Cloud-Monitoring Label for the Cloud Monitoring team label Dec 21, 2022
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Dec 21, 2022
@zmoog
Copy link
Contributor Author

zmoog commented Dec 23, 2022

In general, the azure-eventhub input may have an issue handling event hub message payloads that are not strings containing well-formed JSON documents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Cloud-Monitoring Label for the Cloud Monitoring team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant