# Copyright 2022 Red Hat, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
data:
  ccx_notification_writer_dashboard.json: |-
    {
      "__requires": [
        {
          "type": "grafana",
          "id": "grafana",
          "name": "Grafana",
          "version": "8.2.1"
        },
        {
          "type": "datasource",
          "id": "prometheus",
          "name": "Prometheus",
          "version": "1.0.0"
        },
        {
          "type": "panel",
          "id": "timeseries",
          "name": "Time series",
          "version": ""
        }
      ],
      "annotations": {
        "list": [
          {
            "builtIn": 1,
            "datasource": "-- Grafana --",
            "enable": true,
            "hide": true,
            "iconColor": "rgba(0, 211, 255, 1)",
            "name": "Annotations & Alerts",
            "target": {
              "limit": 100,
              "matchAny": false,
              "tags": [],
              "type": "dashboard"
            },
            "type": "dashboard"
          }
        ]
      },
      "description": "Dashboard for CCX notification writer",
      "editable": true,
      "fiscalYearStartMonth": 0,
      "gnetId": null,
      "graphTooltip": 0,
      "id": null,
      "iteration": 1635415825277,
      "links": [],
      "liveNow": false,
      "panels": [
        {
          "collapsed": false,
          "datasource": null,
          "gridPos": {
            "h": 1,
            "w": 24,
            "x": 0,
            "y": 0
          },
          "id": 4,
          "panels": [],
          "repeat": "datasource",
          "title": "CCX Notification Writer",
          "type": "row"
        },
        {
          "datasource": "${datasource}",
          "description": "Metrics for operations related to consumed messages handling",
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "palette-classic"
              },
              "custom": {
                "axisLabel": "",
                "axisPlacement": "auto",
                "barAlignment": 0,
                "drawStyle": "line",
                "fillOpacity": 0,
                "gradientMode": "none",
                "hideFrom": {
                  "legend": false,
                  "tooltip": false,
                  "viz": false
                },
                "lineInterpolation": "linear",
                "lineWidth": 1,
                "pointSize": 5,
                "scaleDistribution": {
                  "type": "linear"
                },
                "showPoints": "auto",
                "spanNulls": false,
                "stacking": {
                  "group": "A",
                  "mode": "none"
                },
                "thresholdsStyle": {
                  "mode": "off"
                }
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 80
                  }
                ]
              }
            },
            "overrides": []
          },
          "gridPos": {
            "h": 8,
            "w": 12,
            "x": 0,
            "y": 1
          },
          "id": 16,
          "options": {
            "legend": {
              "calcs": [],
              "displayMode": "list",
              "placement": "bottom"
            },
            "tooltip": {
              "mode": "single"
            }
          },
          "targets": [
            {
              "exemplar": true,
              "expr": "sum(rate(ccx_notification_writer_check_last_checked_timestamp{namespace=\"$namespace\"}[1m]))",
              "interval": "",
              "legendFormat": "",
              "refId": "A"
            },
            {
              "exemplar": true,
              "expr": "sum(rate(ccx_notification_writer_check_schema_version{namespace=\"$namespace\"}[1m]))",
              "hide": false,
              "interval": "",
              "legendFormat": "",
              "refId": "B"
            },
            {
              "exemplar": true,
              "expr": "sum(rate(ccx_notification_writer_consumed_messages{namespace=\"$namespace\"}[1m]))",
              "hide": false,
              "interval": "",
              "legendFormat": "",
              "refId": "C"
            },
            {
              "exemplar": true,
              "expr": "sum(rate(ccx_notification_writer_marshal_report{namespace=\"$namespace\"}[1m]))",
              "hide": false,
              "interval": "",
              "legendFormat": "",
              "refId": "D"
            },
            {
              "exemplar": true,
              "expr": "sum(rate(ccx_notification_writer_parse_incoming_message{namespace=\"$namespace\"}[1m]))",
              "hide": false,
              "interval": "",
              "legendFormat": "",
              "refId": "E"
            }
          ],
          "title": "Incoming metrics",
          "type": "timeseries"
        },
        {
          "datasource": "${datasource}",
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "palette-classic"
              },
              "custom": {
                "axisLabel": "",
                "axisPlacement": "auto",
                "barAlignment": 0,
                "drawStyle": "line",
                "fillOpacity": 0,
                "gradientMode": "none",
                "hideFrom": {
                  "legend": false,
                  "tooltip": false,
                  "viz": false
                },
                "lineInterpolation": "linear",
                "lineWidth": 1,
                "pointSize": 5,
                "scaleDistribution": {
                  "type": "linear"
                },
                "showPoints": "auto",
                "spanNulls": false,
                "stacking": {
                  "group": "A",
                  "mode": "none"
                },
                "thresholdsStyle": {
                  "mode": "off"
                }
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 80
                  }
                ]
              }
            },
            "overrides": []
          },
          "gridPos": {
            "h": 8,
            "w": 12,
            "x": 12,
            "y": 1
          },
          "id": 18,
          "options": {
            "legend": {
              "calcs": [],
              "displayMode": "list",
              "placement": "bottom"
            },
            "tooltip": {
              "mode": "single"
            }
          },
          "targets": [
            {
              "exemplar": true,
              "expr": "sum(rate(ccx_notification_writer_shrink_report{namespace=\"$namespace\"}[1m]))",
              "interval": "",
              "legendFormat": "",
              "refId": "A"
            },
            {
              "exemplar": true,
              "expr": "sum(rate(ccx_notification_writer_marshal_report{namespace=\"$namespace\"}[1m]))",
              "hide": false,
              "interval": "",
              "legendFormat": "",
              "refId": "B"
            },
            {
              "exemplar": true,
              "expr": "sum(rate(ccx_notification_writer_stored_messages{namespace=\"$namespace\"}[1m]))",
              "hide": false,
              "interval": "",
              "legendFormat": "",
              "refId": "C"
            }
          ],
          "title": "Outgoing metrics",
          "type": "timeseries"
        },
        {
          "datasource": "${datasource}",
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "palette-classic"
              },
              "custom": {
                "axisLabel": "",
                "axisPlacement": "auto",
                "barAlignment": 0,
                "drawStyle": "line",
                "fillOpacity": 0,
                "gradientMode": "none",
                "hideFrom": {
                  "legend": false,
                  "tooltip": false,
                  "viz": false
                },
                "lineInterpolation": "linear",
                "lineWidth": 1,
                "pointSize": 5,
                "scaleDistribution": {
                  "type": "linear"
                },
                "showPoints": "auto",
                "spanNulls": false,
                "stacking": {
                  "group": "A",
                  "mode": "none"
                },
                "thresholdsStyle": {
                  "mode": "off"
                }
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 80
                  }
                ]
              }
            },
            "overrides": []
          },
          "gridPos": {
            "h": 8,
            "w": 12,
            "x": 0,
            "y": 9
          },
          "id": 20,
          "options": {
            "legend": {
              "calcs": [],
              "displayMode": "list",
              "placement": "bottom"
            },
            "tooltip": {
              "mode": "single"
            }
          },
          "targets": [
            {
              "exemplar": true,
              "expr": "sum(rate(ccx_notification_writer_stored_bytes{namespace=\"$namespace\"}[1m]))",
              "interval": "",
              "legendFormat": "",
              "refId": "A"
            }
          ],
          "title": "Bytes stored per minute",
          "type": "timeseries"
        }
      ],
      "refresh": "",
      "schemaVersion": 31,
      "style": "dark",
      "tags": [],
      "templating": {
        "list": [
          {
            "current": {
              "selected": true,
              "text": "crcs02ue1-prometheus",
              "value": "crcs02ue1-prometheus"
            },
            "description": null,
            "error": null,
            "hide": 0,
            "includeAll": false,
            "label": "datasource",
            "multi": false,
            "name": "datasource",
            "options": [],
            "query": "prometheus",
            "queryValue": "",
            "refresh": 1,
            "regex": "/.*(crcs|crcp)0[1-2]ue1-prometheus.*/",
            "skipUrlSync": false,
            "type": "datasource"
          },
          {
            "allValue": null,
            "current": {
              "selected": true,
              "text": "ccx-data-pipeline-stage",
              "value": "ccx-data-pipeline-stage"
            },
            "description": null,
            "error": null,
            "hide": 0,
            "includeAll": false,
            "label": "namespace",
            "multi": false,
            "name": "namespace",
            "options": [
              {
                "selected": true,
                "text": "ccx-data-pipeline-stage",
                "value": "ccx-data-pipeline-stage"
              },
              {
                "selected": false,
                "text": "ccx-data-pipeline-prod",
                "value": "ccx-data-pipeline-prod"
              }
            ],
            "query": "ccx-data-pipeline-stage,ccx-data-pipeline-prod",
            "queryValue": "",
            "skipUrlSync": false,
            "type": "custom"
          }
        ]
      },
      "time": {
        "from": "now-1h",
        "to": "now"
      },
      "timepicker": {},
      "timezone": "",
      "title": "CCX Notification Writer",
      "uid": "9mNv3nK7z",
      "version": 11
    }
kind: ConfigMap
metadata:
  name: grafana-dashboard-ccx-notification-writer
  labels:
    grafana_dashboard: "true"
  annotations:
    grafana-folder: /grafana-dashboard-definitions/Insights

