1.1.5 • Published 2 months ago

cwl-link v1.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

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

NameTypeDescription
end?numberYou can provide unix timestamp.
start?numberYou 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

NameTypeDescription
regionstring
logGroupstring
logEvents?stringoptional parameter
options?FilterOptionsoptional 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

NameTypeDescription
datastringbase64 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

NameTypeDescription
dataCloudWatchLogsDecodedDataCloudWatch 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

NameTypeDescription
contextContexta 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

NameTypeDescription
eventCloudWatchLogsEventa 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

NameType
srcBuffer

Returns

Promise<Buffer>

decompressed

Defined in

index.ts:78

1.1.5

2 months ago

1.1.1

8 months ago

1.1.0

8 months ago

1.1.4

8 months ago

1.1.3

8 months ago

1.1.2

8 months ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago