- Newest
- Most votes
- Most comments
I contacted AWS Support, and after some days, the person told me that the Connect technical team told him that API Metrics (API Contacts & API Contacts Handled) on the agent level are not yet supported on the GetMetricDataV2
API. So that's why I was getting 0 for those metrics.
I was also told that they would change the documentation to reflect this (so that nobody else has to spend days figuring out this :/) and that they are working so that the API supports these metrics.
What do you get if you change your filter setting from AGENT to the different CHANNEL that you have like CHAT (and others that you are trying to pull report for). Keep the groups value of AGENT and let us know.
Hello lautaroef,
I have re-replicated the GetMetricDataV2 - "API setup and initially encountered a scenario where the API returned no output, similar to your experience. However after further investigation , I managed to resolve the issue by making some additions to the code. This is the final edited code :
// Import required modules
import { ConnectClient, GetMetricDataV2Command } from "@aws-sdk/client-connect";
// Lambda handler function
export async function handler(event, context) {
try {
// Create AWS Connect client
const connectClient = new ConnectClient({ region: "us-east-1" }); // Change the region as needed
// Define input parameters for the GetMetricDataV2 command
const metricsInput = {
ResourceArn: "arn:aws:connect:us-east-1:<user_id>:instance/<same_instance_used_in_historical_metrics>",
StartTime: new Date("2024-03-26T07:00:00.000Z"),
EndTime: new Date("2024-03-28T06:59:59.999Z"),
Interval: {
TimeZone: 'America/Los_Angeles',
IntervalPeriod: 'TOTAL',
},
Filters: [{ FilterKey: "AGENT", FilterValues: ['<AGENT ID>'] }], // agent ids
Groupings: ["QUEUE"],
Metrics: [
// API Contacts Handled
{
Name: 'CONTACTS_HANDLED',
MetricFilters: [
{
MetricFilterKey: 'INITIATION_METHOD',
MetricFilterValues: ['API'],
},
],
},
],
};
// Create GetMetricDataV2Command with the metrics input
const command = new GetMetricDataV2Command(metricsInput);
// Send the command to AWS Connect service and await response
const response = await connectClient.send(command);
// Log the response for debugging (optional)
console.log(response);
// Return response (or process it further)
return response;
} catch (error) {
// Handle errors
console.error("Error:", error);
throw error; // Rethrow the error for Lambda to handle
}
};
When I was running your original code, I noticed that your code had the line Name: 'CONTACTS_HANDLED' placed inside the Metrics array, where metric filters are typically specified. However, this caused confusion as it implied that 'CONTACTS_HANDLED' was a filter, when its actual purpose was to represent the metric we wanted to retrieve. Recognizing this, I moved Name: 'CONTACTS_HANDLED' outside of the MetricFilters array in my modified version of the code, and this is the output I got:
Response { "$metadata": { "httpStatusCode": 200, "requestId": "<REQUEST ID>", "attempts": 1, "totalRetryDelay": 0 }, "MetricResults": [ { "Collections": [ { "Metric": { "MetricFilters": [ { "MetricFilterKey": "INITIATION_METHOD", "MetricFilterValues": [ "API" ], "Negate": false } ], "Name": "CONTACTS_HANDLED" }, "Value": 4 } ], "Dimensions": { "QUEUE": "<QUEUE ID>", "QUEUE_ARN": "QUEUE ARN" }, "MetricInterval": { "EndTime": "2024-03-28T07:00:00.000Z", "Interval": "TOTAL", "StartTime": "2024-03-26T07:00:00.000Z" } } ] }
I observed that the data retrieved correlated with the test calls I had previously placed via the API. This suggests that the code is now accurately fetching the desired metric data.
Hello, thank you for providing help on this. Yes, the request had a formatting error. A bracket was missing, so I just edited that. But even if I change the Groupings to QUEUE, I get various MetricResults for each queue the agent is in, but still get that the agent handled 0 API Contacts :( same period as the Historical Metrics UI which tells me it handled 254 calls.
I have already contacted AWS Technical Support, as it seems to be something on the account level. So as soon as I resolve this, I will publish it here.
Relevant content
- asked 12 days ago
- Accepted Answerasked 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
Adding the filter key CHANNEL with the values CHAT and/or TASK I get an empty MetricResults value.
When I include the VOICE channel I get that 0 calls were handled via API.
Just made some API calls using the startOutboundVoiceContact with my own agent queue, but for the period it happened, it says no API calls were handled for my user :/