Grafana dashboard: Autometrics Overview
Description: Shows the functions with the highest request and error rates

This is a dashboard that will work for any project instrumented with [Autometrics](https://autometrics.dev).

{
  "__inputs": [
    {
      "name": "DS_PROMETHEUS",
      "label": "Prometheus",
      "description": "",
      "type": "datasource",
      "pluginId": "prometheus",
      "pluginName": "Prometheus"
    }
  ],
  "__elements": {},
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "9.4.3"
    },
    {
      "type": "datasource",
      "id": "prometheus",
      "name": "Prometheus",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "timeseries",
      "name": "Time series",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "datasource",
          "uid": "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": "Shows the functions with the highest request and error rates",
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 0,
  "id": null,
  "links": [],
  "liveNow": false,
  "panels": [
    {
      "collapsed": false,
      "datasource": {
        "type": "prometheus",
        "uid": "Sc9Taxa4z"
      },
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 8,
      "panels": [],
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "Sc9Taxa4z"
          },
          "refId": "A"
        }
      ],
      "title": "Autometrics-Instrumented Functions",
      "type": "row"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "Calls per second is calculated as the average over a 5-minute window",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "Calls per Second",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 10,
            "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": [],
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "none"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 24,
        "x": 0,
        "y": 1
      },
      "id": 4,
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "max"
          ],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true,
          "sortBy": "Max",
          "sortDesc": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "pluginVersion": "9.4.1",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "sum by (function, module) (rate(function_calls_count{function=~\"${functions_top_request_rate}\"}[5m])) > 0",
          "format": "time_series",
          "instant": false,
          "interval": "",
          "legendFormat": "",
          "refId": "A"
        }
      ],
      "title": "Request Rate (Top $num_function_limit)",
      "transformations": [],
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "description": "",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic",
            "seriesBy": "max"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "Error Rate",
            "axisPlacement": "auto",
            "axisSoftMax": 1,
            "axisSoftMin": 0,
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 10,
            "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": "percentunit"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 24,
        "x": 0,
        "y": 9
      },
      "id": 2,
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "max"
          ],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true,
          "sortBy": "Max",
          "sortDesc": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "pluginVersion": "9.4.1",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "expr": "(sum by(function, module) (rate(function_calls_count{result=\"error\", function=~\"${functions_top_error_rate}\"}[5m])) > 0)\n/ (sum by(function, module) (rate(function_calls_count{function=~\"${functions_top_error_rate}\"}[5m])) > 0)",
          "interval": "",
          "legendFormat": "",
          "range": true,
          "refId": "A"
        }
      ],
      "title": "Error Rate (Top $num_function_limit)",
      "type": "timeseries"
    }
  ],
  "refresh": "5m",
  "revision": 1,
  "schemaVersion": 38,
  "style": "dark",
  "tags": [
    "autometrics"
  ],
  "templating": {
    "list": [
      {
        "allValue": "",
        "current": {},
        "datasource": {
          "type": "prometheus",
          "uid": "${DS_PROMETHEUS}"
        },
        "definition": "query_result(topk($num_function_limit, sum by (function, module) (rate(function_calls_count[$__range]))))\n",
        "hide": 2,
        "includeAll": true,
        "multi": true,
        "name": "functions_top_request_rate",
        "options": [],
        "query": {
          "query": "query_result(topk($num_function_limit, sum by (function, module) (rate(function_calls_count[$__range]))))\n",
          "refId": "StandardVariableQuery"
        },
        "refresh": 2,
        "regex": "/function=\"(\\w+)\"/",
        "skipUrlSync": false,
        "sort": 4,
        "type": "query"
      },
      {
        "current": {
          "selected": false,
          "text": "10",
          "value": "10"
        },
        "hide": 0,
        "label": "Top Functions to Display",
        "name": "num_function_limit",
        "options": [
          {
            "selected": true,
            "text": "10",
            "value": "10"
          }
        ],
        "query": "10",
        "skipUrlSync": false,
        "type": "textbox"
      },
      {
        "allValue": "",
        "current": {},
        "datasource": {
          "type": "prometheus",
          "uid": "${DS_PROMETHEUS}"
        },
        "definition": "query_result(topk($num_function_limit, sum by (function, module) (rate(function_calls_count{result=\"error\"}[$__range])) / (sum by (function, module) (rate(function_calls_count[$__range])) > 0)))\n",
        "hide": 2,
        "includeAll": true,
        "multi": true,
        "name": "functions_top_error_rate",
        "options": [],
        "query": {
          "query": "query_result(topk($num_function_limit, sum by (function, module) (rate(function_calls_count{result=\"error\"}[$__range])) / (sum by (function, module) (rate(function_calls_count[$__range])) > 0)))\n",
          "refId": "StandardVariableQuery"
        },
        "refresh": 2,
        "regex": "/function=\"(\\w+)\"/",
        "skipUrlSync": false,
        "sort": 4,
        "type": "query"
      }
    ]
  },
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "Autometrics Overview",
  "uid": "autometrics2",
  "version": 19,
  "weekStart": "",
  "gnetId": 18505
}