Grafana dashboard: Locust Testruns

See [Locust dashboard](https://grafana.com/grafana/dashboards/10878) for more details

{
  "__inputs": [
    {
      "name": "DS_LOCUST",
      "label": "locust",
      "description": "",
      "type": "datasource",
      "pluginId": "postgres",
      "pluginName": "PostgreSQL"
    }
  ],
  "__elements": [],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "8.3.4"
    },
    {
      "type": "datasource",
      "id": "postgres",
      "name": "PostgreSQL",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "table",
      "name": "Table",
      "version": ""
    },
    {
      "type": "panel",
      "id": "timeseries",
      "name": "Time series",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "limit": 100,
        "name": "Annotations & Alerts",
        "showIn": 0,
        "target": {
          "limit": 100,
          "matchAny": false,
          "tags": [],
          "type": "dashboard"
        },
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1648636708308,
  "links": [],
  "liveNow": false,
  "panels": [
    {
      "datasource": {
        "type": "postgres",
        "uid": "${DS_LOCUST}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {
            "align": "auto",
            "displayMode": "auto"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "id"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "link"
              },
              {
                "id": "links",
                "value": [
                  {
                    "targetBlank": true,
                    "title": "Report",
                    "url": "/d/-OKXsAo7z/?orgId=1&var-testplan=${__data.fields[testplan]}&from=${__data.fields[start_time_epoch]}&to=${__data.fields[end_time_epoch]}"
                  }
                ]
              },
              {
                "id": "custom.align"
              },
              {
                "id": "custom.width",
                "value": 175
              }
            ]
          },
          {
            "matcher": {
              "id": "byRegexp",
              "options": "/_epoch$/"
            },
            "properties": [
              {
                "id": "unit",
                "value": "string"
              },
              {
                "id": "decimals",
                "value": 2
              },
              {
                "id": "custom.align"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "end time"
            },
            "properties": [
              {
                "id": "unit",
                "value": "short"
              },
              {
                "id": "decimals",
                "value": 2
              },
              {
                "id": "unit",
                "value": "time: YYYY-MM-DD HH:mm:ss"
              },
              {
                "id": "custom.align"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "start_time"
            },
            "properties": [
              {
                "id": "unit",
                "value": "short"
              },
              {
                "id": "decimals",
                "value": 2
              },
              {
                "id": "unit",
                "value": "time: YYYY-MM-DD HH:mm:ss"
              },
              {
                "id": "custom.align"
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 15,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 2,
      "interval": "10ms",
      "links": [],
      "options": {
        "footer": {
          "fields": "",
          "reducer": [
            "sum"
          ],
          "show": false
        },
        "showHeader": true
      },
      "pluginVersion": "8.3.4",
      "targets": [
        {
          "datasource": {
            "type": "postgres",
            "uid": "${DS_LOCUST}"
          },
          "format": "table",
          "group": [],
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "SELECT \n      id,\n      testplan, \n      num_clients, \n      round(rps_avg, 1) as rps_avg,\n      nullif(rps, 0) as rps_target,\n      round(resp_time_avg, 1) as resp_time,\n      fail_ratio,\n      requests, \n      date_trunc('second', end_time - id) AS \"run time\",\n      end_time AS \"end time\",\n      env,\n      description,\n      username,\n      gitrepo,\n      changeset_guid,\n      round(date_part('epoch', id)*1000) AS start_time_epoch, \n      CASE WHEN end_time IS NULL \n              THEN round((date_part('epoch', id)*1000)+300000) -- make a useable link even when there is no end time\n              ELSE round(date_part('epoch', end_time)*1000) \n      END AS end_time_epoch,\n      exit_code,\n      arguments\nFROM testrun\nWHERE $__timeFilter(id) and \n      testplan = ANY(ARRAY[$testplan]::varchar[]) and -- couldnt use a simple testplan IN ($testplan), because postgres fails if $testplan is empty\n      username = ANY(ARRAY[$username]::varchar[]) and\n      env = ANY(ARRAY[$env]::varchar[]) and \n      num_clients >= $min_users and \n      num_clients <= $max_users\nORDER BY id DESC",
          "refId": "B",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              }
            ]
          ],
          "timeColumn": "time",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "Testrun",
      "transformations": [
        {
          "id": "merge",
          "options": {
            "reducers": []
          }
        },
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "end_time_epoch": false,
              "start_time_epoch": false
            },
            "indexByName": {},
            "renameByName": {}
          }
        }
      ],
      "type": "table"
    },
    {
      "datasource": {
        "type": "postgres",
        "uid": "${DS_LOCUST}"
      },
      "description": "Make sure to filter out relevant data (correct testplan, user count, etc) or your graph will not be very meaningful. \n\nThe calculation includes internal time taken for Locust to start and stop test, so it will be sligthly lower than the real value, especially for short runs. It also includes the ramp up phase.",
      "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": 4,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "always",
            "spanNulls": true,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "links": [],
          "mappings": [],
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "none"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byFrameRefID",
              "options": "B"
            },
            "properties": [
              {
                "id": "custom.drawStyle",
                "value": "points"
              },
              {
                "id": "color",
                "value": {
                  "fixedColor": "red",
                  "mode": "fixed"
                }
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 11,
        "w": 12,
        "x": 0,
        "y": 15
      },
      "id": 6,
      "links": [],
      "options": {
        "legend": {
          "calcs": [
            "mean",
            "max",
            "min"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "single"
        }
      },
      "pluginVersion": "8.3.4",
      "repeatDirection": "h",
      "targets": [
        {
          "datasource": {
            "type": "postgres",
            "uid": "${DS_LOCUST}"
          },
          "format": "time_series",
          "group": [
            {
              "params": [
                "$__interval",
                "none"
              ],
              "type": "time"
            }
          ],
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "SELECT id AS \"time\", \n      rps_avg AS \"avg rps\"\nFROM testrun\nWHERE $__timeFilter(id) and \n      testplan = ANY(ARRAY[$testplan]::varchar[]) and -- couldnt use a simple testplan IN ($testplan), because postgres fails if $testplan is empty\n      username = ANY(ARRAY[$username]::varchar[]) and\n      env = ANY(ARRAY[$env]::varchar[]) and \n      num_clients >= $min_users and \n      num_clients <= $max_users\nORDER BY id\n",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "response_time"
                ],
                "type": "column"
              },
              {
                "params": [
                  "avg"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "response_time"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "request",
          "timeColumn": "\"time\"",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        },
        {
          "datasource": {
            "type": "postgres",
            "uid": "${DS_LOCUST}"
          },
          "format": "time_series",
          "group": [
            {
              "params": [
                "$__interval",
                "none"
              ],
              "type": "time"
            }
          ],
          "hide": false,
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "SELECT id AS \"time\", \n      rps_avg AS \"avg rps (test failed)\"\nFROM testrun\nWHERE $__timeFilter(id) and \n      testplan = ANY(ARRAY[$testplan]::varchar[]) and\n      username = ANY(ARRAY[$username]::varchar[]) and\n      env = ANY(ARRAY[$env]::varchar[]) and \n      num_clients >= $min_users and \n      num_clients <= $max_users and exit_code > 0\nORDER BY id\n",
          "refId": "B",
          "select": [
            [
              {
                "params": [
                  "response_time"
                ],
                "type": "column"
              },
              {
                "params": [
                  "avg"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "response_time"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "request",
          "timeColumn": "\"time\"",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "Average requests per second (RPS)",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "postgres",
        "uid": "${DS_LOCUST}"
      },
      "description": "",
      "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": 4,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "always",
            "spanNulls": true,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "links": [],
          "mappings": [],
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "none"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byFrameRefID",
              "options": "B"
            },
            "properties": [
              {
                "id": "custom.drawStyle",
                "value": "points"
              },
              {
                "id": "color",
                "value": {
                  "fixedColor": "semi-dark-red",
                  "mode": "fixed"
                }
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 11,
        "w": 12,
        "x": 12,
        "y": 15
      },
      "id": 7,
      "links": [],
      "options": {
        "legend": {
          "calcs": [
            "mean",
            "max",
            "min"
          ],
          "displayMode": "table",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "single"
        }
      },
      "pluginVersion": "8.3.4",
      "repeatDirection": "h",
      "targets": [
        {
          "datasource": {
            "type": "postgres",
            "uid": "${DS_LOCUST}"
          },
          "format": "time_series",
          "group": [
            {
              "params": [
                "$__interval",
                "none"
              ],
              "type": "time"
            }
          ],
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "SELECT id AS \"time\", \n      resp_time_avg AS \"avg resp time\"\nFROM testrun\nWHERE $__timeFilter(id) and \n      testplan = ANY(ARRAY[$testplan]::varchar[]) and -- couldnt use a simple testplan IN ($testplan), because postgres fails if $testplan is empty\n      username = ANY(ARRAY[$username]::varchar[]) and\n      env = ANY(ARRAY[$env]::varchar[]) and \n      num_clients >= $min_users and \n      num_clients <= $max_users\nORDER BY id\n",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "response_time"
                ],
                "type": "column"
              },
              {
                "params": [
                  "avg"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "response_time"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "request",
          "timeColumn": "\"time\"",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        },
        {
          "datasource": {
            "type": "postgres",
            "uid": "${DS_LOCUST}"
          },
          "format": "time_series",
          "group": [
            {
              "params": [
                "$__interval",
                "none"
              ],
              "type": "time"
            }
          ],
          "hide": false,
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "SELECT id AS \"time\", \n      resp_time_avg AS \"avg resp time (failed)\"\nFROM testrun\nWHERE $__timeFilter(id) and \n      testplan = ANY(ARRAY[$testplan]::varchar[]) and -- couldnt use a simple testplan IN ($testplan), because postgres fails if $testplan is empty\n      username = ANY(ARRAY[$username]::varchar[]) and\n      env = ANY(ARRAY[$env]::varchar[]) and \n      num_clients >= $min_users and \n      num_clients <= $max_users and exit_code > 0\nORDER BY id\n",
          "refId": "B",
          "select": [
            [
              {
                "params": [
                  "response_time"
                ],
                "type": "column"
              },
              {
                "params": [
                  "avg"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "response_time"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "request",
          "timeColumn": "\"time\"",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "Average response time",
      "type": "timeseries"
    }
  ],
  "refresh": false,
  "schemaVersion": 34,
  "style": "dark",
  "tags": [
    "load_test"
  ],
  "templating": {
    "list": [
      {
        "current": {},
        "datasource": {
          "type": "postgres",
          "uid": "${DS_LOCUST}"
        },
        "definition": "SELECT DISTINCT testplan FROM testrun WHERE $__timeFilter(id)",
        "hide": 0,
        "includeAll": true,
        "multi": false,
        "name": "testplan",
        "options": [],
        "query": "SELECT DISTINCT testplan FROM testrun WHERE $__timeFilter(id)",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "current": {},
        "datasource": {
          "type": "postgres",
          "uid": "${DS_LOCUST}"
        },
        "definition": "SELECT DISTINCT username FROM testrun WHERE $__timeFilter(id)",
        "hide": 0,
        "includeAll": true,
        "multi": false,
        "name": "username",
        "options": [],
        "query": "SELECT DISTINCT username FROM testrun WHERE $__timeFilter(id)",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "current": {},
        "datasource": {
          "type": "postgres",
          "uid": "${DS_LOCUST}"
        },
        "definition": "SELECT DISTINCT env FROM testrun WHERE $__timeFilter(id)",
        "hide": 0,
        "includeAll": true,
        "multi": false,
        "name": "env",
        "options": [],
        "query": "SELECT DISTINCT env FROM testrun WHERE $__timeFilter(id)",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "current": {
          "selected": false,
          "text": "0",
          "value": "0"
        },
        "hide": 0,
        "name": "min_users",
        "options": [
          {
            "selected": true,
            "text": "0",
            "value": "0"
          }
        ],
        "query": "0",
        "skipUrlSync": false,
        "type": "textbox"
      },
      {
        "current": {
          "selected": false,
          "text": "9999",
          "value": "9999"
        },
        "hide": 0,
        "name": "max_users",
        "options": [
          {
            "selected": true,
            "text": "9999",
            "value": "9999"
          }
        ],
        "query": "9999",
        "skipUrlSync": false,
        "type": "textbox"
      }
    ]
  },
  "time": {
    "from": "2022-03-26T10:57:14.347Z",
    "to": "2022-03-30T01:56:00.080Z"
  },
  "timepicker": {
    "refresh_intervals": [
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ],
    "time_options": [
      "5m",
      "15m",
      "1h",
      "6h",
      "12h",
      "24h",
      "2d",
      "7d",
      "30d"
    ]
  },
  "timezone": "",
  "title": "Locust Testruns",
  "uid": "rtrgXdxnk",
  "version": 11,
  "weekStart": "",
  "gnetId": 14422
}