aws-embedded-metrics
Advanced tools
Comparing version 0.1.0-beta.1573849895867 to 1.0.0
{ | ||
"name": "aws-embedded-metrics", | ||
"version": "0.1.0-beta.1573849895867", | ||
"description": "AWS Embedded Metrics Package", | ||
"version": "1.0.0", | ||
"description": "AWS Embedded Metrics Client Library", | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"repository": {}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/awslabs/aws-embedded-metrics-node.git" | ||
}, | ||
"engines": { | ||
"node": ">=10.0.0" | ||
}, | ||
"scripts": { | ||
@@ -23,3 +29,6 @@ "test": "jest --config jestconfig.json", | ||
"keywords": [], | ||
"author": "jaredcnance", | ||
"author": "Amazon Web Services", | ||
"contributors": [ | ||
"Jared Nance <jarnance@amazon.com>" | ||
], | ||
"license": "Apache-2.0", | ||
@@ -26,0 +35,0 @@ "devDependencies": { |
# aws-embedded-metrics | ||
![](https://codebuild.us-west-2.amazonaws.com/badges?uuid=eyJlbmNyeXB0ZWREYXRhIjoiRWFRdGtyUGw4a0JyaUR3THF4cTZxU2J6aEE1RVJFdmpxcUk5ekFHdUwzMnJXa1dYRmpzKzBCZlBNMU41cVkwNTNsQjZieUVGc3FGbUw1eHovTERrMStVPSIsIml2UGFyYW1ldGVyU3BlYyI6IjFuQ0VXN2l4YnNVMVpYMHIiLCJtYXRlcmlhbFNldFNlcmlhbCI6MX0%3D&branch=master) | ||
[![](https://img.shields.io/npm/v/aws-embedded-metrics.svg)](https://www.npmjs.com/package/aws-embedded-metrics) | ||
A new package from Amazon CloudWatch that allows you to generate CloudWatch Metrics from log data without requiring a control plane operation (e.g. PutMetricFilter). You are now able to embed metrics inside structured log events that direct CloudWatch Logs to extract and publish metrics to CloudWatch Metrics. | ||
A new package from Amazon CloudWatch that allows you to generate CloudWatch Metrics from structured log events. The embedded metrics will be extracted so you can visualize and alarm on them for real-time incident detection. This allows you to monitor aggregated values while preserving the detailed event context that generated them. | ||
* [Use Cases](#use-cases) | ||
* [Installation](#installation) | ||
* [Usage](#usage) | ||
* [API](#api) | ||
* [Examples](#examples) | ||
* [Development](#development) | ||
## Use Cases | ||
- **Asynchronous emission of metrics from Lambda functions** | ||
There are two natively supported options for emitting metrics from Lambda today: executing synchronous calls to CloudWatch via PutMetricData or extracting metrics from your function logs through CloudWatch Logs Metric Filters. The first couples the TPS of your function to your PutMetricData TPS and also blocks function execution while waiting on a response from CloudWatch Metrics. The second requires you to make a control plane call, forces you to keep code and configuration synchronized and also only supports a maximum of 100 filters per LogGroup. These are no longer problems if you use use CloudWatch embedded metrics since your metric definitions are included in the log data. | ||
There are two natively supported options for emitting metrics from Lambda today: executing synchronous calls to CloudWatch via PutMetricData or extracting metrics from your function logs through CloudWatch Logs Metric Filters. The first couples the TPS of your function to your PutMetricData TPS and also blocks function execution while waiting on a response from CloudWatch Metrics. The second requires you to make a control plane call, forces you to keep code and configuration synchronized. These are no longer problems if you use CloudWatch Embedded Metrics since your metric definitions are included in the log data. | ||
- **Linking metrics to high cardinality context** | ||
Using the Embedded Metric Format, you will be able to extract metrics and configure alarms on those metrics, but also be able to jump back to the logs—using [CloudWatch Logs Insights](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AnalyzingLogData.html)—that emitted those metrics to view high cardinality context. | ||
Using the Embedded Metric Format, you will be able to extract metrics and configure alarms on those metrics, but also be able to jump back to the logs—using [CloudWatch Logs Insights](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AnalyzingLogData.html)—that emitted those metrics to view high cardinality event context. | ||
## Installation | ||
``` | ||
npm install aws-embedded-metrics | ||
``` | ||
## Usage | ||
@@ -21,3 +35,3 @@ | ||
```js | ||
const { metricScope } = require("aws-embedded-metrics"); | ||
const { metricScope, Unit } = require("aws-embedded-metrics"); | ||
@@ -27,3 +41,3 @@ const myFunc = metricScope(metrics => | ||
metrics.putDimensions({ Service: "Aggregator" }); | ||
metrics.putMetric("ProcessingLatency", 100, "Milliseconds"); | ||
metrics.putMetric("ProcessingLatency", 100, Unit.Milliseconds); | ||
metrics.setProperty("RequestId", "422b1569-16f6-4a03-b8f0-fe3fd9b100f8"); | ||
@@ -39,3 +53,3 @@ // ... | ||
```js | ||
const { createMetricsLogger } = require("aws-embedded-metrics"); | ||
const { createMetricsLogger, Unit } = require("aws-embedded-metrics"); | ||
@@ -45,3 +59,3 @@ const myFunc = async () => { | ||
metrics.putDimensions({ Service: "Aggregator" }); | ||
metrics.putMetric("ProcessingLatency", 100, "Milliseconds"); | ||
metrics.putMetric("ProcessingLatency", 100, Unit.Milliseconds); | ||
metrics.setProperty("RequestId", "422b1569-16f6-4a03-b8f0-fe3fd9b100f8"); | ||
@@ -55,2 +69,17 @@ // ... | ||
### Lambda | ||
If you are running on Lambda, export your function like so: | ||
```js | ||
const { metricScope } = require("aws-embedded-metrics"); | ||
const myFunc = metricScope(metrics => | ||
async () => { | ||
// ... | ||
}); | ||
exports.handler = myFunc(); | ||
``` | ||
## API | ||
@@ -241,3 +270,3 @@ | ||
## Running Locally | ||
### Running Locally | ||
@@ -274,3 +303,3 @@ If you are running the CW agent locally, you can test the workflow: | ||
## Formatting | ||
### Formatting | ||
@@ -277,0 +306,0 @@ We use [Prettier](https://prettier.io/) for auto-formatting. |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
97035
1
305
10