Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
cloudwatch-producer
Advanced tools
Simple scaffolding for applications that produce batched CloudWatch metrics
Note This project is a work in progress at the moment and not fully ready for production!
Simple scaffolding for applications that produce batched CloudWatch metrics
npm install cloudwatch-producer
import { Producer } from 'cloudwatch-producer';
// create simple producer
const producer = Producer.create({
region: 'eu-west-1'
});
By default the consumer will look for AWS credentials in the places specified by the AWS SDK. The simplest option is to export your credentials as environment variables:
export AWS_SECRET_ACCESS_KEY=...
export AWS_ACCESS_KEY_ID=...
If you need to specify your credentials manually, you can use a pre-configured instance of the CloudWatch Client.
import { Producer } from 'cloudwatch-producer';
import { CloudWatchClient } from '@aws-sdk/client-cloudwatch';
// create simple producer
const producer = Producer.create({
region: 'eu-west-1',
cloudwatch: new CloudWatchClient({
region: 'eu-west-1',
credentials: {
accessKeyId: 'yourAccessKey',
secretAccessKey: 'yourSecret'
}
})
});
To send a metric, you just need to call the .collect()
method with your metric and value, as in the example below.
import { Producer } from 'cloudwatch-producer';
// create simple producer
const producer = Producer.create({
region: 'eu-west-1'
});
producer.collect(
{
MetricName: 'My Awesome Metric',
Unit: 'Seconds',
Dimensions: [
{
Name: 'dimension-one',
Value: 'dimension-one-value'
}
]
},
2
);
Please note that if you have not started the producer, this metric will be sent instantly, rather than in a batch. You can find out how to start batching below.
By default, CloudWatch Producer will not send metrics in batches until the producer has been started, to start it, just call the .start()
method like so:
producer.start();
If you would like to stop sending metrics in batches and go back to instantly sending metrics, just call the .stop()
method like so:
producer.stop();
CloudWatch Producer will send the following via the API when a metric batch is triggered or a metric is instantly dispatched:
{
MetricName: "My Awesome Metric",
Dimensions: [
{
Name: 'dimension-one',
Value: 'dimension-one-value'
}
],
StatisticValues: {
Maximum: 2,
Minimum: 2,
SampleCount: 1,
Sum: 2
},
Timestamp: "Thu Mar 02 2023 22:26:20 GMT+0000 (Greenwich Mean Time)",
Unit: "Seconds"
}
Dimensions
were supplied when the metric was collected, it will be sent as []
Unit
was not supplied when the metric was collected, it will be sent as None
StatisticValues
will be incremented like so:
Maximum
will either be the previously stored value or the provided value if the provided value is higherMinimum
will either be the previously stored value or the provided value if the provided value is lowerSampleCount
will be incremented each time the metric is updatedSum
will be the previously stored value plus the provided valuenpm test
For coverage report, run the command:
npm run coverage
To check for problems using ESLint
npm run lint
FAQs
Simple scaffolding for applications that produce batched CloudWatch metrics
The npm package cloudwatch-producer receives a total of 0 weekly downloads. As such, cloudwatch-producer popularity was classified as not popular.
We found that cloudwatch-producer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.