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

Detect And Skip Subscribing To Own Log Group #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions src/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,25 @@ def create_subscription(log_client, log_group_name, humio_log_ingester_arn, cont
# We cannot subscribe to the log group that our stdout/err goes to.
if context.log_group_name == log_group_name:
logger.debug("Skipping our own log group name...")
return

# And we do not want to subscribe to other Humio log ingesters - if there are any.
if "HumioCloudWatchLogsIngester" in log_group_name:
logger.debug("Skipping cloudwatch2humio ingesters...")
else:
logger.info("Creating subscription for %s" % log_group_name)
try:
log_client.put_subscription_filter(
logGroupName=log_group_name,
filterName="%s-humio_ingester" % log_group_name,
filterPattern="", # Matching everything.
destinationArn=humio_log_ingester_arn,
distribution="ByLogStream"
)
logger.debug("Successfully subscribed to %s!" % log_group_name)
except Exception as exception:
logger.error("Error creating subscription to %s. Exception: %s" % (log_group_name, exception))
return

logger.info("Creating subscription for %s" % log_group_name)
try:
log_client.put_subscription_filter(
logGroupName=log_group_name,
filterName="%s-humio_ingester" % log_group_name,
filterPattern="", # Matching everything.
destinationArn=humio_log_ingester_arn,
distribution="ByLogStream"
)
logger.debug("Successfully subscribed to %s!" % log_group_name)
except Exception as exception:
logger.error("Error creating subscription to %s. Exception: %s" % (log_group_name, exception))


def delete_subscription(log_client, log_group_name, filter_name):
Expand Down