cwl-link
TypeScript icon, indicating that this package has built-in type declarations

1.1.8 • Public • Published

cwl-link(CloudWatch Logs Link)

cwl-link creates a link for CloudWatch Logs.

Installation

cwl-link is available as an npm package.

// with npm
npm install cwl-link

// with yarn
yarn add cwl-link

Usage

How to import

// ES5 example
const cwllink = require('cwl-link');
// ES6+ example
import * as cwllink from 'cwl-link';
exports.handler = function(event, context) {
  // This is a link for a Log Event page filtered by request id.
  const link = cwllink.fromLambdaContext(context);
}

AWS Lambda triggered by Subscription Filters

exports.handler = async function(event, context) {
  const link = await cwllink.fromLambdaEventTriggeredBySubscriptionFilters(event);
}

Or you can use decoded data.

exports.handler = async function(event, context) {
  const decoded = await cwllink.decodeCloudWatchLogsData(event.awslogs.data);

  // you can use decoded data.

  const link = cwllink.fromCloudWatchLogsData(decoded);
}

Other Node.js runtime environment

const region = '...';
const logGroupName = '...';
const logGroupLink = cwllink.create(region, logGroupName);

const logEventName = '...';
const logEventLink = cwllink.create(region, logGroupName, logEventName);

const terms = ['...'];
const filteredByTermsLink = cwllink.create(region, logGroupName, logEventName, { terms });

const start = 1_649_602_800_000; // unix time(ms): 2022-04-12 00:00:00
const filteredByStartLink = cwllink.create(region, logGroupName, logEventName, { start });
const start = -3_600_000; // in the last hour(ms):
const filteredByRelativeStartLink = cwllink.create(region, logGroupName, logEventName, { start });

const end = 1_649_689_199_000; // unix time(ms): 2022-04-12 23:59:59
const filteredByEndLink = cwllink.create(region, logGroupName, logEventName, { end });

const filteredByMixLink = cwllink.create(region, logGroupName, logEventName, { terms, start, end });

These Usages have been tested.

Type Aliases

FilterOptions

Ƭ FilterOptions: Object

Options for filtering logs.

Type declaration

Name Type Description
end? number You can provide unix timestamp.
start? number You can provide the absolute or relative time(ms). - if you provide unix timestamp, it is treated as absolute time. - if you provide negative number, it is treated as relative time.
terms? string[] You can filter by string array.

Defined in

index.ts:5

Functions

create

create(region, logGroup, logEvents?, options?): string

Create a link for CloudWatch Logs.

Parameters

Name Type Description
region string
logGroup string
logEvents? string optional parameter
options? FilterOptions optional parameter for filtering logs

Returns

string

a link for CloudWatch Logs.

Defined in

index.ts:27


decodeCloudWatchLogsData

decodeCloudWatchLogsData(data): Promise<CloudWatchLogsDecodedData>

Decode CloudWatch Logs data.

Parameters

Name Type Description
data string base64 of zipped data.

Returns

Promise<CloudWatchLogsDecodedData>

CloudWatch Logs decoded data.

Defined in

index.ts:93


fromCloudWatchLogsData

fromCloudWatchLogsData(data): string

Create a link for CloudWatch Logs from CloudWatchLogsDecodedData.

Parameters

Name Type Description
data CloudWatchLogsDecodedData CloudWatch Logs decoded data.

Returns

string

a link for a Log Event page filtered by request id.

Defined in

index.ts:107


fromLambdaContext

fromLambdaContext(context): string

Create a link for CloudWatch Logs from a context of AWS Lambda.

Parameters

Name Type Description
context Context a context of AWS Lambda.

Returns

string

a link for a Log Event page filtered by request id.

Defined in

index.ts:66


fromLambdaEventTriggeredBySubscriptionFilters

fromLambdaEventTriggeredBySubscriptionFilters(event): Promise<string>

Create a link for CloudWatch Logs from a event of AWS Lambda triggered by Subscription Filters.

Parameters

Name Type Description
event CloudWatchLogsEvent a event of AWS Lambda triggered by Subscription Filters.

Returns

Promise<string>

a link for a Log Event page filtered by request id.

Defined in

index.ts:121


gunzipAsync

gunzipAsync(src): Promise<Buffer>

gunzipAsync is a promise wrapper of zlib.gunzip.

Parameters

Name Type
src Buffer

Returns

Promise<Buffer>

decompressed

Defined in

index.ts:78

Readme

Keywords

Package Sidebar

Install

npm i cwl-link

Weekly Downloads

73

Version

1.1.8

License

MIT

Unpacked Size

30.9 kB

Total Files

7

Last publish

Collaborators

  • michiharu