---
apiVersion: v1
kind: ConfigMap
metadata:
  name: jvm-dashboard
  namespace: kubenav
  labels:
    kubenav.io/prometheus-dashboard: "true"
data:
  title: "JVM"
  description: "Dashboard for JVM Metrics"
  variables: |
    [
      {
        "name": "Namespace",
        "label": "namespace",
        "query": "jvm_classes_loaded",
        "allowAll": false
      },
      {
        "name": "Pod",
        "label": "pod",
        "query": "jvm_classes_loaded{namespace=~\"{{ .Namespace }}\"}",
        "allowAll": false
      }
    ]
  charts: |
    [
      {
        "title": "Memory Usage",
        "unit": "MiB",
        "size": {
          "xs": "12",
          "sm": "12",
          "md": "12",
          "lg": "6",
          "xl": "6"
        },
        "type": "area",
        "queries": [
          {
            "label": "Memory Usage",
            "query": "sum(container_memory_usage_bytes{namespace=\"{{ .Namespace }}\", pod=\"{{ .Pod }}\", container!=\"\", container!=\"POD\"}) / 1024 / 1024"
          }
        ]
      },
      {
        "title": "CPU Usage",
        "unit": "Cores",
        "size": {
          "xs": "12",
          "sm": "12",
          "md": "12",
          "lg": "6",
          "xl": "6"
        },
        "type": "area",
        "queries": [
          {
            "label": "CP Usage",
            "query": "sum(rate(container_cpu_user_seconds_total{namespace=\"{{ .Namespace }}\", pod=\"{{ .Pod }}\"}[1m]))"
          }
        ]
      },
      {
        "title": "Memory Used",
        "unit": "MiB",
        "size": {
          "xs": "12",
          "sm": "12",
          "md": "12",
          "lg": "4",
          "xl": "4"
        },
        "type": "area",
        "queries": [
          {
            "label": "Memory Used",
            "query": "sum(rate(jvm_memory_bytes_used{namespace=\"{{ .Namespace }}\", pod=\"{{ .Pod }}\"}[1m])) / 1024 / 1024"
          }
        ]
      },
      {
        "title": "GC Time",
        "unit": "s",
        "size": {
          "xs": "12",
          "sm": "12",
          "md": "12",
          "lg": "4",
          "xl": "4"
        },
        "type": "area",
        "queries": [
          {
            "label": "{{ .gc }}",
            "query": "sum(rate(jvm_gc_collection_seconds_sum{namespace=\"{{ .Namespace }}\", pod=\"{{ .Pod }}\"}[1m])) by (gc)"
          }
        ]
      },
      {
        "title": "GC Count",
        "unit": "",
        "size": {
          "xs": "12",
          "sm": "12",
          "md": "12",
          "lg": "4",
          "xl": "4"
        },
        "type": "area",
        "queries": [
          {
            "label": "{{ .gc }}",
            "query": "sum(rate(jvm_gc_collection_seconds_count{namespace=\"{{ .Namespace }}\", pod=\"{{ .Pod }}\"}[1m])) by (gc)"
          }
        ]
      },
      {
        "title": "Classes Loaded",
        "unit": "",
        "size": {
          "xs": "12",
          "sm": "12",
          "md": "12",
          "lg": "6",
          "xl": "6"
        },
        "type": "area",
        "queries": [
          {
            "label": "Classes",
            "query": "sum(jvm_classes_loaded{namespace=\"{{ .Namespace }}\", pod=\"{{ .Pod }}\"})"
          }
        ]
      },
      {
        "title": "Thread Count",
        "unit": "",
        "size": {
          "xs": "12",
          "sm": "12",
          "md": "12",
          "lg": "6",
          "xl": "6"
        },
        "type": "area",
        "queries": [
          {
            "label": "Threads",
            "query": "sum(jvm_threads_current{namespace=\"{{ .Namespace }}\", pod=\"{{ .Pod }}\"})"
          }
        ]
      }
    ]
