Skip to content

Conversation

@ykitamura-mdsol
Copy link
Contributor

Background

All of AWS Batch logs are sent to one log group, /aws/batch/job, and the log stream name format is jobDefinitionName/default/ecs_task_id:
https://docs.aws.amazon.com/batch/latest/userguide/job_states.html

Changes

In order to stream logs of specific AWS Batch jobs to SumoLogic, this PR is adding log stream name prefix filtering for CloudWatch logs

* SOURCE_NAME_OVERRIDE (OPTIONAL) - Override _sourceName metadata field within SumoLogic.
* INCLUDE_LOG_INFO (OPTIONAL) - Set it to true when loggroup/logstream values needs to be included in logs. Default is false
* LOG_FORMAT - Default is Others. One can choose VPC-JSON for VPC flow logs in json format and VPC-RAW for only RAW message line
* LOG_STREAM_PREFIX (OPTIONAL) - Comma separated list of logStream name prefixes to filter by logStream, expecially for AWS Batch logs

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"especially"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in cc67fdb

"includeSecurityGroupInfo": ("INCLUDE_SECURITY_GROUP_INFO" in env) ? env.INCLUDE_SECURITY_GROUP_INFO === "true" : false,
// Regex to filter by logStream name prefixes
"logStreamPrefixRegex": ("LOG_STREAM_PREFIX" in env)
? new RegExp('^(' + env.LOG_STREAM_PREFIX.replace(/,/g, '|') + ')', 'i')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you might want to escape the values from the CSV, unsure the range of characters that you're allowed to use but any regex modifier that might be in one of the items would corrupt the final regex.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in bd4b656

@ykitamura-mdsol ykitamura-mdsol changed the title Add log stream name prefix filtering, expecially for AWS Batch logs Add log stream name prefix filtering, especially for AWS Batch logs Sep 11, 2019
@ykitamura-mdsol
Copy link
Contributor Author

@himanshu219, could you please review this PR?

Copy link
Contributor

@himanshu219 himanshu219 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM I think we can add this variable in Cloudformation template as well. what do you think?

@ykitamura-mdsol
Copy link
Contributor Author

Good idea 💡 Added the variable in e64128c

@himanshu219
Copy link
Contributor

Thanks

@himanshu219 himanshu219 merged commit 253ccc6 into SumoLogic:master Sep 18, 2019
@ykitamura-mdsol ykitamura-mdsol deleted the feature/log_stream_filter branch September 18, 2019 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants