-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 95996aa
Showing
17 changed files
with
5,747 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# EditorConfig helps developers define and maintain consistent | ||
# coding styles between different editors and IDEs | ||
# editorconfig.org | ||
# | ||
# Some of these options are also respected by Prettier | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
# Markdown syntax specifies that trailing whitespaces can be meaningful, | ||
# so let’s not trim those. e.g. 2 trailing spaces = linebreak (<br />) | ||
# See https://daringfireball.net/projects/markdown/syntax#p | ||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# https://github.com/vitest-dev/vitest/blob/main/.github/actions/setup-and-cache/action.yml | ||
name: Setup Node.js and install dependencies | ||
description: Setup PNPM and Node.js and install dependencies | ||
inputs: | ||
node-version: | ||
required: false | ||
description: Node version for setup-node | ||
default: 20 | ||
|
||
runs: | ||
using: composite | ||
|
||
steps: | ||
- name: Install pnpm | ||
uses: pnpm/action-setup@v4 | ||
|
||
- name: Setup Node.js ${{ inputs.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ inputs.node-version }} | ||
cache: 'pnpm' | ||
|
||
- name: Install dependencies | ||
shell: bash | ||
run: pnpm install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- '**.ts' | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Biome | ||
uses: biomejs/setup-biome@v2 | ||
|
||
- name: Lint | ||
run: biome ci . | ||
|
||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup and Install | ||
id: install | ||
uses: ./.github/actions/setup-and-install | ||
with: | ||
node-version: 20 | ||
|
||
# https://docs.localstack.cloud/user-guide/ci/github-actions/ | ||
- name: Start LocalStack | ||
run: | | ||
pip install localstack awscli-local[ver1] # install LocalStack cli and awslocal | ||
docker pull localstack/localstack # Make sure to pull the latest version of the image | ||
localstack start -d # Start LocalStack in the background | ||
echo "Waiting for LocalStack startup..." # Wait 30 seconds for the LocalStack container | ||
localstack wait -t 30 # to become ready before timing out | ||
echo "Startup complete" | ||
- name: Build | ||
run: pnpm build | ||
|
||
- name: Test | ||
run: pnpm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
web_modules/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional stylelint cache | ||
.stylelintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variable files | ||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
.env.* | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
.parcel-cache | ||
|
||
# Next.js build output | ||
.next | ||
out | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# vuepress v2.x temp and cache directory | ||
.temp | ||
.cache | ||
|
||
# Docusaurus cache and generated files | ||
.docusaurus | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
.vscode-test | ||
|
||
# yarn v2 | ||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
|
||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
// https://code.visualstudio.com/docs/editor/debugging | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node-terminal", | ||
"name": "Vitest Test", | ||
"request": "launch", | ||
"command": "pnpm vitest ${fileBasenameNoExtension}", | ||
"cwd": "${fileDirname}" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"files.associations": { | ||
"biome.json": "jsonc", | ||
"turbo.json": "jsonc" | ||
}, | ||
"editor.formatOnSave": true, | ||
"editor.codeActionsOnSave": { | ||
"quickfix.biome": "explicit" | ||
}, | ||
"[javascript]": { | ||
"editor.defaultFormatter": "biomejs.biome" | ||
}, | ||
"[typescript]": { | ||
"editor.defaultFormatter": "biomejs.biome" | ||
}, | ||
"[json]": { | ||
"editor.defaultFormatter": "biomejs.biome" | ||
}, | ||
"[jsonc]": { | ||
"editor.defaultFormatter": "biomejs.biome" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Chris Cook | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# Serverless CloudWatch Logs Insights Plugin | ||
|
||
[![CI](https://github.com/zirkelc/serverless-cloudwatch-logs-insights/actions/workflows/ci.yml/badge.svg)](https://github.com/zirkelc/serverless-cloudwatch-logs-insights/actions/workflows/ci.yml) | ||
[![npm](https://img.shields.io/npm/v/serverless-cloudwatch-logs-insights-plugin)](https://www.npmjs.com/package/serverless-cloudwatch-logs-insights-plugin) | ||
[![npm](https://img.shields.io/npm/dt/serverless-cloudwatch-logs-insights-plugin)](https://www.npmjs.com/package/serverless-cloudwatch-logs-insights-plugin) | ||
|
||
This Serverless Framework plugin automatically creates CloudWatch Logs Insights queries for all Lambda functions in your service. | ||
|
||
## Installation | ||
|
||
Install the plugin as a dev dependency in your Serverless project: | ||
|
||
```bash | ||
npm install --save-dev serverless-cloudwatch-logs-insights-plugin | ||
``` | ||
|
||
## Usage | ||
|
||
Add the plugin to your `serverless.yml` file: | ||
|
||
```yaml | ||
plugins: | ||
- serverless-cloudwatch-logs-insights-plugin | ||
``` | ||
Configure your queries in the `custom` section of your `serverless.yml`: | ||
|
||
```yaml | ||
custom: | ||
cloudwatchLogsInsights: | ||
queries: | ||
- name: "ErrorLogs" | ||
query: "fields @timestamp, @message | filter @message like /ERROR/ | sort @timestamp desc | limit 20" | ||
- name: "WarningLogs" | ||
query: "fields @timestamp, @message | filter @message like /WARNING/ | sort @timestamp desc | limit 20" | ||
- name: "RecentLogs" | ||
query: "fields @timestamp, @message | sort @timestamp desc | limit 50" | ||
``` | ||
|
||
## Configuration | ||
|
||
The plugin configuration is placed under the `custom.cloudwatchLogsInsights` key in your `serverless.yml` file. | ||
|
||
### Options | ||
|
||
- `queries`: An array of query definitions. Each query definition should have: | ||
- `name`: A unique name for the query (required). You can use forward slashes to create folder structure for your queries. For example, `folder-name/query-name`. | ||
- `query`: The CloudWatch Logs Insights query string (required). For example: `fields @timestamp, @message | filter @message like /ERROR/ | sort @timestamp desc | limit 20` | ||
|
||
## How It Works | ||
|
||
1. The plugin collects all Lambda functions defined in your Serverless service. | ||
2. It creates a CloudFormation resource of type `AWS::CloudWatch::QueryDefinition` for each configured query. | ||
3. Each query includes all Lambda function log groups. | ||
|
||
## Example | ||
|
||
Here's a full example of a `serverless.yml` file using this plugin: | ||
|
||
```yaml | ||
service: my-service | ||
plugins: | ||
- serverless-cloudwatch-logs-insights-plugin | ||
provider: | ||
name: aws | ||
runtime: nodejs14.x | ||
functions: | ||
hello: | ||
handler: handler.hello | ||
world: | ||
handler: handler.world | ||
custom: | ||
cloudwatchLogsInsights: | ||
queries: | ||
- name: "ErrorLogs" | ||
query: "fields @timestamp, @message | filter @message like /ERROR/ | sort @timestamp desc | limit 20" | ||
- name: "WarningLogs" | ||
query: "fields @timestamp, @message | filter @message like /WARNING/ | sort @timestamp desc | limit 20" | ||
- name: "RecentLogs" | ||
query: "fields @timestamp, @message | sort @timestamp desc | limit 50" | ||
``` | ||
|
||
This configuration will create three CloudWatch Logs Insights queries, each including both the `hello` and `world` function log groups. | ||
|
||
## Contributing | ||
|
||
Contributions are welcome! Please feel free to submit a Pull Request. | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License. |
Oops, something went wrong.