Skip to content

Setup AWS CloudWatch

MCatherine edited this page Mar 15, 2023 · 3 revisions

Setup Dashboard

  • Go to AWS CloudWatch, and select "Dashboards". In the main screen, select "Create dashboard". In the popup window, let's call it "FAM-Ops" and then click "Create dashboard"

    image image

  • In the dashboard space, click on "Actions" and then select "View/edit source"

    image

  • In the pop up window, paste the following config template, and we need to change a few parameters so that it matches the service in our current AWS environment

    • fam api lambda name
    • fam auth lambda name
    • fam api gateway name
    • rds cluster name
    {
        "widgets": [
            {
                "height": 5,
                "width": 8,
                "y": 5,
                "x": 0,
                "type": "metric",
                "properties": {
                    "metrics": [
                        [
                            "AWS/ApiGateway",
                            "4XXError",
                            "ApiName",
                            "fam-api-lambda-credible-lamprey-gateway",
                            "Stage",
                            "v1",
                            { "visible": false }
                        ],
                        [".", "5XXError", ".", ".", ".", "."]
                    ],
                    "view": "timeSeries",
                    "stacked": false,
                    "region": "ca-central-1",
                    "title": "API Gateway 5XX Errors",
                    "period": 300,
                    "stat": "Sum"
                }
            },
            {
                "height": 5,
                "width": 8,
                "y": 10,
                "x": 0,
                "type": "metric",
                "properties": {
                    "metrics": [
                        [
                            "AWS/ApiGateway",
                            "4XXError",
                            "ApiName",
                            "fam-api-lambda-glad-spaniel-gateway",
                            "Stage",
                            "v1"
                        ]
                    ],
                    "view": "timeSeries",
                    "stacked": false,
                    "region": "ca-central-1",
                    "title": "API Gateway 4XX Errors",
                    "period": 300,
                    "stat": "Sum"
                }
            },
            {
                "height": 5,
                "width": 8,
                "y": 0,
                "x": 0,
                "type": "metric",
                "properties": {
                    "metrics": [
                        [
                            "AWS/Lambda",
                            "Errors",
                            "FunctionName",
                            "fam-api-lambda-glad-spaniel",
                            { "label": "API Lambda Errors" }
                        ],
                        [
                            "...",
                            "fam-auth-lambda-climbing-snapper",
                            { "label": "Auth Lambda Errors" }
                        ]
                    ],
                    "view": "timeSeries",
                    "stacked": false,
                    "region": "ca-central-1",
                    "period": 300,
                    "stat": "Sum",
                    "title": "Lambda Errors"
                }
            },
            {
                "height": 5,
                "width": 8,
                "y": 0,
                "x": 8,
                "type": "metric",
                "properties": {
                    "metrics": [
                        [
                            "AWS/ApiGateway",
                            "Latency",
                            "ApiName",
                            "fam-api-lambda-glad-spaniel-gateway",
                            "Stage",
                            "v1",
                            { "label": "p99", "stat": "p99" }
                        ],
                        ["...", { "label": "p95" }],
                        ["...", { "label": "p90", "stat": "p90" }],
                        ["...", { "stat": "p50", "label": "p50" }]
                    ],
                    "view": "timeSeries",
                    "stacked": false,
                    "region": "ca-central-1",
                    "title": "API Gateway Performance (Latency)",
                    "period": 300,
                    "stat": "p95"
                }
            },
            {
                "height": 5,
                "width": 8,
                "y": 5,
                "x": 16,
                "type": "metric",
                "properties": {
                    "metrics": [
                        [
                            "AWS/Lambda",
                            "ConcurrentExecutions",
                            "FunctionName",
                            "fam-api-lambda-glad-spaniel",
                            { "label": "API Lambda", "yAxis": "left" }
                        ],
                        [
                            "...",
                            "fam-auth-lambda-ideal-warthog",
                            { "label": "Auth Lambda" }
                        ]
                    ],
                    "view": "timeSeries",
                    "stacked": false,
                    "region": "ca-central-1",
                    "title": "Lambda Concurrent Executions",
                    "period": 300,
                    "stat": "Maximum"
                }
            },
            {
                "height": 5,
                "width": 8,
                "y": 0,
                "x": 16,
                "type": "metric",
                "properties": {
                    "view": "timeSeries",
                    "stacked": false,
                    "metrics": [
                        [
                            "AWS/RDS",
                            "ACUUtilization",
                            "DBClusterIdentifier",
                            "prod-fam-cluster"
                        ]
                    ],
                    "region": "ca-central-1",
                    "title": "Database Compute Usage"
                }
            },
            {
                "height": 5,
                "width": 8,
                "y": 10,
                "x": 8,
                "type": "metric",
                "properties": {
                    "metrics": [
                        [
                            "AWS/Lambda",
                            "Invocations",
                            "FunctionName",
                            "fam-api-lambda-glad-spaniel",
                            { "label": "API Lambda" }
                        ],
                        [
                            "...",
                            "fam-auth-lambda-ideal-warthog",
                            { "label": "Auth Lambda" }
                        ]
                    ],
                    "view": "timeSeries",
                    "stacked": false,
                    "region": "ca-central-1",
                    "title": "Lambda Invocations (# of Requests)",
                    "period": 300,
                    "stat": "Sum",
                    "setPeriodToTimeRange": true
                }
            },
            {
                "height": 5,
                "width": 8,
                "y": 5,
                "x": 8,
                "type": "metric",
                "properties": {
                    "metrics": [
                        [
                            "AWS/Lambda",
                            "Duration",
                            "FunctionName",
                            "fam-auth-lambda-together-eagle",
                            { "label": "p99", "stat": "p99" }
                        ],
                        ["...", { "label": "p95", "stat": "p95" }],
                        ["...", { "label": "p90" }],
                        ["...", { "label": "p50", "stat": "p50" }]
                    ],
                    "view": "timeSeries",
                    "stacked": false,
                    "region": "ca-central-1",
                    "title": "Auth Lambda Performance",
                    "period": 300,
                    "stat": "p90"
                }
            }
        ]
    }
    
    
  • If we want to manully edit any of the metrics, select the "Edit" button for the metric

    image

  • The "Graphed Metrics" option shows the displayed services, the "Browse" option shows the available metrics that we could select to put on the chart

    image image

Setup Alarms

  • Select "Alarms -> All alarms" from the left pannel, and from the screen, select "Create alarm"

    image

  • Follow the steps, first select the metric, we'll choose the "Lambda -> By Function Name", and the check the one for fam-api-lambda error. And then we set the "Statistic" to be "sum", and "Conditions" to be "greater than 1". Or whatever we want to be checked

    image image

  • And then we could select an existing SNS (Simple Notification Service) topic or create a new one

    image image

  • And then we'll just set the name and review to finish the setup

Clone this wiki locally