Skip to content

Instantly share code, notes, and snippets.

@yaasita
Created November 22, 2022 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yaasita/3b7ed311aec61227979bd58f6d3a0c14 to your computer and use it in GitHub Desktop.
Save yaasita/3b7ed311aec61227979bd58f6d3a0c14 to your computer and use it in GitHub Desktop.
import {
CloudWatchClient,
PutMetricDataCommand,
} from "@aws-sdk/client-cloudwatch";
const cw = new CloudWatchClient({ region: "ap-northeast-1" });
async function putcloudwatch(name, count) {
const metricname = `${ENV}:${name}`;
const params = {
MetricData: [
{
MetricName: metricname,
Timestamp: new Date(),
Unit: "Count",
Value: count,
},
],
Namespace: "WorkerQueues",
};
const command = new PutMetricDataCommand(params);
const response = await cw.send(command);
console.log(`putMetric: ${metricname}, ${count}`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment