npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cwl-link

v1.1.5

Published

Create a CloudWatch Logs Link

Downloads

396

Readme

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