This serverless app publishes AWS CloudWatch logs to Slack based on a subscription filter. This differs from Keeton Hodgson's by using a different lamda-to-slack mechanism that allows for basic text comparison to determine the webhook to use. This is useful in the case that you want to split slack data out based on different text that might appear (for example, send DEBUG output to one channel, and ERROR output to another.)
- Create an AWS account if you do not already have one and login
- Go to the app's page on the Serverless Application Repository and click "Deploy"
- Provide the required app parameters (see parameter details below) and click "Deploy"
To get a webhook URL for this application:
- Navigate to https://api.slack.com
- Click on the "Start Building" button
- Give your app a name and select a workspace
- Under "Add features and functionality" select "Incoming Webhooks"
- Turn on "Incoming Webhooks" and click "Add New Webhook to Workspace"
- Select the desired channel and click "Authorize"
- Copy the generated Webhook URL
You can find the name of the log group by navigating to CloudWatch logs on the AWS console. You can also pass it in as a parameter from another stack or another resource (e.g. default lambda log group names are /aws/lambda/{lambda-function-name}
).
CloudWatch logs allow you to filter logs based on a pattern. For more information, see the AWS Documentation.
SlackUrl
(required) - Webhook URL for integration with SlackLogGroupName
(required) - Log group to listen to (has to be in same account and region)FilterPattern
(optional) - Pattern for filtering log events. Default: ERROROnlySendLogMessage
(optional) - Option to only send log message instead of all message, id, and timestamp information. Default: False. Values: False, TrueLogLevel
(optional) - Log level for Lambda function logging, e.g., ERROR, INFO, DEBUG, etc. Default: INFOSlackUrl01
(optional) - Webhook URL for integration with Slack (if messages match ContainsString01)ContainsString01
(optional) - A string that, if present in the message, dictates that the message should be logged to SlackUrl01SlackUrl02
(optional) - Webhook URL for integration with Slack (if messages match ContainsString02)ContainsString02
(optional) - A string that, if present in the message, dictates that the message should be logged to SlackUrl02SlackUrl03
(optional) - Webhook URL for integration with Slack (if messages match ContainsString03)ContainsString03
(optional) - A string that, if present in the message, dictates that the message should be logged to SlackUrl03SlackUrl04
(optional) - Webhook URL for integration with Slack (if messages match ContainsString04)ContainsString04
(optional) - A string that, if present in the message, dictates that the message should be logged to SlackUrl04SlackUrl05
(optional) - Webhook URL for integration with Slack (if messages match ContainsString05)ContainsString05
(optional) - A string that, if present in the message, dictates that the message should be logged to SlackUrl05
LogsToLambdaName
- Log Lambda Function NameLogsToLambdaArn
- Log Lambda Function ARNLambdaToSlackName
- Slack Lambda Function NameLambdaToSlackArn
- Slack Lambda Function ARN
This code is made available under the MIT license. See the LICENSE file.
If you would like to see a version of this application that uses code instead of other applications, see the 0.0.1 Release.