# Copyright 2021 Google LLC All Rights Reserved.
#
# 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.

# configs map used by grafana
apiVersion: v1
kind: ConfigMap
metadata:
  name: quilkin-general
  namespace: metrics
  labels:
    grafana_dashboard: "1"
data:
  dashboard-agones-gameservers.json: |
    {
      "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"
          }
        ]
      },
      "editable": true,
      "fiscalYearStartMonth": 0,
      "gnetId": null,
      "graphTooltip": 0,
      "iteration": 1638396359116,
      "links": [],
      "liveNow": false,
      "panels": [
        {
          "datasource": null,
          "description": "",
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "thresholds"
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  }
                ]
              },
              "unit": "decbytes"
            },
            "overrides": []
          },
          "gridPos": {
            "h": 8,
            "w": 5,
            "x": 0,
            "y": 0
          },
          "id": 11,
          "options": {
            "colorMode": "value",
            "graphMode": "area",
            "justifyMode": "auto",
            "orientation": "auto",
            "reduceOptions": {
              "calcs": [
                  "lastNotNull"
              ],
              "fields": "",
              "values": false
            },
            "text": {},
            "textMode": "auto"
          },
          "pluginVersion": "8.2.1",
          "repeat": null,
          "targets": [
            {
              "exemplar": true,
              "expr": "sum(increase(quilkin_session_tx_bytes_total[$interval]))",
              "instant": false,
              "interval": "",
              "legendFormat": "Transmit",
              "refId": "A"
            },
            {
              "exemplar": true,
              "expr": "sum(increase(quilkin_session_rx_bytes_total[$interval]))",
              "hide": false,
              "instant": false,
              "interval": "",
              "legendFormat": "Receive",
              "refId": "B"
            }
          ],
          "title": "Network Traffic [$interval]",
          "type": "stat"
        },
        {
          "datasource": null,
          "description": "",
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "thresholds"
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "#EAB839",
                    "value": 20
                  },
                  {
                    "color": "red",
                    "value": 50
                  }
                ]
              },
              "unit": "none"
            },
            "overrides": []
          },
          "gridPos": {
            "h": 8,
            "w": 4,
            "x": 5,
            "y": 0
          },
          "id": 8,
          "options": {
            "colorMode": "value",
            "graphMode": "area",
            "justifyMode": "auto",
            "orientation": "auto",
            "reduceOptions": {
              "calcs": [
                  "lastNotNull"
              ],
              "fields": "",
              "values": false
            },
            "text": {},
            "textMode": "auto"
          },
          "pluginVersion": "8.2.1",
          "targets": [
            {
              "exemplar": true,
              "expr": "sum(rate(quilkin_session_tx_errors_total[$interval]))",
              "instant": true,
              "interval": "",
              "legendFormat": "Transmit",
              "refId": "A"
            },
            {
              "exemplar": true,
              "expr": "sum(rate(quilkin_session_rx_errors_total[$interval]))",
              "hide": false,
              "instant": true,
              "interval": "",
              "legendFormat": "Receive",
              "refId": "B"
            }
          ],
          "title": "Errors [$interval]",
          "type": "stat"
        },
        {
          "datasource": null,
          "description": "",
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "palette-classic"
              },
              "custom": {
                "axisLabel": "",
                "axisPlacement": "auto",
                "barAlignment": 0,
                "drawStyle": "line",
                "fillOpacity": 3,
                "gradientMode": "none",
                "hideFrom": {
                  "legend": false,
                  "tooltip": false,
                  "viz": false
                },
                "lineInterpolation": "linear",
                "lineWidth": 1,
                "pointSize": 5,
                "scaleDistribution": {
                  "type": "linear"
                },
                "showPoints": "never",
                "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": 15,
            "x": 9,
            "y": 0
          },
          "id": 2,
          "options": {
            "legend": {
              "calcs": [],
              "displayMode": "list",
              "placement": "bottom"
            },
            "tooltip": {
              "mode": "single"
            }
          },
          "pluginVersion": "8.0.3",
          "targets": [
            {
              "exemplar": true,
              "expr": "count(sum(quilkin_cluster_active{}) by (instance))",
              "format": "time_series",
              "interval": "",
              "legendFormat": "instances",
              "refId": "A"
            },
            {
              "exemplar": true,
              "expr": "sum(quilkin_cluster_active_endpoints)",
              "hide": false,
              "interval": "",
              "legendFormat": "endpoints",
              "refId": "B"
            },
            {
              "exemplar": true,
              "expr": "sum(quilkin_session_active)",
              "hide": false,
              "interval": "",
              "legendFormat": "active_sessions",
              "refId": "C"
            }
          ],
          "title": "Quilkin Instances & Sessions",
          "type": "timeseries"
        },
        {
          "datasource": null,
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "palette-classic"
              },
              "custom": {
                "axisLabel": "",
                "axisPlacement": "auto",
                "barAlignment": 0,
                "drawStyle": "line",
                "fillOpacity": 3,
                "gradientMode": "none",
                "hideFrom": {
                  "legend": false,
                  "tooltip": false,
                  "viz": false
                },
                "lineInterpolation": "linear",
                "lineStyle": {
                  "fill": "solid"
                },
                "lineWidth": 1,
                "pointSize": 5,
                "scaleDistribution": {
                  "type": "linear"
                },
                "showPoints": "never",
                "spanNulls": false,
                "stacking": {
                  "group": "A",
                  "mode": "none"
                },
                "thresholdsStyle": {
                  "mode": "off"
                }
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 80
                  }
                ]
              },
              "unit": "decbytes"
            },
            "overrides": []
          },
          "gridPos": {
            "h": 8,
            "w": 24,
            "x": 0,
            "y": 8
          },
          "id": 4,
          "options": {
            "legend": {
              "calcs": [],
              "displayMode": "list",
              "placement": "bottom"
            },
            "tooltip": {
              "mode": "single"
            }
          },
          "targets": [
            {
              "exemplar": true,
              "expr": "sum(rate(quilkin_session_tx_bytes_total[$__rate_interval]))",
              "interval": "",
              "legendFormat": "transmit rate",
              "refId": "A"
            },
            {
              "exemplar": true,
              "expr": "sum(rate(quilkin_session_rx_bytes_total[$__rate_interval]))",
              "hide": false,
              "interval": "",
              "legendFormat": "receive rate",
              "refId": "B"
            },
            {
              "exemplar": true,
              "expr": "sum(rate(quilkin_proxy_packets_dropped_total[$__rate_interval]))",
              "hide": false,
              "interval": "",
              "legendFormat": "dropped packet rate",
              "refId": "C"
            },
            {
              "exemplar": true,
              "expr": "sum(rate(quilkin_session_rx_errors_total[$__rate_interval]))",
              "hide": false,
              "interval": "",
              "legendFormat": "receive error rate",
              "refId": "D"
            },
            {
              "exemplar": true,
              "expr": "sum(rate(quilkin_session_tx_errors_total[$__rate_interval]))",
              "hide": false,
              "interval": "",
              "legendFormat": "transmit error rate",
              "refId": "E"
            }
          ],
          "title": "Network Traffic Rates",
          "type": "timeseries"
        },
        {
          "datasource": null,
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "palette-classic"
              },
              "custom": {
                "axisLabel": "",
                "axisPlacement": "auto",
                "barAlignment": 0,
                "drawStyle": "line",
                "fillOpacity": 3,
                "gradientMode": "none",
                "hideFrom": {
                  "legend": false,
                  "tooltip": false,
                  "viz": false
                },
                "lineInterpolation": "linear",
                "lineWidth": 1,
                "pointSize": 5,
                "scaleDistribution": {
                  "type": "linear"
                },
                "showPoints": "never",
                "spanNulls": false,
                "stacking": {
                  "group": "A",
                  "mode": "none"
                },
                "thresholdsStyle": {
                  "mode": "off"
                }
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 80
                  }
                ]
              },
              "unit": "s"
            },
            "overrides": []
          },
          "gridPos": {
            "h": 8,
            "w": 12,
            "x": 0,
            "y": 16
          },
          "id": 6,
          "options": {
            "legend": {
              "calcs": [],
              "displayMode": "list",
              "placement": "bottom"
            },
            "tooltip": {
              "mode": "single"
            }
          },
          "targets": [
            {
              "exemplar": true,
              "expr": " histogram_quantile(0.5,sum(rate(quilkin_session_duration_secs_bucket[$__rate_interval])) by (le))",
              "interval": "",
              "legendFormat": "50%",
              "refId": "A"
            },
            {
              "exemplar": true,
              "expr": " histogram_quantile(0.9,sum(rate(quilkin_session_duration_secs_bucket[$__rate_interval])) by (le))",
              "format": "time_series",
              "hide": false,
              "interval": "",
              "legendFormat": "90%",
              "refId": "B"
            },
            {
              "exemplar": true,
              "expr": " histogram_quantile(0.99,sum(rate(quilkin_session_duration_secs_bucket[$__rate_interval])) by (le))",
              "hide": false,
              "interval": "",
              "legendFormat": "99%",
              "refId": "C"
            }
          ],
          "title": "Session Length",
          "type": "timeseries"
        },
        {
          "datasource": null,
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "palette-classic"
              },
              "custom": {
                "axisLabel": "",
                "axisPlacement": "auto",
                "barAlignment": 0,
                "drawStyle": "line",
                "fillOpacity": 3,
                "gradientMode": "none",
                "hideFrom": {
                  "legend": false,
                  "tooltip": false,
                  "viz": false
                },
                "lineInterpolation": "linear",
                "lineWidth": 1,
                "pointSize": 5,
                "scaleDistribution": {
                  "type": "linear"
                },
                "showPoints": "never",
                "spanNulls": false,
                "stacking": {
                  "group": "A",
                  "mode": "none"
                },
                "thresholdsStyle": {
                  "mode": "off"
                }
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  }
                ]
              },
              "unit": "s"
            },
            "overrides": [
              {
                "matcher": {
                  "id": "byName",
                  "options": "(total) 50%"
                },
                "properties": [
                  {
                    "id": "color",
                    "value": {
                      "fixedColor": "super-light-green",
                      "mode": "fixed"
                    }
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "(total) 90%"
                },
                "properties": [
                  {
                    "id": "color",
                    "value": {
                      "fixedColor": "semi-dark-green",
                      "mode": "fixed"
                    }
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "(total) 99%"
                },
                "properties": [
                  {
                    "id": "color",
                    "value": {
                      "fixedColor": "dark-green",
                      "mode": "fixed"
                    }
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "(read) 50%"
                },
                "properties": [
                  {
                    "id": "color",
                    "value": {
                      "fixedColor": "super-light-orange",
                      "mode": "fixed"
                    }
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "(read) 90%"
                },
                "properties": [
                  {
                    "id": "color",
                    "value": {
                      "fixedColor": "semi-dark-orange",
                      "mode": "fixed"
                    }
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "(read) 99%"
                },
                "properties": [
                  {
                    "id": "color",
                    "value": {
                      "fixedColor": "dark-orange",
                      "mode": "fixed"
                    }
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "(write) 50%"
                },
                "properties": [
                  {
                    "id": "color",
                    "value": {
                      "fixedColor": "super-light-purple",
                      "mode": "fixed"
                    }
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "(write) 90%"
                },
                "properties": [
                  {
                    "id": "color",
                    "value": {
                      "fixedColor": "semi-dark-purple",
                      "mode": "fixed"
                    }
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "(write) 99%"
                },
                "properties": [
                  {
                    "id": "color",
                    "value": {
                      "fixedColor": "dark-purple",
                      "mode": "fixed"
                    }
                  }
                ]
              }
            ]
          },
          "gridPos": {
            "h": 8,
            "w": 12,
            "x": 12,
            "y": 16
          },
          "id": 14,
          "options": {
            "legend": {
              "calcs": [],
              "displayMode": "list",
              "placement": "bottom"
            },
            "tooltip": {
              "mode": "single"
            }
          },
          "targets": [
            {
              "exemplar": true,
              "expr": "histogram_quantile(0.5,sum(rate(quilkin_proxy_packet_processing_duration_seconds_bucket[$__rate_interval])) by (le))",
              "interval": "",
              "legendFormat": "(total) 50%",
              "refId": "A"
            },
            {
              "exemplar": true,
              "expr": "histogram_quantile(0.9,sum(rate(quilkin_proxy_packet_processing_duration_seconds_bucket[$__rate_interval])) by (le))",
              "format": "time_series",
              "hide": false,
              "interval": "",
              "legendFormat": "(total) 90%",
              "refId": "B"
            },
            {
              "exemplar": true,
              "expr": "histogram_quantile(0.99,sum(rate(quilkin_proxy_packet_processing_duration_seconds_bucket[$__rate_interval])) by (le))",
              "hide": false,
              "interval": "",
              "legendFormat": "(total) 99%",
              "refId": "C"
            },
            {
              "exemplar": true,
              "expr": "histogram_quantile(0.5,sum(rate(quilkin_proxy_packet_processing_duration_seconds_bucket{event=\"read\"}[$__rate_interval])) by (le))",
              "hide": false,
              "interval": "",
              "legendFormat": "(read) 50%",
              "refId": "D"
            },
            {
              "exemplar": true,
              "expr": "histogram_quantile(0.9,sum(rate(quilkin_proxy_packet_processing_duration_seconds_bucket{event=\"read\"}[$__rate_interval])) by (le))",
              "hide": false,
              "interval": "",
              "legendFormat": "(read) 90%",
              "refId": "E"
            },
            {
              "exemplar": true,
              "expr": "histogram_quantile(0.99,sum(rate(quilkin_proxy_packet_processing_duration_seconds_bucket{event=\"read\"}[$__rate_interval])) by (le))",
              "hide": false,
              "interval": "",
              "legendFormat": "(read) 99%",
              "refId": "F"
            },
            {
              "exemplar": true,
              "expr": "histogram_quantile(0.5,sum(rate(quilkin_proxy_packet_processing_duration_seconds_bucket{event=\"write\"}[$__rate_interval])) by (le))",
              "hide": false,
              "interval": "",
              "legendFormat": "(write) 50%",
              "refId": "G"
            },
            {
              "exemplar": true,
              "expr": "histogram_quantile(0.9,sum(rate(quilkin_proxy_packet_processing_duration_seconds_bucket{event=\"write\"}[$__rate_interval])) by (le))",
              "hide": false,
              "interval": "",
              "legendFormat": "(write) 90%",
              "refId": "H"
            },
            {
              "exemplar": true,
              "expr": "histogram_quantile(0.99,sum(rate(quilkin_proxy_packet_processing_duration_seconds_bucket{event=\"write\"}[$__rate_interval])) by (le))",
              "hide": false,
              "interval": "",
              "legendFormat": "(write) 99%",
              "refId": "I"
            }
          ],
          "title": "Packet Processing Time",
          "type": "timeseries"
        }
      ],
      "refresh": "10s",
      "schemaVersion": 31,
      "style": "dark",
      "tags": [],
      "templating": {
        "list": [
          {
            "auto": false,
            "auto_count": 30,
            "auto_min": "10s",
            "current": {
              "selected": false,
              "text": "30m",
              "value": "30m"
            },
            "description": null,
            "error": null,
            "hide": 0,
            "label": null,
            "name": "interval",
            "options": [
              {
                "selected": false,
                "text": "1m",
                "value": "1m"
              },
              {
                "selected": false,
                "text": "10m",
                "value": "10m"
              },
              {
                "selected": true,
                "text": "30m",
                "value": "30m"
              },
              {
                "selected": false,
                "text": "1h",
                "value": "1h"
              },
              {
                "selected": false,
                "text": "6h",
                "value": "6h"
              },
              {
                "selected": false,
                "text": "12h",
                "value": "12h"
              },
              {
                "selected": false,
                "text": "1d",
                "value": "1d"
              },
              {
                "selected": false,
                "text": "7d",
                "value": "7d"
              },
              {
                "selected": false,
                "text": "14d",
                "value": "14d"
              },
              {
                "selected": false,
                "text": "30d",
                "value": "30d"
              }
            ],
            "query": "1m,10m,30m,1h,6h,12h,1d,7d,14d,30d",
            "queryValue": "",
            "refresh": 2,
            "skipUrlSync": false,
            "type": "interval"
          }
        ]
      },
      "time": {
        "from": "now-15m",
        "to": "now"
      },
      "timepicker": {},
      "timezone": "",
      "title": "Quilkin General Metrics",
      "uid": "QAbeZjgnk",
      "version": 1
    }