amazon-cloudwatch-agent icon indicating copy to clipboard operation
amazon-cloudwatch-agent copied to clipboard

multi_line_start_pattern value should be validated on launch

Open motooka opened this issue 2 years ago • 1 comments

Describe the bug When a user uses a malformed regexp as multi_line_start_pattern value, the command exists successfully but logs are not submitted to CloudWatch Logs.

Steps to reproduce

  • create a configuration file, with multi_line_start_pattern setting for a log, but the multi_line_start_pattern value is not a correct regexp.
  • execute /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json as a root user

What did you expect to see?

  • the command amazon-cloudwatch-agent-ctl exits with non-zero status code
  • the command amazon-cloudwatch-agent-ctl DOES NOT say Configuration validation succeeded

What did you see instead?

  • the command amazon-cloudwatch-agent-ctl exits with 0 status code
  • the command amazon-cloudwatch-agent-ctl DOES say Configuration validation succeeded
  • the log file /opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log is filled with a log message W! [inputs.logfile] not started with file state folder %s/opt/aws/amazon-cloudwatch-agent/logs/state. This log entry comes every seconds.

What version did you use? Version: 1.300031.0b313

What config did you use? logs section

"logs": {
	"logs_collected": {
		"files": {
			"collect_list": [
				{
					"file_path": "/var/log/foo.log",
					"log_group_name": "foolog",
					"log_stream_name": "{instance_id}",
					"multi_line_start_pattern": "*",
					"retention_in_days": -1
				}
			]
		}
	}
},

Environment OS: Ubuntu 22.04 on EC2

Additional context

  • if the multi_line_start_pattern value is an empty string, the validation process fails as expected.
  • current documentation does not provide any example for multi_line_start_pattern regexp. I guess some examples in this document might also be effective to prevent users from wasting long time.

motooka avatar Nov 23 '23 12:11 motooka

This issue was marked stale due to lack of activity.

github-actions[bot] avatar Feb 22 '24 00:02 github-actions[bot]

Closing this because it has stalled. Feel free to reopen if this issue is still relevant, or to ping the collaborator who labeled it stalled if you have any questions.

github-actions[bot] avatar Mar 24 '24 00:03 github-actions[bot]