# Copyright 2018 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: agones-gameservers
  namespace: metrics
  labels:
    grafana_dashboard: "1"
data:
  dashboard-agones-gameservers.json: |
    {
    "annotations": {
      "list": [
        {
          "$$hashKey": "object:261",
          "builtIn": 1,
          "datasource": "-- Grafana --",
          "enable": true,
          "hide": true,
          "iconColor": "rgba(0, 211, 255, 1)",
          "name": "Annotations & Alerts",
          "type": "dashboard"
        }
      ]
    },
    "description": "",
    "editable": true,
    "gnetId": null,
    "graphTooltip": 0,
    "iteration": 1590749685767,
    "links": [],
    "panels": [
      {
        "cacheTimeout": null,
        "datasource": null,
        "gridPos": {
          "h": 6,
          "w": 7,
          "x": 0,
          "y": 0
        },
        "id": 4,
        "links": [],
        "options": {
          "displayMode": "lcd",
          "fieldOptions": {
            "calcs": [
              "mean"
            ],
            "defaults": {
              "mappings": [
                {
                  "from": "",
                  "id": 1,
                  "operator": "",
                  "text": "",
                  "to": "",
                  "type": 1,
                  "value": ""
                }
              ],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 80
                  }
                ]
              },
              "title": "",
              "unit": "short"
            },
            "overrides": [],
            "values": false
          },
          "orientation": "horizontal",
          "showUnfilled": true
        },
        "pluginVersion": "6.7.1",
        "targets": [
          {
            "expr": "sum(agones_gameservers_count{fleet_name=~\"$fleet\", namespace=~\"$namespace\"}) by (type)",
            "format": "time_series",
            "hide": false,
            "instant": true,
            "interval": "",
            "intervalFactor": 1,
            "legendFormat": "{{type}}",
            "refId": "A"
          }
        ],
        "title": "GameServers count per type",
        "type": "bargauge"
      },
      {
        "aliasColors": {},
        "bars": false,
        "dashLength": 10,
        "dashes": false,
        "datasource": null,
        "fill": 1,
        "fillGradient": 0,
        "gridPos": {
          "h": 6,
          "w": 17,
          "x": 7,
          "y": 0
        },
        "hiddenSeries": false,
        "id": 2,
        "legend": {
          "alignAsTable": true,
          "avg": true,
          "current": true,
          "hideEmpty": true,
          "hideZero": true,
          "max": false,
          "min": false,
          "rightSide": true,
          "show": true,
          "total": false,
          "values": true
        },
        "lines": true,
        "linewidth": 1,
        "links": [],
        "nullPointMode": "null",
        "options": {
          "dataLinks": []
        },
        "percentage": false,
        "pointradius": 5,
        "points": false,
        "renderer": "flot",
        "seriesOverrides": [],
        "spaceLength": 10,
        "stack": false,
        "steppedLine": false,
        "targets": [
          {
            "expr": "sum(rate(agones_gameservers_total{fleet_name=~\"$fleet\", namespace=~\"$namespace\"}[$interval])) by (type)",
            "format": "time_series",
            "interval": "",
            "intervalFactor": 1,
            "legendFormat": "{{type}}",
            "refId": "A"
          }
        ],
        "thresholds": [],
        "timeFrom": null,
        "timeRegions": [],
        "timeShift": null,
        "title": "GameServers rate per type",
        "tooltip": {
          "shared": true,
          "sort": 0,
          "value_type": "individual"
        },
        "type": "graph",
        "xaxis": {
          "buckets": null,
          "mode": "time",
          "name": null,
          "show": true,
          "values": []
        },
        "yaxes": [
          {
            "format": "short",
            "label": null,
            "logBase": 1,
            "max": null,
            "min": null,
            "show": true
          },
          {
            "format": "short",
            "label": null,
            "logBase": 1,
            "max": null,
            "min": null,
            "show": true
          }
        ],
        "yaxis": {
          "align": false,
          "alignLevel": null
        }
      },
      {
        "aliasColors": {},
        "bars": false,
        "dashLength": 10,
        "dashes": false,
        "datasource": null,
        "fill": 10,
        "fillGradient": 0,
        "gridPos": {
          "h": 7,
          "w": 12,
          "x": 0,
          "y": 6
        },
        "hiddenSeries": false,
        "id": 7,
        "legend": {
          "alignAsTable": true,
          "avg": true,
          "current": true,
          "hideEmpty": true,
          "hideZero": true,
          "max": false,
          "min": false,
          "rightSide": true,
          "show": true,
          "total": false,
          "values": true
        },
        "lines": true,
        "linewidth": 1,
        "links": [],
        "nullPointMode": "null",
        "options": {
          "dataLinks": []
        },
        "percentage": false,
        "pointradius": 5,
        "points": false,
        "renderer": "flot",
        "seriesOverrides": [],
        "spaceLength": 10,
        "stack": true,
        "steppedLine": false,
        "targets": [
          {
            "expr": "sum(agones_gameservers_count{fleet_name=~\"$fleet\", namespace=~\"$namespace\"}) by (type)",
            "format": "time_series",
            "interval": "",
            "intervalFactor": 1,
            "legendFormat": "{{type}}",
            "refId": "A"
          }
        ],
        "thresholds": [],
        "timeFrom": null,
        "timeRegions": [],
        "timeShift": null,
        "title": "GameServers count per type",
        "tooltip": {
          "shared": true,
          "sort": 0,
          "value_type": "individual"
        },
        "type": "graph",
        "xaxis": {
          "buckets": null,
          "mode": "time",
          "name": null,
          "show": true,
          "values": []
        },
        "yaxes": [
          {
            "format": "short",
            "label": null,
            "logBase": 1,
            "max": null,
            "min": null,
            "show": true
          },
          {
            "format": "short",
            "label": null,
            "logBase": 1,
            "max": null,
            "min": null,
            "show": true
          }
        ],
        "yaxis": {
          "align": false,
          "alignLevel": null
        }
      },
      {
        "aliasColors": {
          "allocated": "#511749",
          "desired": "#ef843c",
          "ready": "#3f6833",
          "total": "#0a50a1"
        },
        "bars": false,
        "dashLength": 10,
        "dashes": false,
        "datasource": null,
        "fill": 1,
        "fillGradient": 0,
        "gridPos": {
          "h": 7,
          "w": 12,
          "x": 12,
          "y": 6
        },
        "hiddenSeries": false,
        "id": 9,
        "legend": {
          "alignAsTable": true,
          "avg": true,
          "current": true,
          "max": false,
          "min": false,
          "rightSide": true,
          "show": true,
          "total": false,
          "values": true
        },
        "lines": true,
        "linewidth": 1,
        "links": [],
        "nullPointMode": "null",
        "options": {
          "dataLinks": []
        },
        "percentage": false,
        "pointradius": 5,
        "points": false,
        "renderer": "flot",
        "seriesOverrides": [],
        "spaceLength": 10,
        "stack": false,
        "steppedLine": false,
        "targets": [
          {
            "expr": "sum(agones_fleets_replicas_count{name=~\"$fleet\", namespace=~\"$namespace\"}) by (type)",
            "format": "time_series",
            "interval": "",
            "intervalFactor": 1,
            "legendFormat": "{{type}}",
            "refId": "A"
          }
        ],
        "thresholds": [],
        "timeFrom": null,
        "timeRegions": [],
        "timeShift": null,
        "title": "Fleet Replicas Count",
        "tooltip": {
          "shared": true,
          "sort": 0,
          "value_type": "individual"
        },
        "type": "graph",
        "xaxis": {
          "buckets": null,
          "mode": "time",
          "name": null,
          "show": true,
          "values": []
        },
        "yaxes": [
          {
            "format": "short",
            "label": null,
            "logBase": 1,
            "max": null,
            "min": null,
            "show": true
          },
          {
            "format": "short",
            "label": null,
            "logBase": 1,
            "max": null,
            "min": null,
            "show": true
          }
        ],
        "yaxis": {
          "align": false,
          "alignLevel": null
        }
      },
      {
        "aliasColors": {},
        "bars": false,
        "dashLength": 10,
        "dashes": false,
        "datasource": null,
        "fill": 1,
        "fillGradient": 0,
        "gridPos": {
          "h": 7,
          "w": 11,
          "x": 0,
          "y": 13
        },
        "hiddenSeries": false,
        "id": 12,
        "legend": {
          "alignAsTable": true,
          "avg": false,
          "current": true,
          "max": false,
          "min": false,
          "rightSide": true,
          "show": true,
          "total": false,
          "values": true
        },
        "lines": true,
        "linewidth": 1,
        "links": [],
        "nullPointMode": "null",
        "options": {
          "dataLinks": []
        },
        "percentage": false,
        "pointradius": 5,
        "points": false,
        "renderer": "flot",
        "seriesOverrides": [],
        "spaceLength": 10,
        "stack": false,
        "steppedLine": false,
        "targets": [
          {
            "expr": "histogram_quantile(1, sum(rate(agones_gameservers_node_count_bucket[1m])) by (le))",
            "format": "time_series",
            "intervalFactor": 1,
            "legendFormat": "max",
            "refId": "F"
          },
          {
            "expr": "histogram_quantile(0.99, sum(rate(agones_gameservers_node_count_bucket[1m])) by (le))",
            "format": "time_series",
            "intervalFactor": 1,
            "legendFormat": "99th",
            "refId": "A"
          },
          {
            "expr": "histogram_quantile(0.90, sum(rate(agones_gameservers_node_count_bucket[1m])) by (le))",
            "format": "time_series",
            "intervalFactor": 1,
            "legendFormat": "90th",
            "refId": "B"
          },
          {
            "expr": "histogram_quantile(0.50, sum(rate(agones_gameservers_node_count_bucket[1m])) by (le))",
            "format": "time_series",
            "intervalFactor": 1,
            "legendFormat": "50th",
            "refId": "C"
          },
          {
            "expr": "histogram_quantile(0, sum(rate(agones_gameservers_node_count_bucket[1m])) by (le))",
            "format": "time_series",
            "intervalFactor": 1,
            "legendFormat": "min",
            "refId": "E"
          },
          {
            "expr": "avg(delta(agones_gameservers_node_count_sum[1m]) / delta(agones_gameservers_node_count_count[1m]))",
            "format": "time_series",
            "interval": "",
            "intervalFactor": 1,
            "legendFormat": "avg",
            "refId": "D"
          }
        ],
        "thresholds": [],
        "timeFrom": null,
        "timeRegions": [],
        "timeShift": null,
        "title": "GameServers per node",
        "tooltip": {
          "shared": true,
          "sort": 0,
          "value_type": "individual"
        },
        "type": "graph",
        "xaxis": {
          "buckets": null,
          "mode": "time",
          "name": null,
          "show": true,
          "values": []
        },
        "yaxes": [
          {
            "$$hashKey": "object:696",
            "format": "short",
            "label": null,
            "logBase": 1,
            "max": null,
            "min": null,
            "show": true
          },
          {
            "$$hashKey": "object:697",
            "format": "short",
            "label": null,
            "logBase": 1,
            "max": null,
            "min": null,
            "show": true
          }
        ],
        "yaxis": {
          "align": false,
          "alignLevel": null
        }
      },
      {
        "aliasColors": {},
        "bars": false,
        "dashLength": 10,
        "dashes": false,
        "datasource": null,
        "fill": 1,
        "fillGradient": 0,
        "gridPos": {
          "h": 7,
          "w": 13,
          "x": 11,
          "y": 13
        },
        "hiddenSeries": false,
        "id": 14,
        "legend": {
          "alignAsTable": true,
          "avg": true,
          "current": true,
          "max": true,
          "min": false,
          "rightSide": true,
          "show": true,
          "total": false,
          "values": true
        },
        "lines": true,
        "linewidth": 1,
        "links": [],
        "nullPointMode": "null",
        "options": {
          "dataLinks": []
        },
        "percentage": false,
        "pointradius": 5,
        "points": false,
        "renderer": "flot",
        "seriesOverrides": [],
        "spaceLength": 10,
        "stack": true,
        "steppedLine": false,
        "targets": [
          {
            "expr": "agones_nodes_count{empty=\"true\"}",
            "format": "time_series",
            "intervalFactor": 1,
            "legendFormat": "unused",
            "refId": "A"
          },
          {
            "expr": "agones_nodes_count{empty=\"false\"}",
            "format": "time_series",
            "intervalFactor": 1,
            "legendFormat": "used",
            "refId": "B"
          }
        ],
        "thresholds": [],
        "timeFrom": null,
        "timeRegions": [],
        "timeShift": null,
        "title": "Node availability (stacked)",
        "tooltip": {
          "shared": true,
          "sort": 0,
          "value_type": "individual"
        },
        "type": "graph",
        "xaxis": {
          "buckets": null,
          "mode": "time",
          "name": null,
          "show": true,
          "values": []
        },
        "yaxes": [
          {
            "format": "short",
            "label": null,
            "logBase": 1,
            "max": null,
            "min": null,
            "show": true
          },
          {
            "format": "short",
            "label": null,
            "logBase": 1,
            "max": null,
            "min": null,
            "show": true
          }
        ],
        "yaxis": {
          "align": false,
          "alignLevel": null
        }
      }
    ],
    "refresh": "5s",
    "schemaVersion": 22,
    "style": "dark",
    "tags": [
      "agones",
      "state",
      "gameservers"
    ],
    "templating": {
      "list": [
        {
          "allValue": ".*",
          "current": {
            "text": "All",
            "value": [
              "$__all"
            ]
          },
          "datasource": "Prometheus",
          "definition": "label_values(agones_gameservers_count, fleet_name)\t",
          "hide": 0,
          "includeAll": true,
          "index": -1,
          "label": null,
          "multi": true,
          "name": "fleet",
          "options": [],
          "query": "label_values(agones_gameservers_count, fleet_name)\t",
          "refresh": 2,
          "regex": "",
          "skipUrlSync": false,
          "sort": 0,
          "tagValuesQuery": "",
          "tags": [],
          "tagsQuery": "",
          "type": "query",
          "useTags": false
        },
        {
          "auto": true,
          "auto_count": 30,
          "auto_min": "1m",
          "current": {
            "selected": false,
            "text": "auto",
            "value": "$__auto_interval_interval"
          },
          "hide": 0,
          "label": null,
          "name": "interval",
          "options": [
            {
              "selected": true,
              "text": "auto",
              "value": "$__auto_interval_interval"
            },
            {
              "selected": false,
              "text": "1m",
              "value": "1m"
            },
            {
              "selected": false,
              "text": "10m",
              "value": "10m"
            },
            {
              "selected": false,
              "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",
          "refresh": 2,
          "skipUrlSync": false,
          "type": "interval"
        },
        {
          "allValue": null,
          "current": {
            "text": "All",
            "value": [
              "$__all"
            ]
          },
          "datasource": "Prometheus",
          "definition": "label_values(agones_gameservers_count, namespace)",
          "hide": 0,
          "includeAll": true,
          "index": -1,
          "label": null,
          "multi": true,
          "name": "namespace",
          "options": [],
          "query": "label_values(agones_gameservers_count, namespace)",
          "refresh": 2,
          "regex": "",
          "skipUrlSync": false,
          "sort": 0,
          "tagValuesQuery": "",
          "tags": [],
          "tagsQuery": "",
          "type": "query",
          "useTags": false
        }
      ]
    },
    "time": {
      "from": "now-15m",
      "to": "now"
    },
    "timepicker": {
      "refresh_intervals": [
        "5s",
        "10s",
        "30s",
        "1m",
        "5m",
        "15m",
        "30m",
        "1h",
        "2h",
        "1d"
      ],
      "time_options": [
        "5m",
        "15m",
        "1h",
        "6h",
        "12h",
        "24h",
        "2d",
        "7d",
        "30d"
      ]
    },
    "timezone": "",
    "title": "Agones GameServers",
    "uid": "D78OotUmk",
    "variables": {
      "list": []
    },
    "version": 1
    }
