{"id":13626420,"url":"https://github.com/TheDesignium/cdk-log-notifier","last_synced_at":"2025-04-16T14:33:28.969Z","repository":{"id":110995545,"uuid":"275123252","full_name":"TheDesignium/cdk-log-notifier","owner":"TheDesignium","description":"Collect and filter CloudWatch logs and post to Slack.","archived":false,"fork":false,"pushed_at":"2025-04-01T02:01:46.000Z","size":657,"stargazers_count":44,"open_issues_count":3,"forks_count":3,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-04-07T15:51:22.575Z","etag":null,"topics":["aws-cdk","aws-cdk-construct","aws-cloudwatch","aws-cloudwatch-logs","aws-lambda","cdk","cdk-constructs","cloudwatch","cloudwatch-logs","javascript","lambda","slack","slack-bot","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TheDesignium.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-26T09:50:18.000Z","updated_at":"2025-03-07T03:53:57.000Z","dependencies_parsed_at":"2024-11-08T16:35:18.538Z","dependency_job_id":"945d8f36-7c81-4bf9-be45-a85b968c2919","html_url":"https://github.com/TheDesignium/cdk-log-notifier","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheDesignium%2Fcdk-log-notifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheDesignium%2Fcdk-log-notifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheDesignium%2Fcdk-log-notifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheDesignium%2Fcdk-log-notifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheDesignium","download_url":"https://codeload.github.com/TheDesignium/cdk-log-notifier/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249250820,"owners_count":21237961,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-cdk","aws-cdk-construct","aws-cloudwatch","aws-cloudwatch-logs","aws-lambda","cdk","cdk-constructs","cloudwatch","cloudwatch-logs","javascript","lambda","slack","slack-bot","typescript"],"created_at":"2024-08-01T21:02:17.919Z","updated_at":"2025-04-16T14:33:28.530Z","avatar_url":"https://github.com/TheDesignium.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# cdk-log-notifier: Filter CloudWatch logs and post to Slack.\n\nThe AWS CDK Construct to build a system that gather CloudWatch logs, filter and post to Slack.\n\n![screenshot](https://i.imgur.com/Qx2A9n2.png)\n\n## Example Usage\n\nWatch the all logs contains \"ERROR\" from Lambda functions.\n\n```typescript\nconst logNotifier = new LogNotifier(this, 'logNotifier', {\n  filterPattern: logs.FilterPattern.allTerms('ERROR'),\n  slackIncomingWebhookUrl: 'https://hooks.slack.com/...', // Use yours.\n});\n\nlogNotifier.watch(lambdaFunc1.logGroup);\nlogNotifier.watch(lambdaFunc2.logGroup);\n```\n\n## Installation\n\n```sh\nnpm i @thedesignium/cdk-log-notifier\n```\n\n## API Reference\n\n### Class: `LogNotifier`\n\n```typescript\nnew LogNotifier(scope: cdk.Construct, id: string, props: LogNotifierProps)\n```\n\nThe properties in `props`:\n\n- `filterPattern`: The [FilterPattern object in aws-cloudwatch module](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-logs.FilterPattern.html). The logs is filtered as specified here. *Required.*\n- `slackIncomingWebhookUrl`: The [Incoming Webhook URL](https://api.slack.com/messaging/webhooks) of Slack. Create for the Slack channel the logs should be posted. *Required.*\n- `dateTimeFormatOptions`: The [arguments of the DateTimeFormat constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#parameters), used to format the datetime which shown at the bottom of the Slack message. If omitted, it's formatted like `12/20, 3:00:00 AM UTC`. *Optional.*\n\n  Example:\n\n  ```typescript\n    dateTimeFormatOptions: {\n      locales: 'ja-JP',\n      timeZone: 'Asia/Tokyo',\n      month: 'numeric',\n      day: 'numeric',\n      hour: 'numeric',\n      minute: 'numeric',\n      second: 'numeric',\n    }\n  ```\n\n#### Static Method: `fromAttributes`\n\n```typescript\nLogNotifier.fromAttributes(scope: cdk.Construct, id: string, attrs: LogNotifierAttributes): LogNotifier\n```\n\nInstantiate from the attributes. Put the value of `logNotifier.attributes` as `attrs` parameter.\n\n#### Method: `watch`\n\n```typescript\nlogNotifier.watch(logGroup: logs.LogGroup): void\n```\n\nAdd the log group to watch list to notify. The logs in the watched log groups are filtered by the filterPattern and posted to Slack.\n\n#### Property: `attributes`\n\n```typescript\nattributes: LogNotifierAttributes\n```\n\nTo use with `LogNotifier.fromAttributes()`.\n\n## Containing Resources\n\n- [logs.SubscriptionFilter](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-logs.SubscriptionFilter.html)\n- [lambda.Function](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-lambda.Function.html)\n\n## Limitation\n\nThe `watch()` method attaches a [Subscription](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Subscriptions.html) to the subject logGroup. The number of subscription can be attached to a logGroup, however, is only one. So it'll fail if the logGroup has another subscription already. Similary, the watched logGroup can't be attached another subscription nor watched from another LogNotifier.\n\n## Motivation\n\nThere were 2 requirements:\n\n1. Notice the all logs produced by `console.error()`(not only the crash report such InvocationError)\n2. Jump easily to CloudWatch via link\n\nWe tried `Lambda's error metric + CloudWatch Alarm + Chatbot` and `CloudWatch Metrics Filter + CloudWatch Alarm + Chatbot`, but the former system don't satisfy [1] and the latter system don't satisfy [2]. That's why we need this.\n\n## FAQ\n\n### Cross Stack?\n\nPossible. Export all values in `LogNotifier.prototype.attributes`, import it and use `LogNotifier.fromAttributes()` in another Stack.\n\n### How can I customize the Slack bot icon or name?\n\nYou can set at [Slack App setting page](https://api.slack.com/apps), or Incoming Webhook configuration page if you use [Legacy Incoming Webhook](https://api.slack.com/legacy/custom-integrations/incoming-webhooks).\n\n### No support for other languages than TypeScript?\n\nSupports Python, Java, Go and .NET.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTheDesignium%2Fcdk-log-notifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTheDesignium%2Fcdk-log-notifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTheDesignium%2Fcdk-log-notifier/lists"}