AWS - Cloudwatch CLI Dashboard Deployment - CLI - 'Search Parameter'

0

Hope you're all doing well. I am reaching out to you because I am working on configuring a bash script that I can employ to dynamically deploy to AWS Cloudwatch Dashboards irrespective of AWS Instance.

So far, I'm having some success with it, but there is something that I am not getting my hands around. I'm hoping that I can get a little advice.

Since I want to be able to set these up through the CLI, and not through the portal, I don't know how to get the entire set of lambdas to display dynamically, except by setting up the widget manually. Now, as I understand it, I should be using the "Search" parameter in the 'expression' clause.

This is what I'm doing. Additionally, I am using that clause for other things in AWS (like for example, Connect Queue Wait Times) and it works successfully. However, in the case that I am attempting to use it for the Lambdas, it is not working. Now, I'm using the search clause for 3 other AWS Connect features, so my best guess is that I am using it incorrectly, or that it does not apply for the lambdas. Below I have attached two examples of how I am entering it.

Please note, I am deploying this to AWS in the following way. I am running a bash file that requests certain call center information, which is then dynamically entered into the JSON you see below. After the JSON is created, a file is generated from the entered parameters. That file is then deployed to AWS via CLI.

AWS Connect Queue Wait Time In this case, it is working.

"metrics": [[ { "expression": "SEARCH('{AWS/Connect,QueueName, InstanceId, MetricGroup}', 'Average', 300)", "id": "e1", "period": 300, "region": "${instanceRegion}" } ]]

Lambda Errors - Widget - By Lambda In this case it is not.

"metrics": [[ { "expression": "SEARCH('{AWS/Lambda,FunctionName, InstanceId, MetricName}', 'Average', 300)", "id": "e1", "period": 300, "region": "${instanceRegion}" }]]

Hoping that someone understands why the lambda (second) isn't working, but the first one is. I'd like the second one to function like the first one, so that it lists all of the lambdas, no matter how many/few there are.

I don't think this is going to be very helpful, but if there is any chance there is, below you will find the entire JSON that is being used.

