Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

20.4 KB
Raw Blame
# ---------------------------------------------------------------------------------------------------------------------
# Provisions a CloudWatch dashboard with variables to select which instance to show metrics for, should be one per
# region.
# ---------------------------------------------------------------------------------------------------------------------
AWSTemplateFormatVersion: "2010-09-09"
Description: "AWS Linux 2, docker compose, nfs support, cron support, cloud watch logging, route53 updating"
Resources:
  CloudWatchDashboard:
    Type: AWS::CloudWatch::Dashboard
    Properties:
      DashboardName: or-default
      DashboardBody: !Sub |
        {
          "variables": [
            {
              "type": "property",
              "property": "InstanceName",
              "inputType": "select",
              "id": "InstanceName",
              "label": "Instance",
              "visible": true,
              "search": "CWAgent-Prometheus MetricName=or_attributes_total",
              "populateFrom": "InstanceName"
            },
            {
              "type": "property",
              "property": "InstanceId",
              "inputType": "select",
              "id": "InstanceId",
              "label": "EC2 Instance ID",
              "visible": true,
              "search": "CWAgent MetricName=disk_used_percent",
              "populateFrom": "InstanceId"
            }
          ],
          "widgets": [
            {
              "height": 6,
              "width": 8,
              "y": 0,
              "x": 0,
              "type": "metric",
              "properties": {
                "metrics": [
                  [ { "expression": "m8-m6-m5-m4-m3-m2-m1", "label": "Other", "id": "e1", "region": "eu-west-1" } ],
                  [ "CWAgent-Prometheus", "or_attributes_total", "InstanceName", "a", "source", "RulesEngine", { "id": "m1", "yAxis": "left", "label": "Rules" } ],
                  [ "...", "DefaultMQTTHandler", { "id": "m2", "yAxis": "left", "label": "MQTT" } ],
                  [ "...", "AgentService", { "id": "m3", "yAxis": "left", "label": "Agents" } ],
                  [ "...", "AssetResource", { "id": "m4", "yAxis": "left", "label": "HTTP API" } ],
                  [ "...", "WebsocketClient", { "id": "m5", "yAxis": "left", "label": "Websocket" } ],
                  [ "...", "GatewayService", { "id": "m6", "yAxis": "left", "label": "Gateways" } ],
                  [ ".", "artemis_message_count", ".", ".", "queue", "*.*.writeattributevalue.#", { "id": "m7", "yAxis": "left", "label": "MQTT Backlog" } ],
                  [ ".", "or_attributes_seconds_count", ".", ".", { "visible": false, "label": "Total", "id": "m8" } ]
                ],
                "view": "timeSeries",
                "stacked": false,
                "region": "${AWS::Region}",
                "stat": "Sum",
                "period": 300,
                "title": "Attribute Events",
                "yAxis": {
                  "left": {
                    "showUnits": false,
                    "label": "Count",
                    "min": 0
                  }
                }
              }
            },
            {
              "height": 6,
              "width": 8,
              "y": 6,
              "x": 8,
              "type": "metric",
              "properties": {
                "metrics": [
                  [ { "expression": "IF(m2,(m1/m2)*1000,0)", "label": "Rule Engines", "id": "e1" } ],
                  [ { "expression": "IF(m4,(m3/m4)*1000,0)", "label": "Attr. Processor", "id": "e2", "yAxis": "right" } ],
                  [ "CWAgent-Prometheus", "or_rules_seconds_sum", "InstanceName", "a", { "id": "m1", "visible": false } ],
                  [ ".", "or_rules_seconds_count", ".", ".", { "id": "m2", "visible": false } ],
                  [ ".", "or_attributes_seconds_sum", ".", ".", { "id": "m3", "visible": false } ],
                  [ ".", "or_attributes_seconds_count", ".", ".", { "id": "m4", "visible": false } ]
                ],
                "view": "timeSeries",
                "stacked": false,
                "region": "${AWS::Region}",
                "stat": "Sum",
                "period": 300,
                "title": "Execution Time",
                "yAxis": {
                  "left": {
                    "showUnits": false,
                    "label": "ms",
                    "min": 0
                  },
                  "right": {
                    "showUnits": false,
                    "label": "ms",
                    "min": 0
                  }
                }
              }
            },
            {
              "height": 6,
              "width": 8,
              "y": 12,
              "x": 8,
              "type": "metric",
              "properties": {
                "metrics": [
                  [ "CWAgent-Prometheus", "haproxy_server_current_sessions", "server", "manager", "proxy", "mqtt", "InstanceName", "a", { "label": "MQTT" } ],
                  [ "...", "manager_backend", ".", ".", { "label": "HTTP/WS" } ],
                  [ "...", "keycloak", ".", "keycloak_backend", ".", ".", { "label": "Keycloak" } ],
                  [ ".", "haproxy_server_http_responses_total", ".", ".", ".", ".", ".", ".", "code", "5xx", { "label": "Keycloak 5xx", "yAxis": "right" } ],
                  [ "...", "manager", ".", "manager_backend", ".", ".", ".", ".", { "label": "Manager 5xx", "yAxis": "right" } ]
                ],
                "view": "timeSeries",
                "stacked": false,
                "region": "${AWS::Region}",
                "title": "Proxy Sessions & Errors",
                "stat": "Maximum",
                "period": 300,
                "yAxis": {
                  "left": {
                    "min": 0,
                    "label": "Count",
                    "showUnits": false
                  },
                  "right": {
                    "min": 0,
                    "label": "Count",
                    "showUnits": false
                  }
                }
              }
            },
            {
              "height": 6,
              "width": 8,
              "y": 12,
              "x": 0,
              "type": "metric",
              "properties": {
                "metrics": [
                  [ "CWAgent-Prometheus", "haproxy_server_bytes_in_total", "server", "manager", "proxy", "mqtt", "InstanceName", "a", { "label": "MQTT Bytes In" } ],
                  [ ".", "haproxy_server_bytes_out_total", ".", ".", ".", ".", ".", ".", { "label": "MQTT Bytes Out" } ],
                  [ "...", "keycloak", ".", "keycloak_backend", ".", ".", { "label": "Keycloak Bytes Out" } ],
                  [ ".", "haproxy_server_bytes_in_total", ".", ".", ".", ".", ".", ".", { "label": "Keycloak Bytes In" } ],
                  [ "...", "manager", ".", "manager_backend", ".", ".", { "label": "HTTP/WS Bytes In" } ],
                  [ ".", "haproxy_server_bytes_out_total", ".", ".", ".", ".", ".", ".", { "label": "HTTP/WS Bytes Out" } ]
                ],
                "view": "timeSeries",
                "stacked": false,
                "region": "${AWS::Region}",
                "title": "Proxy I/O",
                "stat": "Sum",
                "period": 300,
                "yAxis": {
                  "left": {
                    "min": 0
                  }
                }
              }
            },
            {
              "height": 6,
              "width": 8,
              "y": 0,
              "x": 8,
              "type": "metric",
              "properties": {
                "metrics": [
                  [ { "expression": "m1-m2", "label": "Dynamic Threads", "id": "e1" } ],
                  [ { "expression": "IF(m4,(m3/m4)*1000,0)", "label": "Execution Time", "id": "e2", "yAxis": "right" } ],
                  [ "CWAgent-Prometheus", "executor_pool_size_threads", "InstanceName", "a", "name", "ContainerExecutor", { "id": "m1", "visible": false, "stat": "Maximum" } ],
                  [ ".", "executor_pool_core_threads", ".", ".", ".", ".", { "id": "m2", "visible": false, "stat": "Maximum" } ],
                  [ ".", "executor_seconds_sum", ".", ".", ".", ".", { "id": "m3", "visible": false } ],
                  [ ".", "executor_seconds_count", ".", ".", ".", ".", { "id": "m4", "visible": false } ]
                ],
                "view": "timeSeries",
                "stacked": false,
                "region": "${AWS::Region}",
                "title": "Container Threads",
                "stat": "Sum",
                "period": 300,
                "yAxis": {
                  "left": {
                    "min": 0,
                    "showUnits": false,
                    "label": "Count"
                  },
                  "right": {
                    "min": 0,
                    "showUnits": false,
                    "label": "ms"
                  }
                }
              }
            },
            {
              "height": 9,
              "width": 8,
              "y": 9,
              "x": 16,
              "type": "metric",
              "properties": {
                "metrics": [
                  [ "AWS/EC2", "EBSReadOps", "InstanceId", "a", { "label": "Read", "id": "m1", "visible": false, "stat": "Sum" } ],
                  [ ".", "EBSWriteOps", ".", ".", { "label": "Write", "id": "m2", "stat": "Sum", "visible": false } ],
                  [ ".", "CPUCreditBalance", ".", ".", { "yAxis": "left", "label": "CPU Credit Balance", "id": "m3", "stat": "Average", "visible": false } ],
                  [ ".", "CPUUtilization", ".", ".", { "label": "CPU Utilization %", "id": "m4", "yAxis": "right" } ],
                  [ ".", "EBSIOBalance%", ".", ".", { "label": "EBS IO Balance %", "yAxis": "right" } ],
                  [ { "expression": "m1/DIFF_TIME(m1)", "label": "Read IOPS", "id": "e1" } ],
                  [ { "expression": "m2/DIFF_TIME(m2)", "label": "Write IOPS", "id": "e2" } ],
                  [ { "expression": "m3/100", "label": "CPU Credit Balance (x100)", "id": "e3" } ]
                ],
                "view": "timeSeries",
                "stacked": false,
                "region": "${AWS::Region}",
                "title": "EC2",
                "stat": "Maximum",
                "period": 300,
                "yAxis": {
                  "left": {
                    "min": 0
                  },
                  "right": {
                    "min": 0,
                    "max": 100
                  }
                }
              }
            },
            {
              "height": 9,
              "width": 8,
              "y": 0,
              "x": 16,
              "type": "metric",
              "properties": {
                "metrics": [
                  [ "CWAgent", "mem_used_percent", "InstanceId", "a", { "label": "Memory Usage %" } ],
                  [ "CWAgent", "disk_used_percent", ".", ".", "path", "/", "fstype", "xfs", { "label": "Root Disk Usage %" } ],
                  [ "CWAgent", "disk_used_percent", ".", ".", "path", "/var/lib/docker/volumes", "fstype", "xfs", { "label": "Data Disk Usage %" } ]
                ],
                "view": "timeSeries",
                "stacked": false,
                "region": "${AWS::Region}",
                "stat": "Average",
                "period": 900,
                "title": "Disk & Memory",
                "yAxis": {
                  "left": {
                    "min": 0,
                    "max": 100
                  }
                }
              }
            },
            {
              "height": 6,
              "width": 8,
              "y": 6,
              "x": 0,
              "type": "metric",
              "properties": {
                "metrics": [
                  [ { "expression": "IF(m2,(m1/m2)*1000,0)", "label": "Processing Time", "id": "e1", "yAxis": "right" } ],
                  [ "CWAgent-Prometheus", "or_provisioning_seconds_sum", "InstanceName", "a", { "id": "m1", "yAxis": "left", "visible": false } ],
                  [ ".", "or_provisioning_seconds_count", ".", ".", { "id": "m2", "yAxis": "left", "label": "Count" } ],
                  [ ".", "artemis_message_count", ".", ".", "queue", "provisioning.*.request", { "id": "m3", "yAxis": "left", "label": "Backlog" } ]
                ],
                "view": "timeSeries",
                "stacked": false,
                "region": "${AWS::Region}",
                "stat": "Sum",
                "period": 300,
                "title": "Provisioning Requests",
                "yAxis": {
                  "left": {
                    "showUnits": false,
                    "label": "Count",
                    "min": 0
                  },
                  "right": {
                    "showUnits": false,
                    "label": "ms",
                    "min": 0
                  }
                }
              }
            },
            {
                "type": "metric",
                "x": 0,
                "y": 18,
                "width": 8,
                "height": 6,
                "properties": {
                    "metrics": [
                        [ "CWAgent-Prometheus", "pg_connections_used", "InstanceName", "a", { "id": "m1", "yAxis": "left", "label": "DB Connections Used" } ],
                        [ "CWAgent-Prometheus", "pg_connections_free", "InstanceName", "a", { "id": "m2", "yAxis": "left", "label": "DB Connections Free" } ]
                    ],
                    "view": "timeSeries",
                    "stacked": true,
                    "region": "eu-west-1",
                    "stat": "Sum",
                    "period": 300,
                    "title": "PostgreSQL Connections",
                    "yAxis": {
                        "left": {
                            "showUnits": false,
                            "label": "Connections",
                            "min": 0
                        }
                    }
                }
            },
            {
                "type": "metric",
                "x": 8,
                "y": 18,
                "width": 8,
                "height": 6,
                "properties": {
                    "view": "timeSeries",
                    "metrics": [
                        [ "CWAgent-Prometheus", "pg_long_running_queries_count", "InstanceName", "a", { "id": "m1", "yAxis": "left", "label": "Long Running Queries" } ]
                    ],
                    "region": "eu-west-1",
                    "stat": "Sum",
                    "period": 300,
                    "title": "Long Running Queries"
                }
            },
            {
                "type": "metric",
                "x": 4,
                "y": 24,
                "width": 4,
                "height": 6,
                "properties": {
                    "sparkline": true,
                    "view": "singleValue",
                    "metrics": [
                        [ "CWAgent-Prometheus", "pg_index_bloat_count", "InstanceName", "a", { "id": "m1", "yAxis": "left", "label": "Index Bloat Count" } ],
                        [ "CWAgent-Prometheus", "pg_table_bloat_count", "InstanceName", "a", { "id": "m2", "yAxis": "left", "label": "Table Bloat Count" } ]
                    ],
                    "region": "eu-west-1",
                    "stat": "Sum",
                    "period": 300,
                    "title": "Bloat Count"
                }
            },
            {
                "type": "metric",
                "x": 0,
                "y": 24,
                "width": 4,
                "height": 6,
                "properties": {
                    "sparkline": true,
                    "view": "singleValue",
                    "metrics": [
                        [ "CWAgent-Prometheus", "pg_datapoint_chunks_needing_compression", "InstanceName", "a", { "id": "m1", "yAxis": "left", "label": "Chunks Needing Compression" } ]
                    ],
                    "region": "eu-west-1",
                    "stat": "Maximum",
                    "period": 86400,
                    "start": "-P1D",
                    "end": "P0D",
                    "title": "Chunks Needing Compression"
                }
            },
            {
                "type": "metric",
                "x": 16,
                "y": 18,
                "width": 8,
                "height": 6,
                "properties": {
                    "view": "gauge",
                    "metrics": [
                        [ "CWAgent-Prometheus", "pg_cache_hit_percentage", "InstanceName", "a", { "id": "m1", "yAxis": "left", "label": "Cache Hit Percentage" } ],
                        [ "CWAgent-Prometheus", "pg_datapoint_uncompressed_cache_hit_ratio", "InstanceName", "a", { "id": "m2", "yAxis": "left", "label": "Uncompressed Cache Hit Ratio" } ]
                    ],
                    "region": "eu-west-1",
                    "stat": "Average",
                    "period": 3600,
                    "title": "Cache Hit",
                    "yAxis": {
                        "left": {
                            "min": 95,
                            "max": 100
                        }
                    }
                }
            },
            {
                "type": "metric",
                "x": 16,
                "y": 24,
                "width": 8,
                "height": 6,
                "properties": {
                    "view": "timeSeries",
                    "metrics": [
                        [ "CWAgent-Prometheus", "pg_timescale_job_total_failures_total", "InstanceName", "a", "proc_name", "_timescaledb_functions.policy_compression", "job_id", "1000", { "id": "m1", "yAxis": "left", "label": "Total Failures" } ]
                    ],
                    "region": "eu-west-1",
                    "stat": "Average",
                    "period": 3600,
                    "title": "Timescale Total Failures",
                    "yAxis": {
                        "left": {
                            "showUnits": false,
                            "label": "Count",
                            "min": 0
                        }
                    }
                }
            },
            {
                "type": "metric",
                "x": 8,
                "y": 24,
                "width": 8,
                "height": 6,
                "properties": {
                    "view": "timeSeries",
                    "metrics": [
                        [ "CWAgent-Prometheus", "pg_dead_tuple_percent", "InstanceName", "a", "table_name", "dashboard", { "id": "m1", "yAxis": "left", "label": "Dashboard" } ],
                        [ "...", "user_asset_link", { "id": "m2", "yAxis": "left", "label": "User Asset Link" } ],
                        [ "...", "global_ruleset", { "id": "m3", "yAxis": "left", "label": "Global Ruleset" } ],
                        [ "...", "realm_ruleset", { "id": "m4", "yAxis": "left", "label": "Realm Ruleset" } ],
                        [ "...", "syslog_event", { "id": "m5", "yAxis": "left", "label": "Syslog Event" } ],
                        [ "...", "asset", { "id": "m6", "yAxis": "left", "label": "Asset" } ],
                        [ "...", "flyway_schema_history", { "id": "m7", "yAxis": "left", "label": "Flyway Schema History" } ],
                        [ "...", "asset_datapoint", { "id": "m8", "yAxis": "left", "label": "Asset Datapoint" } ],
                        [ "...", "provisioning_config", { "id": "m9", "yAxis": "left", "label": "Provisioning Config" } ],
                        [ "...", "notification", { "id": "m10", "yAxis": "left", "label": "Notification" } ],
                        [ "...", "alarm_asset_link", { "id": "m11", "yAxis": "left", "label": "Alarm Asset Link" } ],
                        [ "...", "asset_ruleset", { "id": "m12", "yAxis": "left", "label": "Asset Ruleset" } ],
                        [ "...", "alarm", { "id": "m13", "yAxis": "left", "label": "Alarm" } ],
                        [ "...", "gateway_connection", { "id": "m14", "yAxis": "left", "label": "Gateway Connection" } ],
                        [ "...", "asset_predicted_datapoint", { "id": "m15", "yAxis": "left", "label": "Asset Predicted Datapoint" } ]
                    ],
                    "region": "eu-west-1",
                    "stat": "Average",
                    "period": 300,
                    "title": "Dead Tuple",
                    "yAxis": {
                        "left": {
                            "showUnits": false,
                            "label": "Percent",
                            "min": 0
                        }
                    }
                }
            }
          ]
        }