Log output contains extra newlines
We log to journald on our instances, and have been trying to configure the SSM agent to log to JSON for easier parsing and ingestion into our various log platforms. It appears that in numerous places, nested JSON response payloads are run through jsonutil.Indent() before being logged.
This example is caused by https://github.com/aws/amazon-ssm-agent/blob/master/agent/runcommand/service.go#L209:
Apr 22 18:38:58 hostname.foo.bar amazon-ssm-agent[5696]: {"time":1587580737774566385,"level":"INFO","message":"[MessageGatewayService] Sending reply {
Apr 22 18:38:58 hostname.foo.bar amazon-ssm-agent[5696]: "SchemaVersion": 1,
Apr 22 18:38:58 hostname.foo.bar amazon-ssm-agent[5696]: "TaskId": "[redacted]",
Apr 22 18:38:58 hostname.foo.bar amazon-ssm-agent[5696]: "Topic": "agent_task_complete",
Apr 22 18:38:58 hostname.foo.bar amazon-ssm-agent[5696]: "FinalTaskStatus": "Failed",
Apr 22 18:38:58 hostname.foo.bar amazon-ssm-agent[5696]: "IsRoutingFailure": false,
Apr 22 18:38:58 hostname.foo.bar amazon-ssm-agent[5696]: "AwsAccountId": "",
Apr 22 18:38:58 hostname.foo.bar amazon-ssm-agent[5696]: "InstanceId": "i-[redacted]",
Apr 22 18:38:58 hostname.foo.bar amazon-ssm-agent[5696]: "Output": "\n----------ERROR-------\nSetting up data channel with id [redacted] failed: failed to create websocket
Apr 22 18:38:58 hostname.foo.bar amazon-ssm-agent[5696]: "S3Bucket": "",
Apr 22 18:38:58 hostname.foo.bar amazon-ssm-agent[5696]: "S3UrlSuffix": "",
Apr 22 18:38:58 hostname.foo.bar amazon-ssm-agent[5696]: "CwlGroup": "",
Apr 22 18:38:58 hostname.foo.bar amazon-ssm-agent[5696]: "CwlStream": ""
Apr 22 18:38:58 hostname.foo.bar amazon-ssm-agent[5696]: }","func":"buildAgentTaskComplete"}
This is quite frustrating, as every newline in the indented payload results in a separate log line in the journal, and prevents our logging platform from simply ingesting the JSON. I do not believe this to be an issue with our seelog configuration, as this would likely occur for any configuration when using journald.
Also an issue is that other special characters (like quotes) in the message are not being escaped, resulting in malformed JSON.
Thank you for bringing this to our attention. We have taken a note of this.