Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@middy/cloudwatch-metrics

Package Overview
Dependencies
Maintainers
3
Versions
131
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@middy/cloudwatch-metrics

Embedded CloudWatch metrics middleware for the middy framework

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
651
decreased by-49.88%
Maintainers
3
Weekly downloads
 
Created
Source

Middy Cloudwatch metrics middleware

Middy logo

Metrics middleware for the middy framework, the stylish Node.js middleware engine for AWS Lambda

npm version Known Vulnerabilities Standard Code Style Greenkeeper badge Chat on Gitter

This middleware hydrates lambda's context.metrics property with an instance of MetricLogger. This instance can be used to easily generate custom metrics from Lambda functions without requiring custom batching code, making blocking network requests or relying on 3rd party software.

Metrics collected with this logger are then available for querying within AWS CloudWatch Log Insights

You can explore all the MetricLogger APIs following aws-embedded-metrics documentation.

Install

To install this middleware you can use NPM:

npm install --save @middy/metrics

Options

  • namespace (string) (optional): Defaults to aws-embedded-metrics. Sets the CloudWatch namespace that extracted metrics should be published to.
  • dimensions (Record<String, String>[]) (optional): Defaults to
    [
        {"ServiceName": "myLambdaFunctionName"},
        {"ServiceType": "AWS::Lambda::Function"},
        {"LogGroupName": "logGroupNameUsedByMyLambda"},
    ]
    
    Explicitly override all dimensions. This will remove the default dimensions. You can provide an empty array to record all metrics without dimensions.

Sample usage

const middy = require('@middy/core')
const metrics = require('@middy/metrics')

const handler = middy((event, context, cb) => {
    context.metrics.putMetric("ProcessingLatency", 100, "Milliseconds");
    context.metrics.setProperty("RequestId", "422b1569-16f6-4a03-b8f0-fe3fd9b100f8")
    cb(null, {})
})

handler.use(metrics({
    namspace: "myAppliction",
    dimensions: [
        { "Action": "Buy" }
    ]
}))

Middy documentation and examples

For more documentation and examples, refers to the main Middy monorepo on GitHub or Middy official website.

Contributing

Everyone is very welcome to contribute to this repository. Feel free to raise issues or to submit Pull Requests.

License

Licensed under MIT License. Copyright (c) 2017-2018 Luciano Mammino and the Middy team.

FOSSA Status

Keywords

FAQs

Package last updated on 01 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc