I want to use AWS CloudFront custom metrics to create a count tracker for special requests (per unique user identified by userName).
I am able to send data to CloudFront using code sample shared below.
The data getting captured is not cumulative but always shows count as 1 even after multiple requests.When I visualise this data in graphs I don’t see the count getting increment but is plotted as points with the value 1 for 5 mins interval.
Is there something wrong with my usage?
const data = {
MetricData: [
{
MetricName: "special_req_count",
Dimensions: [
{
Name: "user",
Value: userName,
},
],
Unit: "Count",
Value: 1
},
],
Namespace: "CustomMetrics",
}
const command = new PutMetricDataCommand(data)
const response = await cwClient.send(command)
thanks