{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "Observability Solution from CloudWatch: JVM on EC2. Version: 1.0.0.",
  "Transform": "AWS::LanguageExtensions",
  "Parameters": {
    "DashboardNameParameter": {
      "Type": "String",
      "Description": "Enter name of the dashboard, the maximum length is 255, and valid characters are A-Z, a-z, 0-9, \"-\", and \"_\". The dashboard will display metrics from the region where the stack is being created. To easily differentiate this dashboard from similar ones in other regions, we recommend including the region name in the dashboard name.",
      "MinLength": "1",
      "MaxLength": "255",
      "AllowedPattern": "^[a-zA-Z0-9-_]*$",
      "Default": "JVMDashboard"
    }
  },
  "Resources": {
    "CloudWatchDashboard": {
      "Type": "AWS::CloudWatch::Dashboard",
      "Properties": {
        "DashboardName": {
          "Ref": "DashboardNameParameter"
        },
        "DashboardBody": {
          "Fn::ToJsonString": {
            "variables": [
              {
                "type": "pattern",
                "pattern": "JvmProcessGroupName",
                "inputType": "select",
                "id": "JvmProcessGroupName",
                "label": "JVM Process Group Name",
                "defaultValue": "__FIRST",
                "visible": true,
                "search": "{CWAgent,InstanceId,ProcessGroupName} MetricName=\"jvm.memory.heap.used\"",
                "populateFrom": "ProcessGroupName"
              }
            ],
            "widgets": [
              {
                "height": 3,
                "width": 24,
                "y": 0,
                "x": 0,
                "type": "text",
                "properties": {
                  "markdown": "# Overview\nThis part of the dashboard gives you a high-level summary of the activities and performance on JvmProcessGroupName.\n**Note**: To view data from a different JVM process group, use the `JVM Process Group Name` drop-down box at the top of the dashboard.",
                  "background": "transparent"
                }
              },
              {
                "height": 8,
                "width": 9,
                "y": 3,
                "x": 7,
                "type": "metric",
                "properties": {
                  "metrics": [
                    [
                      {
                        "expression": "MAX(REMOVE_EMPTY(SEARCH('{CWAgent,InstanceId,ProcessGroupName} MetricName=\"jvm.threads.count\" ProcessGroupName=\"JvmProcessGroupName\"', 'Maximum', 60)))",
                        "id": "m1",
                        "period": 60,
                        "label": "Max Threads Count [avg: ${AVG}, max: ${MAX}]"
                      }
                    ],
                    [
                      {
                        "expression": "AVG(REMOVE_EMPTY(SEARCH('{CWAgent,InstanceId,ProcessGroupName} MetricName=\"jvm.threads.count\" ProcessGroupName=\"JvmProcessGroupName\"', 'Maximum', 60)))",
                        "id": "m2",
                        "period": 60,
                        "label": "Average Threads Count [avg: ${AVG}, max: ${MAX}]"
                      }
                    ]
                  ],
                  "yAxis": {
                    "left": {
                      "label": "Count",
                      "showUnits": false,
                      "min": 0
                    }
                  },
                  "view": "timeSeries",
                  "stacked": false,
                  "region": {
                    "Ref": "AWS::Region"
                  },
                  "stat": "Average",
                  "period": 60,
                  "title": "Threads count"
                }
              },
              {
                "height": 8,
                "width": 8,
                "y": 3,
                "x": 16,
                "type": "metric",
                "properties": {
                  "metrics": [
                    [
                      {
                        "expression": "MAX(e1)",
                        "id": "m1",
                        "period": 60,
                        "label": "Max GC Duration [avg: ${AVG}, max: ${MAX}]"
                      }
                    ],
                    [
                      {
                        "expression": "AVG(e1)",
                        "id": "m2",
                        "period": 60,
                        "label": "Average GC Duration [avg: ${AVG}, max: ${MAX}]"
                      }
                    ],
                    [
                      {
                        "expression": "REMOVE_EMPTY(SEARCH('{CWAgent,InstanceId,ProcessGroupName,name} MetricName=\"jvm.gc.collections.elapsed\" ProcessGroupName=\"JvmProcessGroupName\"', 'Sum', 60))",
                        "id": "e1",
                        "period": 60,
                        "label": "GC Duration",
                        "visible": false
                      }
                    ]
                  ],
                  "yAxis": {
                    "left": {
                      "label": "Milliseconds",
                      "showUnits": false,
                      "min": 0
                    }
                  },
                  "view": "timeSeries",
                  "stacked": false,
                  "region": {
                    "Ref": "AWS::Region"
                  },
                  "stat": "Average",
                  "period": 60,
                  "title": "Garbage collection duration"
                }
              },
              {
                "height": 2,
                "width": 24,
                "y": 11,
                "x": 0,
                "type": "text",
                "properties": {
                  "markdown": "# JVM host metrics\nThe following sections provide a more detailed look at the top contributing servers for various JVM metrics, in your selected JVM process group.",
                  "background": "transparent"
                }
              },
              {
                "height": 8,
                "width": 8,
                "y": 16,
                "x": 0,
                "type": "metric",
                "properties": {
                  "metrics": [
                    [
                      {
                        "expression": "SORT(SEARCH('{CWAgent,InstanceId,ProcessGroupName} MetricName=\"jvm.memory.heap.used\" ProcessGroupName=\"JvmProcessGroupName\"', 'Average', 60), MAX, DESC, 10)",
                        "id": "m1",
                        "period": 60,
                        "label": "Used [avg: ${AVG}, max: ${MAX}] - ${PROP('Dim.InstanceId')}"
                      }
                    ],
                    [
                      {
                        "expression": "AVG(SEARCH('{CWAgent,InstanceId,ProcessGroupName} MetricName=\"jvm.memory.heap.used\" ProcessGroupName=\"JvmProcessGroupName\"', 'Average', 60))",
                        "id": "e1",
                        "period": 60,
                        "label": "Average Used [avg: ${AVG}, max: ${MAX}]"
                      }
                    ]
                  ],
                  "yAxis": {
                    "left": {
                      "label": "Bytes",
                      "showUnits": false,
                      "min": 0
                    }
                  },
                  "view": "timeSeries",
                  "stacked": false,
                  "region": {
                    "Ref": "AWS::Region"
                  },
                  "stat": "Average",
                  "period": 60,
                  "title": "Top 10 heap memory used"
                }
              },
              {
                "height": 8,
                "width": 12,
                "y": 34,
                "x": 0,
                "type": "metric",
                "properties": {
                  "metrics": [
                    [
                      {
                        "expression": "SORT(SEARCH('{CWAgent,InstanceId,ProcessGroupName} MetricName=\"jvm.threads.count\" ProcessGroupName=\"JvmProcessGroupName\"', 'Average', 60), MAX, DESC, 10)",
                        "id": "m1",
                        "period": 60,
                        "label": "Threads Count [avg: ${AVG}, max: ${MAX}] - ${PROP('Dim.InstanceId')}"
                      }
                    ],
                    [
                      {
                        "expression": "AVG(SEARCH('{CWAgent,InstanceId,ProcessGroupName} MetricName=\"jvm.threads.count\" ProcessGroupName=\"JvmProcessGroupName\"', 'Average', 60))",
                        "id": "e1",
                        "period": 60,
                        "label": "Average Threads Count [avg: ${AVG}, max: ${MAX}]"
                      }
                    ]
                  ],
                  "yAxis": {
                    "left": {
                      "label": "Count",
                      "showUnits": false,
                      "min": 0
                    }
                  },
                  "view": "timeSeries",
                  "stacked": false,
                  "region": {
                    "Ref": "AWS::Region"
                  },
                  "stat": "Average",
                  "period": 60,
                  "title": "Top 10 threads count"
                }
              },
              {
                "height": 8,
                "width": 12,
                "y": 34,
                "x": 12,
                "type": "metric",
                "properties": {
                  "metrics": [
                    [
                      {
                        "expression": "SORT(SEARCH('{CWAgent,InstanceId,ProcessGroupName} MetricName=\"jvm.classes.loaded\" ProcessGroupName=\"JvmProcessGroupName\"', 'Average', 60), MAX, DESC, 10)",
                        "id": "m1",
                        "period": 60,
                        "label": "Classes Loaded [avg: ${AVG}, max: ${MAX}] - ${PROP('Dim.InstanceId')}"
                      }
                    ],
                    [
                      {
                        "expression": "AVG(SEARCH('{CWAgent,InstanceId,ProcessGroupName} MetricName=\"jvm.classes.loaded\" ProcessGroupName=\"JvmProcessGroupName\"', 'Average', 60))",
                        "id": "e1",
                        "period": 60,
                        "label": "Average Classes Loaded [avg: ${AVG}, max: ${MAX}]"
                      }
                    ]
                  ],
                  "yAxis": {
                    "left": {
                      "label": "Count",
                      "showUnits": false,
                      "min": 0
                    }
                  },
                  "view": "timeSeries",
                  "stacked": false,
                  "region": {
                    "Ref": "AWS::Region"
                  },
                  "stat": "Average",
                  "period": 60,
                  "title": "Top 10 classes loaded"
                }
              },
              {
                "height": 8,
                "width": 8,
                "y": 24,
                "x": 0,
                "type": "metric",
                "properties": {
                  "metrics": [
                    [
                      {
                        "expression": "SORT(SEARCH('{CWAgent,InstanceId,ProcessGroupName} MetricName=\"jvm.memory.nonheap.used\" ProcessGroupName=\"JvmProcessGroupName\"', 'Average', 60), MAX, DESC, 10)",
                        "id": "m1",
                        "period": 60,
                        "label": "Used [avg: ${AVG}, max: ${MAX}] - ${PROP('Dim.InstanceId')}"
                      }
                    ],
                    [
                      {
                        "expression": "AVG(SEARCH('{CWAgent,InstanceId,ProcessGroupName} MetricName=\"jvm.memory.nonheap.used\" ProcessGroupName=\"JvmProcessGroupName\"', 'Average', 60))",
                        "id": "e1",
                        "period": 60,
                        "label": "Average Used [avg: ${AVG}, max: ${MAX}]"
                      }
                    ]
                  ],
                  "yAxis": {
                    "left": {
                      "label": "Bytes",
                      "showUnits": false,
                      "min": 0
                    }
                  },
                  "view": "timeSeries",
                  "stacked": false,
                  "region": {
                    "Ref": "AWS::Region"
                  },
                  "stat": "Average",
                  "period": 60,
                  "title": "Top 10 non-heap memory used"
                }
              },
              {
                "height": 3,
                "width": 24,
                "y": 13,
                "x": 0,
                "type": "text",
                "properties": {
                  "markdown": "## Memory usage by host\nThis section provides visibility into the memory usage of hosts in the selected JVM process group. Heap usage metrics help you identify memory leaks and manage memory allocation issues. The non-heap metrics are crucial for monitoring the performance of the JVM.\nWhen maximum heap memory or non-heap memory displays as negative, it means that the maximum is not configured and the metric emits -1 for that metric.",
                  "background": "transparent"
                }
              },
              {
                "height": 2,
                "width": 24,
                "y": 32,
                "x": 0,
                "type": "text",
                "properties": {
                  "markdown": "## Threads and classes loaded by host\nThis section provides visibility into the threads and classes loaded of hosts on the selected JVM process group. An unexpected high number of threads can indicate issues such as thread leaks or high concurrency demands. The number of classes loaded can help detect excessive dynamic class creation.",
                  "background": "transparent"
                }
              },
              {
                "height": 4,
                "width": 24,
                "y": 42,
                "x": 0,
                "type": "text",
                "properties": {
                  "markdown": "## Garbage collection\nThis section provides visibility into the garbage collection of hosts on the selected JVM process group. Use the number of garbage collections to monitor memory issues or suboptimal JVM settings. High garbage collection time might indicate that the JVM is struggling to free memory efficiently.\nThe heap is partitioned into a set of equal-sized heap regions, each a contiguous range of virtual memory with no fixed size for Eden, Survivor, or Old. This provides greater flexibility and efficiency. G1 (Garbage first) performs a concurrent global marking phase to determine the liveness of objects throughout the heap.\nMinor GC moves the live objects from Eden to Survivor 1 (or Survivor 2) when Eden memory exceeds its limit. In a mixed garbage collection, the G1 GC optionally adds some old regions to the set of eden and survivor regions that will be collected. The exact number of old regions added is controlled by a number of flags. Full GC performs in-place compaction of the entire heap and might be slow. Full garbage collections are still single threaded, but if tuned properly your applications should avoid full garbage collections.\n",
                  "background": "transparent"
                }
              },
              {
                "height": 8,
                "width": 12,
                "y": 56,
                "x": 0,
                "type": "metric",
                "properties": {
                  "metrics": [
                    [
                      {
                        "expression": "SEARCH('{CWAgent,InstanceId,ProcessGroupName,name} MetricName=\"jvm.gc.collections.count\" ProcessGroupName=\"JvmProcessGroupName\" name=\"G1 Young Generation\"', 'Sum', 60)",
                        "id": "e2",
                        "period": 60,
                        "label": "GC Count",
                        "visible": false
                      }
                    ],
                    [
                      {
                        "expression": "SORT(e2, MAX, DESC, 10)",
                        "label": "Invocations Per Minute [last: ${LAST}, max: ${MAX}, sum: ${SUM}] - ${PROP('Dim.InstanceId')}"
                      }
                    ],
                    [
                      {
                        "expression": "AVG(e2)",
                        "label": "Average Invocations [avg: ${AVG}]",
                        "id": "m2"
                      }
                    ]
                  ],
                  "yAxis": {
                    "left": {
                      "label": "Count",
                      "showUnits": false,
                      "min": 0
                    }
                  },
                  "view": "timeSeries",
                  "stacked": false,
                  "region": {
                    "Ref": "AWS::Region"
                  },
                  "stat": "Average",
                  "period": 60,
                  "title": "Top 10 garbage collection invocations per minute"
                }
              },
              {
                "height": 1,
                "width": 24,
                "y": 46,
                "x": 0,
                "type": "text",
                "properties": {
                  "markdown": "### G1 concurrent garbage collection invocations and duration",
                  "background": "transparent"
                }
              },
              {
                "height": 8,
                "width": 12,
                "y": 56,
                "x": 12,
                "type": "metric",
                "properties": {
                  "metrics": [
                    [
                      {
                        "expression": "SEARCH('{CWAgent,InstanceId,ProcessGroupName,name} MetricName=\"jvm.gc.collections.elapsed\" ProcessGroupName=\"JvmProcessGroupName\" name=\"G1 Young Generation\"', 'Sum', 60)",
                        "id": "e2",
                        "period": 60,
                        "label": "GC Duration",
                        "visible": false
                      }
                    ],
                    [
                      {
                        "expression": "SORT(e2, MAX, DESC, 10)",
                        "label": "Duration [last: ${LAST}, max: ${MAX}, sum: ${SUM}] - ${PROP('Dim.InstanceId')}"
                      }
                    ],
                    [
                      {
                        "expression": "AVG(e2)",
                        "label": "Average Duration [avg: ${AVG}]",
                        "id": "m2"
                      }
                    ]
                  ],
                  "yAxis": {
                    "left": {
                      "label": "Milliseconds",
                      "showUnits": false,
                      "min": 0
                    }
                  },
                  "view": "timeSeries",
                  "stacked": false,
                  "region": {
                    "Ref": "AWS::Region"
                  },
                  "stat": "Average",
                  "period": 60,
                  "title": "Top 10 garbage collection duration"
                }
              },
              {
                "height": 1,
                "width": 24,
                "y": 55,
                "x": 0,
                "type": "text",
                "properties": {
                  "markdown": "### Minor garbage collection invocations and duration",
                  "background": "transparent"
                }
              },
              {
                "height": 8,
                "width": 12,
                "y": 47,
                "x": 0,
                "type": "metric",
                "properties": {
                  "metrics": [
                    [
                      {
                        "expression": "SEARCH('{CWAgent,InstanceId,ProcessGroupName,name} MetricName=\"jvm.gc.collections.count\" ProcessGroupName=\"JvmProcessGroupName\" name=\"G1 Concurrent GC\"', 'Sum', 60)",
                        "id": "e2",
                        "period": 60,
                        "label": "GC Count",
                        "visible": false
                      }
                    ],
                    [
                      {
                        "expression": "SORT(e2, MAX, DESC, 10)",
                        "label": "Invocations Per Minute [last: ${LAST}, max: ${MAX}, sum: ${SUM}] - ${PROP('Dim.InstanceId')}"
                      }
                    ],
                    [
                      {
                        "expression": "AVG(e2)",
                        "label": "Average Invocations [avg: ${AVG}]",
                        "id": "m2"
                      }
                    ]
                  ],
                  "yAxis": {
                    "left": {
                      "label": "Count",
                      "showUnits": false,
                      "min": 0
                    }
                  },
                  "view": "timeSeries",
                  "stacked": false,
                  "region": {
                    "Ref": "AWS::Region"
                  },
                  "stat": "Average",
                  "period": 60,
                  "title": "Top 10 garbage collection invocations per minute"
                }
              },
              {
                "height": 8,
                "width": 12,
                "y": 47,
                "x": 12,
                "type": "metric",
                "properties": {
                  "metrics": [
                    [
                      {
                        "expression": "SEARCH('{CWAgent,InstanceId,ProcessGroupName,name} MetricName=\"jvm.gc.collections.elapsed\" ProcessGroupName=\"JvmProcessGroupName\" name=\"G1 Concurrent GC\"', 'Sum', 60)",
                        "id": "e2",
                        "period": 60,
                        "label": "GC Duration",
                        "visible": false
                      }
                    ],
                    [
                      {
                        "expression": "SORT(e2, MAX, DESC, 10)",
                        "label": "Duration [last: ${LAST}, max: ${MAX}, sum: ${SUM}] - ${PROP('Dim.InstanceId')}"
                      }
                    ],
                    [
                      {
                        "expression": "AVG(e2)",
                        "label": "Average Duration [avg: ${AVG}]",
                        "id": "m2"
                      }
                    ]
                  ],
                  "yAxis": {
                    "left": {
                      "label": "Milliseconds",
                      "showUnits": false,
                      "min": 0
                    }
                  },
                  "view": "timeSeries",
                  "stacked": false,
                  "region": {
                    "Ref": "AWS::Region"
                  },
                  "stat": "Average",
                  "period": 60,
                  "title": "Top 10 garbage collection duration"
                }
              },
              {
                "height": 1,
                "width": 24,
                "y": 64,
                "x": 0,
                "type": "text",
                "properties": {
                  "markdown": "### Mixed garbage collection invocations and duration",
                  "background": "transparent"
                }
              },
              {
                "height": 8,
                "width": 12,
                "y": 65,
                "x": 0,
                "type": "metric",
                "properties": {
                  "metrics": [
                    [
                      {
                        "expression": "SEARCH('{CWAgent,InstanceId,ProcessGroupName,name} MetricName=\"jvm.gc.collections.count\" ProcessGroupName=\"JvmProcessGroupName\" name=\"G1 Old Generation\"', 'Sum', 60)",
                        "id": "e2",
                        "period": 60,
                        "label": "GC Count",
                        "visible": false
                      }
                    ],
                    [
                      {
                        "expression": "SORT(e2, MAX, DESC, 10)",
                        "label": "Invocations Per Minute [last: ${LAST}, max: ${MAX}, sum: ${SUM}] - ${PROP('Dim.InstanceId')}"
                      }
                    ],
                    [
                      {
                        "expression": "AVG(e2)",
                        "label": "Average Invocations [avg: ${AVG}]",
                        "id": "m2"
                      }
                    ]
                  ],
                  "yAxis": {
                    "left": {
                      "label": "Count",
                      "showUnits": false,
                      "min": 0
                    }
                  },
                  "view": "timeSeries",
                  "stacked": false,
                  "region": {
                    "Ref": "AWS::Region"
                  },
                  "stat": "Average",
                  "period": 60,
                  "title": "Top 10 garbage collection invocations per minute"
                }
              },
              {
                "height": 8,
                "width": 12,
                "y": 65,
                "x": 12,
                "type": "metric",
                "properties": {
                  "metrics": [
                    [
                      {
                        "expression": "SEARCH('{CWAgent,InstanceId,ProcessGroupName,name} MetricName=\"jvm.gc.collections.elapsed\" ProcessGroupName=\"JvmProcessGroupName\" name=\"G1 Old Generation\"', 'Sum', 60)",
                        "id": "e2",
                        "period": 60,
                        "label": "GC Duration",
                        "visible": false
                      }
                    ],
                    [
                      {
                        "expression": "SORT(e2, MAX, DESC, 10)",
                        "label": "Duration [last: ${LAST}, max: ${MAX}, sum: ${SUM}] - ${PROP('Dim.InstanceId')}"
                      }
                    ],
                    [
                      {
                        "expression": "AVG(e2)",
                        "label": "Average Duration [avg: ${AVG}]",
                        "id": "m2"
                      }
                    ]
                  ],
                  "yAxis": {
                    "left": {
                      "label": "Milliseconds",
                      "showUnits": false,
                      "min": 0
                    }
                  },
                  "view": "timeSeries",
                  "stacked": false,
                  "region": {
                    "Ref": "AWS::Region"
                  },
                  "stat": "Average",
                  "period": 60,
                  "title": "Top 10 garbage collection duration"
                }
              },
              {
                "height": 4,
                "width": 7,
                "y": 3,
                "x": 0,
                "type": "metric",
                "properties": {
                  "metrics": [
                    [
                      {
                        "expression": "AVG(REMOVE_EMPTY(SEARCH('{CWAgent,InstanceId,ProcessGroupName} MetricName=\"jvm.memory.heap.used\" ProcessGroupName=\"JvmProcessGroupName\"', 'Maximum', 60)))",
                        "id": "heap_memory_used",
                        "period": 60,
                        "label": "Heap Memory Used [avg: ${AVG}, max: ${MAX}]",
                        "visible": false
                      }
                    ],
                    [
                      {
                        "expression": "AVG(REMOVE_EMPTY(SEARCH('{CWAgent,InstanceId,ProcessGroupName} MetricName=\"jvm.memory.heap.max\" ProcessGroupName=\"JvmProcessGroupName\"', 'Maximum', 60)))",
                        "id": "heap_memory_max",
                        "period": 60,
                        "label": "Heap Memory Max [avg: ${AVG}, max: ${MAX}]",
                        "visible": false
                      }
                    ],
                    [
                      {
                        "expression": "100*(heap_memory_used/denominator)",
                        "label": "Heap Memory Usage [avg: ${AVG}, max: ${MAX}]",
                        "id": "e1"
                      }
                    ],
                    [
                      {
                        "expression": "IF(heap_memory_max>0, heap_memory_max,1)",
                        "id": "denominator",
                        "period": 60,
                        "label": "normalized denominator",
                        "visible": false
                      }
                    ]
                  ],
                  "sparkline": true,
                  "view": "singleValue",
                  "region": {
                    "Ref": "AWS::Region"
                  },
                  "period": 60,
                  "title": "Heap memory usage percentage",
                  "stat": "Average"
                }
              },
              {
                "height": 4,
                "width": 7,
                "y": 7,
                "x": 0,
                "type": "metric",
                "properties": {
                  "metrics": [
                    [
                      {
                        "expression": "AVG(REMOVE_EMPTY(SEARCH('{CWAgent,InstanceId,ProcessGroupName} MetricName=\"jvm.memory.nonheap.used\" ProcessGroupName=\"JvmProcessGroupName\"', 'Maximum', 60)))",
                        "id": "non_heap_memory_used",
                        "period": 60,
                        "label": "Non Heap Memory Used [avg: ${AVG}, max: ${MAX}]",
                        "visible": false
                      }
                    ],
                    [
                      {
                        "expression": "AVG(REMOVE_EMPTY(SEARCH('{CWAgent,InstanceId,ProcessGroupName} MetricName=\"jvm.memory.nonheap.max\" ProcessGroupName=\"JvmProcessGroupName\"', 'Maximum', 60)))",
                        "id": "non_heap_memory_max",
                        "period": 60,
                        "label": "Non Heap Memory Max [avg: ${AVG}, max: ${MAX}]",
                        "visible": false
                      }
                    ],
                    [
                      {
                        "expression": "100*(non_heap_memory_used/non_heap_memory_max)",
                        "label": "percentage",
                        "id": "percentage",
                        "visible": false
                      }
                    ],
                    [
                      {
                        "expression": "IF(percentage>0, percentage, nan)",
                        "id": "result",
                        "period": 60,
                        "label": "Non-heap Memory Usage [avg: ${AVG}, max: ${MAX}]"
                      }
                    ],
                    [
                      {
                        "expression": "1/0",
                        "label": "Not A Number",
                        "id": "nan",
                        "visible": false
                      }
                    ]
                  ],
                  "sparkline": true,
                  "view": "singleValue",
                  "region": {
                    "Ref": "AWS::Region"
                  },
                  "period": 60,
                  "title": "Non-heap memory usage percentage",
                  "stat": "Average"
                }
              },
              {
                "height": 8,
                "width": 8,
                "y": 16,
                "x": 8,
                "type": "metric",
                "properties": {
                  "metrics": [
                    [
                      {
                        "expression": "SORT(SEARCH('{CWAgent,InstanceId,ProcessGroupName} MetricName=\"jvm.memory.heap.committed\" ProcessGroupName=\"JvmProcessGroupName\"', 'Average', 60), MAX, DESC, 10)",
                        "id": "m1",
                        "period": 60,
                        "label": "Committed [avg: ${AVG}, max: ${MAX}] - ${PROP('Dim.InstanceId')}"
                      }
                    ],
                    [
                      {
                        "expression": "AVG(SEARCH('{CWAgent,InstanceId,ProcessGroupName} MetricName=\"jvm.memory.heap.committed\" ProcessGroupName=\"JvmProcessGroupName\"', 'Average', 60))",
                        "id": "e1",
                        "period": 60,
                        "label": "Average Committed [avg: ${AVG}, max: ${MAX}]"
                      }
                    ]
                  ],
                  "yAxis": {
                    "left": {
                      "label": "Bytes",
                      "showUnits": false,
                      "min": 0
                    }
                  },
                  "view": "timeSeries",
                  "stacked": false,
                  "region": {
                    "Ref": "AWS::Region"
                  },
                  "stat": "Average",
                  "period": 60,
                  "title": "Top 10 heap memory committed"
                }
              },
              {
                "height": 8,
                "width": 8,
                "y": 16,
                "x": 16,
                "type": "metric",
                "properties": {
                  "metrics": [
                    [
                      {
                        "expression": "SORT(SEARCH('{CWAgent,InstanceId,ProcessGroupName} MetricName=\"jvm.memory.heap.max\" ProcessGroupName=\"JvmProcessGroupName\"', 'Average', 60), MAX, DESC, 10)",
                        "id": "m1",
                        "period": 60,
                        "label": "Max [avg: ${AVG}, max: ${MAX}] - ${PROP('Dim.InstanceId')}"
                      }
                    ],
                    [
                      {
                        "expression": "AVG(SEARCH('{CWAgent,InstanceId,ProcessGroupName} MetricName=\"jvm.memory.heap.max\" ProcessGroupName=\"JvmProcessGroupName\"', 'Average', 60))",
                        "id": "e1",
                        "period": 60,
                        "label": "Average Max [avg: ${AVG}, max: ${MAX}]"
                      }
                    ]
                  ],
                  "yAxis": {
                    "left": {
                      "label": "Bytes",
                      "showUnits": false,
                      "min": 0
                    }
                  },
                  "view": "timeSeries",
                  "stacked": false,
                  "region": {
                    "Ref": "AWS::Region"
                  },
                  "stat": "Average",
                  "period": 60,
                  "title": "Top 10 heap memory max"
                }
              },
              {
                "height": 8,
                "width": 8,
                "y": 24,
                "x": 8,
                "type": "metric",
                "properties": {
                  "metrics": [
                    [
                      {
                        "expression": "SORT(SEARCH('{CWAgent,InstanceId,ProcessGroupName} MetricName=\"jvm.memory.nonheap.committed\" ProcessGroupName=\"JvmProcessGroupName\"', 'Average', 60), MAX, DESC, 10)",
                        "id": "m1",
                        "period": 60,
                        "label": "Committed [avg: ${AVG}, max: ${MAX}] - ${PROP('Dim.InstanceId')}"
                      }
                    ],
                    [
                      {
                        "expression": "AVG(SEARCH('{CWAgent,InstanceId,ProcessGroupName} MetricName=\"jvm.memory.nonheap.committed\" ProcessGroupName=\"JvmProcessGroupName\"', 'Average', 60))",
                        "id": "e1",
                        "period": 60,
                        "label": "Average Committed [avg: ${AVG}, max: ${MAX}]"
                      }
                    ]
                  ],
                  "yAxis": {
                    "left": {
                      "label": "Bytes",
                      "showUnits": false,
                      "min": 0
                    }
                  },
                  "view": "timeSeries",
                  "stacked": false,
                  "region": {
                    "Ref": "AWS::Region"
                  },
                  "stat": "Average",
                  "period": 60,
                  "title": "Top 10 non-heap memory committed"
                }
              },
              {
                "height": 8,
                "width": 8,
                "y": 24,
                "x": 16,
                "type": "metric",
                "properties": {
                  "metrics": [
                    [
                      {
                        "expression": "SORT(SEARCH('{CWAgent,InstanceId,ProcessGroupName} MetricName=\"jvm.memory.nonheap.max\" ProcessGroupName=\"JvmProcessGroupName\"', 'Average', 60), MAX, DESC, 10)",
                        "id": "m1",
                        "period": 60,
                        "label": "Max [avg: ${AVG}, max: ${MAX}] - ${PROP('Dim.InstanceId')}"
                      }
                    ],
                    [
                      {
                        "expression": "AVG(SEARCH('{CWAgent,InstanceId,ProcessGroupName} MetricName=\"jvm.memory.nonheap.max\" ProcessGroupName=\"JvmProcessGroupName\"', 'Average', 60))",
                        "id": "e1",
                        "period": 60,
                        "label": "Average Max [avg: ${AVG}, max: ${MAX}]"
                      }
                    ]
                  ],
                  "yAxis": {
                    "left": {
                      "label": "Bytes",
                      "showUnits": false
                    }
                  },
                  "view": "timeSeries",
                  "stacked": false,
                  "region": {
                    "Ref": "AWS::Region"
                  },
                  "stat": "Average",
                  "period": 60,
                  "title": "Top 10 non-heap memory max"
                }
              },
              {
                "height": 3,
                "width": 24,
                "y": 73,
                "x": 0,
                "type": "text",
                "properties": {
                  "markdown": {
                    "Fn::Join": [
                      "",
                      [
                        "# EC2 metrics\nTo view the AWS/EC2 vended metrics for your EC2 instances, refer to the [Amazon EC2 CloudWatch Automatic Dashboard](https://",
                        {
                          "Ref": "AWS::Region"
                        },
                        ".console.aws.amazon.com/cloudwatch/home?region=",
                        {
                          "Ref": "AWS::Region"
                        },
                        "#home:dashboards/EC2).\n\n\nTo view system-level metrics collected by the CloudWatch agent deployed to your EC2 instances, refer the Monitoring tab for the relevant instance on the [Amazon EC2 console](https://",
                        {
                          "Ref": "AWS::Region"
                        },
                        ".console.aws.amazon.com/ec2/home#Instances)."
                      ]
                    ]
                  },
                  "background": "transparent"
                }
              }
            ]
          }
        }
      }
    }
  }
}