{
    "start": "-PT3H",
    "periodOverride": "inherit",
    "widgets": [
        {
            "height": 6,
            "width": 6,
            "y": 6,
            "x": 0,
            "type": "metric",
            "properties": {
                "metrics": [
                    [ "AWS/Connect", "CallsPerInterval", "InstanceId", "${instanceId}", "MetricGroup", "VoiceCalls", { "visible": false } ],
                    [ ".", "ConcurrentCallsPercentage", ".", ".", ".", ".", { "visible": false } ],
                    [ ".", "ConcurrentCalls", ".", ".", ".", "." ],
                    [ ".", "MissedCalls", ".", ".", ".", ".", { "visible": false } ],
                    [ ".", "CallRecordingUploadError", ".", ".", ".", "CallRecordings", { "visible": false } ]
                ],
                "view": "timeSeries",
                "stacked": false,
                "region": "${instanceRegion}",
                "title": "Concurrent Calls - Widget",
                "period": 300,
                "yAxis": {
                    "left": {
                        "label": "miliseconds",
                        "showUnits": false
                    },
                    "right": {
                        "label": "Time",
                        "showUnits": false
                    }
                },
                "stat": "Average",
                "annotations": {
                    "horizontal": [
                        {
                            "label": "Alarm Threshold",
                            "value": 120
                        }
                    ]
                }
            }
        },
        {
            "height": 6,
            "width": 6,
            "y": 0,
            "x": 6,
            "type": "metric",
            "properties": {
                "metrics": [
                    [ "AWS/Connect", "ToInstancePacketLossRate", "Participant", "Agent", "Type of Connection", "WebRTC", "Instance ID", "${instanceId}", "Stream Type", "Voice", { "period": 60, "stat": "Average", "color": "#2ca02c" } ],
                    [ "...", { "period": 60, "stat": "Maximum", "color": "#d62728" } ]
                ],
                "view": "timeSeries",
                "stacked": false,
                "region": "${instanceRegion}",
                "title": "Instance Packet Loss - Widget",
                "yAxis": {
                    "left": {
                        "label": "Packet",
                        "showUnits": false
                    },
                    "right": {
                        "label": "Time",
                        "showUnits": false
                    }
                },
                "period": 300,
                "liveData": true,
                "annotations": {
                    "horizontal": [
                        {
                            "label": "Alarm Threshold",
                            "value": 0.8
                        }
                    ]
                }
            }
        },
        {
            "height": 6,
            "width": 6,
            "y": 0,
            "x": 12,
            "type": "metric",
            "properties": {
                "metrics": [
                    [ "AWS/Connect", "ConcurrentCallsPercentage", "InstanceId", "${instanceId}", "MetricGroup", "VoiceCalls", { "visible": false } ],
                    [ ".", "ConcurrentCalls", ".", ".", ".", ".", { "visible": false } ],
                    [ ".", "CallsPerInterval", ".", ".", ".", ".", { "visible": false } ],
                    [ ".", "MissedCalls", ".", ".", ".", "." ],
                    [ ".", "CallRecordingUploadError", ".", ".", ".", "CallRecordings", { "visible": false } ]
                ],
                "view": "timeSeries",
                "stacked": false,
                "region": "${instanceRegion}",
                "title": "Missed Calls - Widget",
                "period": 300,
                "stat": "Average",
                "yAxis": {
                    "left": {
                        "label": "Calls",
                        "showUnits": false 
                    },
                    "right": {
                        "label": "Time",
                        "showUnits": false
                    }
                },
                "annotations": {
                    "horizontal": [
                        {
                            "label": "Alarm",
                            "value": 20
                        }
                    ]
                }
            }
        },
        {
            "height": 6,
            "width": 6,
            "y": 0,
            "x": 18,
            "type": "metric",
            "properties": {
                "view": "timeSeries",
                "stacked": false,
                "metrics": [
                    [ "AWS/Lambda", "Errors", {"period": 60, "stat": "Sum", "color": "#d62728"} ]
                ],
                "region": "${instanceRegion}",
                "yAxis": {
                    "left": {
                        "label": "Errors",
                        "showUnits": false
                    },
                    "right": {
                        "label": "Time",
                        "showUnits": false
                    }
                },
                "annotations": {
                    "horizontal": [
                        {
                            "label": "Alarm Threshold",
                            "value": 1
                        }
                    ]
                },
                "title": "Lambda Errors - Widget - Overall",
                "period": 300
            }
        },
        {
            "height": 6,
            "width": 6,
            "y": 0,
            "x": 0,
            "type": "metric",
            "properties": {
                "metrics": [
                    [ "AWS/Lambda", "Duration", {"region": "${instanceRegion}", "color": "#ff9896", "label": "Duration"} ]
                ],
                "view": "timeSeries",
                "stacked": false,
                "region": "${instanceRegion}",
                "period": 60,
                "yAxis": {
                    "left": {
                        "label": "Milliseconds",
                        "showUnits": false
                    },
                    "right": {
                        "label": "Time",
                        "showUnits": false
                    }
                },
                "stat": "Sum",
                "annotations": {
                    "horizontal": [
                        {
                            "label": "Alarm Threshold (15 Minutes)",
                            "value": 900000
                        }
                    ]
                },
                "title": "Lambda Execution Duration - Widget"
            }
        },
        {
            "height": 6,
            "width": 6,
            "y": 6,
            "x": 6,
            "type": "metric",
            "properties": {
                "metrics": [
                    [ "AWS/Connect", "CallsPerInterval", "InstanceId", "${instanceId}", "MetricGroup", "VoiceCalls", { "period": 3600, "stat": "Sum", "color": "#2ca02c" } ]
                ],
                "period": 300,
                "stat": "Sum",
                "yAxis": {
                    "left": {
                        "label": "Calls",
                        "showUnits": false
                    },
                    "right": {
                        "label": "Time",
                        "showUnits": false
                    }
                }
                ,
                "region": "${instanceRegion}",
                "title": "Total Calls - Widget",
                "liveData": true,
                "legend": {
                    "position": "bottom"
                }
            }
        },
        {
            "height": 6,
            "width": 6,
            "y": 6,
            "x": 12,
            "type": "metric",
            "properties": {
                "view": "timeSeries",
                "metrics": [
                    [ { "expression": "SEARCH('{AWS/Connect,ContactFlowName,InstanceId,MetricGroup}', 'Average', 300)", "id": "e1", "period": 300, "color": "#d62728" } ]
                ],
                "region": "${instanceRegion}",
                "period": 300,
                "yAxis": {
                    "left": {
                        "label": "Errors",
                        "showUnits": false
                    },
                    "right": {
                        "label": "Time",
                        "showUnits": false
                    }
                },
                "title": "Contact Flow Errors - Widget - Overall"
            }
        },
        {
            "height": 6,
            "width": 6,
            "y": 6,
            "x": 18,
            "type": "metric",
            "properties": {
                "view": "timeSeries",
                "stacked": false,
                "metrics": [
                    [ { "expression": "SEARCH('{AWS/Connect,QueueName, InstanceId, MetricGroup}', 'Average', 300)", "id": "e1", "period": 300, "region": "${instanceRegion}" } ]
                ],
                "region": "${instanceRegion}",
                "title": "Queue Wait Time - Widget - By Queue",
                "period": 300,
                "yAxis": {
                    "left": {
                        "label": "Seconds in Queue",
                        "showUnits": false
                    },
                    "right": {
                        "label": "Time",
                        "showUnits": false
                    }
                },
                "annotations": {
                    "horizontal": [
                        {
                            "label": "Alarm Threshold",
                            "value": 600,
                            "fill": "above"
                        }
                    ]
                }
            }
        },
        {
            "height": 5,
            "width": 24,
            "y": 12,
            "x": 0,
            "type": "metric",
            "properties": {
                "view": "singleValue",
                "stacked": false,
                "metrics": [
                    [ { "expression": "SEARCH('{AWS/Connect,QueueName, InstanceId, MetricGroup}', 'Average', 300)", "id": "e1", "period": 300, "region": "${instanceRegion}" } ]
                ],
                "region": "${instanceRegion}",
                "title": "Queue Wait Time - Widget - By Queue",
                "period": 300,
                "yAxis": {
                    "left": {
                        "label": "Seconds In Queue",
                        "showUnits": false
                    },
                    "right": {
                        "label": "Time",
                        "showUnits": false
                    }
                },
                "annotations": {
                    "horizontal": [
                        {
                            "label": "Alarm Threshold",
                            "value": 600,
                            "fill": "above"
                        }
                    ]
                }
            }
        },
        {
            "height": 5,
            "width": 24,
            "type": "metric",
            "properties": {
                "view": "singleValue",
                "stacked": false,
                "metrics": [
                    [ { "expression": "SEARCH('{AWS/Lambda,FunctionName, InstanceId, MetricName}', 'Average', 300)", "id": "e1", "period": 300, "region": "${instanceRegion}" } ]
                ],
                "region": "${instanceRegion}",
                "title": "Lambda Errors - Widget - By Lambda",
                "period": 300,
                "yAxis": {
                    "left": {
                        "label": "Errors",
                        "showUnits": false
                    },
                    "right": {
                        "label": "Time",
                        "showUnits": false
                    }
                },
                "annotations": {
                    "horizontal": [
                        {
                            "label": "Alarm Threshold",
                            "value": 600,
                            "fill": "above"
                        }
                    ]
                }
            }
        }
    ]
}
1 Answer
0

do you need to specify the region in the search? I have tried doing a similar approach to yours, with creating a dashboard using dashboard variables to update the region, and when doing so, specifying the region in the properties of the metric widget seems enough, the dashboard doesn't embed the region in the search expression in my case - so I wonder if you need to use that syntax, isn't the setting region property on your widget enough?

profile pictureAWS
Jsc
answered 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions