apiVersion: v1
kind: ConfigMap
metadata:
  name: phoenix-api-dashboard
  labels:
    grafana_dashboard: "true"
data:
  phoenix-api-dashboard.json: |-
    {
      "__inputs": [
        {
          "name": "Prometheus",
          "label": "Prometheus",
          "description": "",
          "type": "datasource",
          "pluginId": "prometheus",
          "pluginName": "Prometheus"
        }
      ],
      "__requires": [
        {
          "type": "grafana",
          "id": "grafana",
          "name": "Grafana",
          "version": "5.2.3"
        },
        {
          "type": "panel",
          "id": "graph",
          "name": "Graph",
          "version": "5.0.0"
        },
        {
          "type": "panel",
          "id": "heatmap",
          "name": "Heatmap",
          "version": "5.0.0"
        },
        {
          "type": "datasource",
          "id": "prometheus",
          "name": "Prometheus",
          "version": "5.0.0"
        }
      ],
      "annotations": {
        "list": [
          {
            "builtIn": 1,
            "datasource": "-- Grafana --",
            "enable": true,
            "hide": true,
            "iconColor": "rgba(0, 211, 255, 1)",
            "name": "Annotations & Alerts",
            "type": "dashboard"
          }
        ]
      },
      "description": "Metrics of all Phoenix APIs in the cluster that implement Prometheus",
      "editable": true,
      "gnetId": null,
      "graphTooltip": 0,
      "id": null,
      "iteration": 1547740641793,
      "links": [],
      "panels": [
        {
          "aliasColors": {
            "discovery-api/fetch_dataset_detail": "rgb(74, 193, 177)",
            "discovery-api/fetch_full_csv": "rgb(41, 110, 117)",
            "discovery-api/fetch_query": "rgb(230, 241, 241)",
            "discovery-api/search": "rgb(0, 74, 191)"
          },
          "bars": false,
          "dashLength": 10,
          "dashes": false,
          "datasource": "Prometheus",
          "fill": 1,
          "gridPos": {
            "h": 9,
            "w": 12,
            "x": 0,
            "y": 0
          },
          "id": 6,
          "legend": {
            "avg": false,
            "current": false,
            "max": false,
            "min": false,
            "show": true,
            "total": false,
            "values": false
          },
          "lines": true,
          "linewidth": 3,
          "links": [],
          "nullPointMode": "null",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [],
          "spaceLength": 10,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "expr": "sum(rate(phoenix_controller_call_duration_microseconds_sum{app=~\"$app\",controller!~\".*Health.*\"}[2m])) without (instance)/sum(rate(phoenix_controller_call_duration_microseconds_count{app=~\"$app\",controller!~\".*Health.*\"}[2m])) without (instance)",
              "format": "time_series",
              "instant": false,
              "interval": "2m",
              "intervalFactor": 1,
              "legendFormat": "{{app}}/{{action}}",
              "refId": "A"
            }
          ],
          "thresholds": [
            {
              "colorMode": "critical",
              "fill": true,
              "fillColor": "rgba(191, 27, 0, 0.28)",
              "line": true,
              "lineColor": "#bf1b00",
              "op": "gt",
              "value": 20000000,
              "yaxis": "left"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Avg Action Call Duration",
          "tooltip": {
            "shared": true,
            "sort": 1,
            "value_type": "individual"
          },
          "type": "graph",
          "xaxis": {
            "buckets": null,
            "mode": "time",
            "name": null,
            "show": true,
            "values": []
          },
          "yaxes": [
            {
              "format": "µs",
              "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": {
            "DiscoveryApiWeb.DatasetDetailController/fetch_dataset_detail": "rgb(74, 193, 177)",
            "DiscoveryApiWeb.DatasetQueryController/fetch_full_csv": "rgb(41, 110, 117)",
            "DiscoveryApiWeb.DatasetQueryController/fetch_query": "rgb(230, 241, 241)",
            "DiscoveryApiWeb.DatasetSearchController/search": "rgb(0, 74, 191)",
            "discovery-api": "#6ed0e0"
          },
          "bars": false,
          "dashLength": 10,
          "dashes": false,
          "datasource": "Prometheus",
          "fill": 3,
          "gridPos": {
            "h": 9,
            "w": 12,
            "x": 12,
            "y": 0
          },
          "id": 4,
          "legend": {
            "avg": false,
            "current": false,
            "max": false,
            "min": false,
            "show": true,
            "total": false,
            "values": false
          },
          "lines": true,
          "linewidth": 3,
          "links": [],
          "nullPointMode": "null",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [],
          "spaceLength": 10,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "expr": "sum(rate(phoenix_controller_call_duration_microseconds_count{app=~\"$app\",controller!~\".*Health.*\"}[2m])) without (instance)",
              "format": "time_series",
              "interval": "2m",
              "intervalFactor": 1,
              "legendFormat": "{{controller}}/{{action}}",
              "refId": "A"
            }
          ],
          "thresholds": [],
          "timeFrom": null,
          "timeShift": null,
          "title": "Phoenix API Call Rate By Action",
          "tooltip": {
            "shared": true,
            "sort": 0,
            "value_type": "individual"
          },
          "type": "graph",
          "xaxis": {
            "buckets": null,
            "mode": "time",
            "name": null,
            "show": true,
            "values": []
          },
          "yaxes": [
            {
              "decimals": null,
              "format": "none",
              "label": "Rate of Requests",
              "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
          }
        },
        {
          "cards": {
            "cardPadding": -1,
            "cardRound": 0
          },
          "color": {
            "cardColor": "rgb(0, 74, 191)",
            "colorScale": "sqrt",
            "colorScheme": "interpolatePuRd",
            "exponent": 0.5,
            "max": null,
            "min": 1,
            "mode": "opacity"
          },
          "dataFormat": "tsbuckets",
          "datasource": "Prometheus",
          "gridPos": {
            "h": 9,
            "w": 12,
            "x": 0,
            "y": 9
          },
          "heatmap": {},
          "highlightCards": true,
          "id": 8,
          "legend": {
            "show": false
          },
          "links": [],
          "targets": [
            {
              "expr": "sum(rate(phoenix_controller_call_duration_microseconds_bucket{app=~\"$app\",controller!~\".*Health.*\"}[2m])) by (le)",
              "format": "heatmap",
              "interval": "2m",
              "intervalFactor": 1,
              "legendFormat": "{{le}}",
              "refId": "A"
            }
          ],
          "title": "Call Duration Heatmap",
          "tooltip": {
            "show": true,
            "showHistogram": false
          },
          "transparent": false,
          "type": "heatmap",
          "xAxis": {
            "show": true
          },
          "xBucketNumber": null,
          "xBucketSize": null,
          "yAxis": {
            "decimals": null,
            "format": "µs",
            "logBase": 1,
            "max": null,
            "min": null,
            "show": true,
            "splitFactor": null
          },
          "yBucketBound": "auto",
          "yBucketNumber": null,
          "yBucketSize": null
        },
        {
          "aliasColors": {
            "discovery-api": "rgb(74, 193, 177)"
          },
          "bars": false,
          "dashLength": 10,
          "dashes": false,
          "datasource": "Prometheus",
          "fill": 3,
          "gridPos": {
            "h": 9,
            "w": 12,
            "x": 12,
            "y": 9
          },
          "id": 2,
          "legend": {
            "avg": false,
            "current": false,
            "max": false,
            "min": false,
            "show": true,
            "total": false,
            "values": false
          },
          "lines": true,
          "linewidth": 3,
          "links": [],
          "nullPointMode": "null",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [],
          "spaceLength": 10,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "expr": "sum(rate(phoenix_controller_call_duration_microseconds_count{app=~\"$app\",controller!~\".*Health.*\"}[2m])) by (app)",
              "format": "time_series",
              "interval": "2m",
              "intervalFactor": 1,
              "legendFormat": "{{app}}",
              "refId": "A"
            }
          ],
          "thresholds": [],
          "timeFrom": null,
          "timeShift": null,
          "title": "Phoenix API Call Rate By App",
          "tooltip": {
            "shared": true,
            "sort": 0,
            "value_type": "individual"
          },
          "type": "graph",
          "xaxis": {
            "buckets": null,
            "mode": "time",
            "name": null,
            "show": true,
            "values": []
          },
          "yaxes": [
            {
              "decimals": 0,
              "format": "none",
              "label": "Rate of Requests",
              "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": "1m",
      "schemaVersion": 16,
      "style": "dark",
      "tags": [
        "Elixir",
        "Phoenix",
        "API"
      ],
      "templating": {
        "list": [
          {
            "allValue": null,
            "current": {},
            "datasource": "Prometheus",
            "hide": 0,
            "includeAll": true,
            "label": null,
            "multi": true,
            "name": "app",
            "options": [],
            "query": "label_values(app)",
            "refresh": 1,
            "regex": "",
            "sort": 0,
            "tagValuesQuery": "",
            "tags": [],
            "tagsQuery": "",
            "type": "query",
            "useTags": false
          }
        ]
      },
      "time": {
        "from": "now-6h",
        "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": "Phoenix API Metrics",
      "uid": "wwrTAhwmz",
      "version": 8
    }