---
apiVersion: v1
kind: ConfigMap
metadata:
  name: thanos-compactor-dashboard
  namespace: kubenav
  labels:
    kubenav.io/prometheus-dashboard: "true"
data:
  title: "Thanos Compactor"
  description: "Dashboard for Thanos Compactor Metrics"
  variables: |
    [
      {
        "name": "Namespace",
        "label": "namespace",
        "query": "thanos_compact_group_compactions_total",
        "allowAll": false
      },
      {
        "name": "Pod",
        "label": "pod",
        "query": "thanos_compact_group_compactions_total{namespace=~\"{{ .Namespace }}\"}",
        "allowAll": true
      }
    ]
  charts: |
    [
      {
        "title": "Group Compaction: Rate",
        "unit": "",
        "size": {
          "xs": "12",
          "sm": "12",
          "md": "12",
          "lg": "6",
          "xl": "6"
        },
        "type": "area",
        "queries": [
          {
            "label": "{{ .group }}",
            "query": "sum(rate(thanos_compact_group_compactions_total{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m])) by (group)"
          }
        ]
      },
      {
        "title": "Group Compaction: Errors",
        "unit": "%",
        "size": {
          "xs": "12",
          "sm": "12",
          "md": "12",
          "lg": "6",
          "xl": "6"
        },
        "type": "area",
        "queries": [
          {
            "label": "Errors",
            "query": "sum(rate(thanos_compact_group_compactions_failures_total{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m])) / sum(rate(thanos_compact_group_compactions_total{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m])) * 100"
          }
        ]
      },
      {
        "title": "Downsample: Rate",
        "unit": "",
        "size": {
          "xs": "12",
          "sm": "12",
          "md": "12",
          "lg": "6",
          "xl": "6"
        },
        "type": "area",
        "queries": [
          {
            "label": "{{ .group }}",
            "query": "sum(rate(thanos_compact_downsample_total{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m])) by (group)"
          }
        ]
      },
      {
        "title": "Downsample: Errors",
        "unit": "%",
        "size": {
          "xs": "12",
          "sm": "12",
          "md": "12",
          "lg": "6",
          "xl": "6"
        },
        "type": "area",
        "queries": [
          {
            "label": "Errors",
            "query": "sum(rate(thanos_compact_downsample_failed_total{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m])) / sum(rate(thanos_compact_downsample_total{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m])) * 100"
          }
        ]
      },
      {
        "title": "Garbage Collection: Rate",
        "unit": "",
        "size": {
          "xs": "12",
          "sm": "12",
          "md": "12",
          "lg": "4",
          "xl": "4"
        },
        "type": "area",
        "queries": [
          {
            "label": "Rate",
            "query": "sum(rate(thanos_compact_garbage_collection_total{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m]))"
          }
        ]
      },
      {
        "title": "Garbage Collection: Errors",
        "unit": "%",
        "size": {
          "xs": "12",
          "sm": "12",
          "md": "12",
          "lg": "4",
          "xl": "4"
        },
        "type": "area",
        "queries": [
          {
            "label": "Errors",
            "query": "sum(rate(thanos_compact_garbage_collection_failures_total{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m])) / sum(rate(thanos_compact_garbage_collection_total{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m])) * 100"
          }
        ]
      },
      {
        "title": "Garbage Collection: Duration",
        "unit": "s",
        "size": {
          "xs": "12",
          "sm": "12",
          "md": "12",
          "lg": "4",
          "xl": "4"
        },
        "type": "area",
        "queries": [
          {
            "label": "P99",
            "query": "histogram_quantile(0.99, sum(rate(thanos_compact_garbage_collection_duration_seconds_bucket{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m])) by (le)) * 1"
          },
          {
            "label": "P90",
            "query": "histogram_quantile(0.90, sum(rate(thanos_compact_garbage_collection_duration_seconds_bucket{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m])) by (le)) * 1"
          },
          {
            "label": "P50",
            "query": "histogram_quantile(0.50, sum(rate(thanos_compact_garbage_collection_duration_seconds_bucket{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m])) by (le)) * 1"
          },
          {
            "label": "Mean",
            "query": "sum(rate(thanos_compact_garbage_collection_duration_seconds_sum{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m])) * 1 / sum(rate(thanos_compact_garbage_collection_duration_seconds_count{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m]))"
          }
        ]
      },
      {
        "title": "Sync Meta: Rate",
        "unit": "",
        "size": {
          "xs": "12",
          "sm": "12",
          "md": "12",
          "lg": "4",
          "xl": "4"
        },
        "type": "area",
        "queries": [
          {
            "label": "Rate",
            "query": "sum(rate(thanos_blocks_meta_syncs_total{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m]))"
          }
        ]
      },
      {
        "title": "Sync Meta: Errors",
        "unit": "%",
        "size": {
          "xs": "12",
          "sm": "12",
          "md": "12",
          "lg": "4",
          "xl": "4"
        },
        "type": "area",
        "queries": [
          {
            "label": "Errors",
            "query": "sum(rate(thanos_blocks_meta_sync_failures_total{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m])) / sum(rate(thanos_blocks_meta_syncs_total{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m])) * 100"
          }
        ]
      },
      {
        "title": "Sync Meta: Duration",
        "unit": "s",
        "size": {
          "xs": "12",
          "sm": "12",
          "md": "12",
          "lg": "4",
          "xl": "4"
        },
        "type": "area",
        "queries": [
          {
            "label": "P99",
            "query": "histogram_quantile(0.99, sum(rate(thanos_blocks_meta_sync_duration_seconds_bucket{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m])) by (le)) * 1"
          },
          {
            "label": "P90",
            "query": "histogram_quantile(0.90, sum(rate(thanos_blocks_meta_sync_duration_seconds_bucket{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m])) by (le)) * 1"
          },
          {
            "label": "P50",
            "query": "histogram_quantile(0.50, sum(rate(thanos_blocks_meta_sync_duration_seconds_bucket{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m])) by (le)) * 1"
          },
          {
            "label": "Mean",
            "query": "sum(rate(thanos_blocks_meta_sync_duration_seconds_sum{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m])) * 1 / sum(rate(thanos_blocks_meta_sync_duration_seconds_count{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m]))"
          }
        ]
      },
      {
        "title": "Object Store Operations: Rate",
        "unit": "",
        "size": {
          "xs": "12",
          "sm": "12",
          "md": "12",
          "lg": "4",
          "xl": "4"
        },
        "type": "area",
        "queries": [
          {
            "label": "{{ .pod }}",
            "query": "sum(rate(thanos_objstore_bucket_operations_total{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m]))"
          }
        ]
      },
      {
        "title": "Object Store Operations: Errors",
        "unit": "%",
        "size": {
          "xs": "12",
          "sm": "12",
          "md": "12",
          "lg": "4",
          "xl": "4"
        },
        "type": "area",
        "queries": [
          {
            "label": "Errors",
            "query": "sum(rate(thanos_objstore_bucket_operation_failures_total{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m])) / sum(rate(thanos_objstore_bucket_operations_total{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m])) * 100"
          }
        ]
      },
      {
        "title": "Object Store Operations: Duration",
        "unit": "s",
        "size": {
          "xs": "12",
          "sm": "12",
          "md": "12",
          "lg": "4",
          "xl": "4"
        },
        "type": "area",
        "queries": [
          {
            "label": "P99",
            "query": "histogram_quantile(0.99, sum(rate(thanos_objstore_bucket_operation_duration_seconds_bucket{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m])) by (le)) * 1"
          },
          {
            "label": "P90",
            "query": "histogram_quantile(0.90, sum(rate(thanos_objstore_bucket_operation_duration_seconds_bucket{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m])) by (le)) * 1"
          },
          {
            "label": "P50",
            "query": "histogram_quantile(0.50, sum(rate(thanos_objstore_bucket_operation_duration_seconds_bucket{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m])) by (le)) * 1"
          },
          {
            "label": "Mean",
            "query": "sum(rate(thanos_objstore_bucket_operation_duration_seconds_sum{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m])) * 1 / sum(rate(thanos_objstore_bucket_operation_duration_seconds_count{namespace=~\"{{ .Namespace }}\", pod=~\"{{ .Pod }}\"}[5m]))"
          }
        ]
      }
    ]
