<commit_before>const aws = require('aws-sdk');
const connect = new aws.Connect();

let params = {
        InstanceId: "<provide your connect instance id>",
        EndTime: 1570845600,  //change the end time
        StartTime:1570780800, //change the start time
        Filters:{
            Queues:["<provide your connect instances queue id>"],
            Channels:["VOICE"]
        },
        HistoricalMetrics:[{
            Name: "CONTACTS_ABANDONED", //add more metrics in this section. View https://docs.aws.amazon.com/connect/latest/APIReference/API_GetMetricData.html
            Unit: "COUNT",
            Statistic:"SUM"
        },
        {
        Name: "CONTACTS_HOLD_ABANDONS",
        Unit: "COUNT",
        Statistic: "SUM"
        }]
    };


exports.handler = async (event) => {

    let result = await connect.getMetricData(params, function(err, data) {
        if (err){
                 console.log(err, err.stack);
        }
        else{   
             console.log(data);        
        }
    }).promise();
    
    var metrics = result["MetricResults"]
        console.log(metrics[0].Collections);
    
    
};
<commit_msg>Add all historical metrics<commit_after>const aws = require('aws-sdk');
const connect = new aws.Connect();

let params = {
        InstanceId: "1e8f045a-d7f1-4405-96c1-66701c25fd32",
        EndTime: 1571184000,
        StartTime:1571153400,
        Filters:{
            Queues:["943031b0-62ce-49a7-8688-9e84accd94fc"],
            Channels:["VOICE"]
        },
        HistoricalMetrics : [
      {
         "Name" : "AFTER_CONTACT_WORK_TIME",
         "Unit" : "SECONDS",
         "Statistic" : "AVG"
      },
      {
         "Name" : "CONTACTS_QUEUED",
         "Unit" : "COUNT",
         "Statistic" : "SUM"
      },
      {
         "Name" : "CONTACTS_HANDLED",
         "Unit" : "COUNT",
         "Statistic" : "SUM"
      },
      {
         "Name" : "HANDLE_TIME",
         "Unit" : "SECONDS",
         "Statistic" : "AVG"
      },
      {
         "Name" : "CONTACTS_TRANSFERRED_OUT",
         "Unit" : "COUNT",
         "Statistic" : "SUM"
      },
      {
         "Name" : "CONTACTS_MISSED",
         "Unit" : "COUNT",
         "Statistic" : "SUM"
      },
      {
         "Name" : "OCCUPANCY",
         "Unit" : "PERCENT",
         "Statistic" : "AVG"
      },
      {
         "Name" : "QUEUED_TIME",
         "Unit" : "SECONDS",
         "Statistic" : "MAX"
      },
      {
         "Name" : "HOLD_TIME",
         "Unit" : "SECONDS",
         "Statistic" : "AVG"
      },
      {
         "Name" : "SERVICE_LEVEL",
         "Threshold" : {
            "Comparison" : "LT",
            "ThresholdValue" : 60.0
         },
         "Unit" : "PERCENT",
         "Statistic" : "AVG"
      },
      {
         "Name" : "SERVICE_LEVEL",
         "Threshold" : {
            "Comparison" : "LT",
            "ThresholdValue" : 120.0
         },
         "Unit" : "PERCENT",
         "Statistic" : "AVG"
      },
      {
         "Name" : "SERVICE_LEVEL",
         "Threshold" : {
            "Comparison" : "LT",
            "ThresholdValue" : 30.0
         },
         "Unit" : "PERCENT",
         "Statistic" : "AVG"
      },
      {
         "Name" : "CONTACTS_ABANDONED",
         "Unit" : "COUNT",
         "Statistic" : "SUM"
      },
      {
         "Name" : "CONTACTS_CONSULTED",
         "Unit" : "COUNT",
         "Statistic" : "SUM"
      },
      {
         "Name" : "CONTACTS_AGENT_HUNG_UP_FIRST",
         "Unit" : "COUNT",
         "Statistic" : "SUM"
      },
      {
         "Name" : "CONTACTS_HANDLED_INCOMING",
         "Unit" : "COUNT",
         "Statistic" : "SUM"
      },
      {
         "Name" : "CONTACTS_HANDLED_OUTBOUND",
         "Unit" : "COUNT",
         "Statistic" : "SUM"
      },
      {
         "Name" : "CONTACTS_HOLD_ABANDONS",
         "Unit" : "COUNT",
         "Statistic" : "SUM"
      },
      {
         "Name" : "CONTACTS_TRANSFERRED_IN",
         "Unit" : "COUNT",
         "Statistic" : "SUM"
      },
      {
         "Name" : "CONTACTS_TRANSFERRED_IN_FROM_QUEUE",
         "Unit" : "COUNT",
         "Statistic" : "SUM"
      },
      {
         "Name" : "CONTACTS_TRANSFERRED_OUT_FROM_QUEUE",
         "Unit" : "COUNT",
         "Statistic" : "SUM"
      },
      {
         "Name" : "CALLBACK_CONTACTS_HANDLED",
         "Unit" : "COUNT",
         "Statistic" : "SUM"
      },
      {
         "Name" : "API_CONTACTS_HANDLED",
         "Unit" : "COUNT",
         "Statistic" : "SUM"
      },
      {
         "Name" : "ABANDON_TIME",
         "Unit" : "SECONDS",
         "Statistic" : "AVG"
      },
      {
         "Name" : "QUEUE_ANSWER_TIME",
         "Unit" : "SECONDS",
         "Statistic" : "AVG"
      },
      {
         "Name" : "INTERACTION_TIME",
         "Unit" : "SECONDS",
         "Statistic" : "AVG"
      },
      {
         "Name" : "INTERACTION_AND_HOLD_TIME",
         "Unit" : "SECONDS",
         "Statistic" : "AVG"
      }
   ]
    };


exports.handler = async (event) => {

    let result = await connect.getMetricData(params, function(err, data) {
        if (err){
                 console.log(err, err.stack);
        }
        else{   
             console.log(data);        
        }
    }).promise();
    
    var metrics = result["MetricResults"]
        console.log(metrics[0].Collections);
};

{'fraction_non_alphanumeric': 0.15637860082304528, 'fraction_numerical': 0.017957351290684626, 'mean_word_length': 1.475462962962963, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1083276', 'n_tokens_mistral': 1891, 'n_tokens_neox': 1805, 'n_words': 292}