Add a dimension to the metrics. A dimension is a key-value pair that is used to group metrics.
Add multiple dimensions to the metrics.
A high-cardinality data part of your Metrics log. This is useful when you want to search highly contextual information along with your metrics in your logs.
Add a metric to the metrics buffer.
Create a singleMetric to capture cold start. If it's a cold start invocation, this feature will:
This has the advantage of keeping cold start metric separate from your application metrics, where you might have unrelated dimensions.
A decorator automating coldstart capture, throw on empty metrics and publishing metrics on handler exit.
Synchronous function to actually publish your metrics. (Not needed if using logMetrics decorator). It will create a new EMF blob and log it to standard output to be then ingested by Cloudwatch logs and processed automatically for metrics creation.
Function to create the right object compliant with Cloudwatch EMF (Event Metric Format).
CloudWatch EMF uses the same dimensions across all your metrics. Use singleMetric if you have a metric that should have different dimensions.
You don't need to call publishStoredMetrics() after calling addMetric for a singleMetrics, they will be flushed directly.
the Metrics
Throw an Error if the metrics buffer is empty.
Generated using TypeDoc
Intro
Metrics creates custom metrics asynchronously by logging metrics to standard output following Amazon CloudWatch Embedded Metric Format (EMF).
These metrics can be visualized through Amazon CloudWatch Console.
Key features
Usage
Object oriented way with decorator
If you are used to TypeScript Class usage to encapsulate your Lambda handler you can leverage the @metrics.logMetrics() decorator to automatically:
Standard function
If you are used to classic JavaScript functions, you can leverage the different methods provided to create and publish metrics.