Grafana dashboard: Octopus Deploy
Description: Octopus Deploy reporting on projects and tasks


# Octopus Deploy Dashboard
Dashboard to visualize [Octopus Deploy](https://octopus.com/) deployment and task data.

Setup a read-only user with access to the Octopus Deploy SQL Server database. 

# SQL Server Express
If you are using the included SQL Server Express you'll have a few more hoops to jump through to enable access on port 1433 remotely from Grafana. To enable TCP/IP connections on SQL Express open the `SQL Server Configuration Manager`. Under `SQL Server Network Configuration` select `Protocols for SQLEXPRESS`. Right click `TCP/IP` and open `Properties`. Scroll down to `IPAll` and blank out `TCP Dynamic Ports` and set `TCP Port` to `1433`. You may need to set your local windows firewall to allow port 1433 through.

# Bugs, suggestions and feedback
Bug reports, suggestions and feedback to [GitHub](https://github.com/bhozar/grafana-dashboards/tree/master/octopusdeploy) please!

# Dashboard
Dashboard is setup to filter the variables based on the Project search box. Type a full or partial search term to filter the board automatically, no need to then select individual projects.

The Deployment Annotations will display over the top of the time series line graph, and hovering over will give details on each deployment. These are also filtered based on the variables at the top of the page.

![Octopus Deploy Dashboard](https://grafana.com/api/dashboards/11720/images/7564/image)
![Octopus Deploy Dashboard](https://grafana.com/api/dashboards/11720/images/7565/image)
![Octopus Deploy Dashboard](https://grafana.com/api/dashboards/11720/images/7566/image)

{
  "__inputs": [
    {
      "name": "DS_OCTOPUSDEPLOY",
      "label": "OctopusDeploy",
      "description": "",
      "type": "datasource",
      "pluginId": "mssql",
      "pluginName": "Microsoft SQL Server"
    }
  ],
  "__requires": [
    {
      "type": "panel",
      "id": "bargauge",
      "name": "Bar Gauge",
      "version": ""
    },
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "6.6.1"
    },
    {
      "type": "panel",
      "id": "grafana-piechart-panel",
      "name": "Pie Chart",
      "version": "1.4.0"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "mssql",
      "name": "Microsoft SQL Server",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "stat",
      "name": "Stat",
      "version": ""
    },
    {
      "type": "panel",
      "id": "table",
      "name": "Table",
      "version": ""
    },
    {
      "type": "panel",
      "id": "text",
      "name": "Text",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "limit": 100,
        "name": "Annotations & Alerts",
        "showIn": 0,
        "type": "dashboard"
      },
      {
        "datasource": "${DS_OCTOPUSDEPLOY}",
        "enable": false,
        "hide": false,
        "iconColor": "#8AB8FF",
        "limit": 100,
        "name": "📝 Deployments Annotations",
        "rawQuery": "SELECT\n   CompletedTime  as time,\n   ProjectName as text,\n   CONCAT(EnvironmentName, ',' , ReleaseVersion, ',' , DeployedBy) as tags\n FROM\n   DeploymentHistory\n WHERE\n  TaskState = 'Success'  AND ProjectName IN ($project) AND EnvironmentName IN ($environment) AND\n  CompletedTime >=  CONVERT( DATETIMEOFFSET, $__timeFrom(), 0 ) AND   \n  CompletedTime <   CONVERT( DATETIMEOFFSET, $__timeTo(), 0 )\nORDER BY CompletedTime  ASC\n",
        "showIn": 0,
        "tags": [],
        "type": "tags"
      }
    ]
  },
  "description": "Octopus Deploy reporting on projects and tasks",
  "editable": true,
  "gnetId": 11720,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1581512355827,
  "links": [],
  "panels": [
    {
      "content": "<br>\n\n# Octopus Deploy\n<center>\n<img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAI0AAACMCAMAAAB23NoyAAAACXBIWXMAAAsSAAALEgHS3X78AAAAM1BMVEX///8vk+Avk+Avk+Avk+Avk+Avk+Avk+Avk+Avk+Avk+Avk+Avk+Avk+Avk+Avk+Avk+CYbWlbAAAAEHRSTlMAECAwQFBgcICQoLDA0ODwVOCoyAAAA3ZJREFUeNrtnMl25CAMRcGADRSD/v9rs8jJWMVgJLm08Nt3cgNCeki4lbp169atoTZrrdXvptDWx1TgWzmFw74HxYUML5W8uRolVuiohOuAtC8wVN6vCdkIcyr8PDrAvApzSB8VTunBeO63BGdVrZSF+VTgiZgIa0oMu6UzrCqT45gK6ypGEAxANYJgaDcLDUOJgwjgH0UqmgQUOmhgPNCIJJItEQwUgtDRhYoGPJ4mAJ3Qe2UIYSDJOE9fskJCmGRxaJcGuTjESwPwwNBEahrYED6YHAaTcw56mrJOk+lp1reKYaMQpfzgoFk+VQ8OmrpKUzloVkunYYEBt0az89AsZhzPQxNkVExcHZdFAzfNTXPTkOYbEJWLQVSdYqLZJOXiKslsLXs/nhq+OpixLDTLLSVRJp0lcNYnaAxWFHHV1GLKAtNWIVoU9FuF621VMTFM3Z5FJRuOLgWqz0bewcEOPnYxJ0oppTRlHFeFVRQUNko5Gf1QhpTj8DSE1YHgSYUXReNE0dib5oqd8qKi+CHqhFdR2Q+f/igrA34CTTtLRJ4qYvOXJS0N8pDTj2Ewe0U/2ES8J+Po4Czj8DRwFnEMzyRx7SEr4aMk/MnSGfiUNkEwAPVUyTIFmHWir2QrsGv62fEBV2ju6ah+wDWaqaG2wFUannR9up1VEPSaeGGy7cR81NtzqYtltg/YXJjSiKXYMx5Fvzye5udLhN5WmWbGC1vtwLRM2fG63FWtjzJcm+aCJ9vwFrHfdTcNy5aVUi6W7gWr1eIru1KqDBLGy8Vp/uSwamY+Pzt6SVq3/r9O7Ww6rFKlzdJwpPvgEpjaZr9u5/142ntmPY0uF6EzsR3d854iP5puVPz7845+pn0yKIM0vP3+ri8HN2oaH8O19b3Gcx36LWMP7723duK05fEQ1HddNukrRDu+evm+6V+959VO3usg+/4dZHFxXuSSqidugn5wJVobVvmptpCbcC9bxm/VY8phmxkv9efbvbWxYp5zkHPOzpX/RRX5gKGRKtKcz/x2E4sfVE2WvDDtes3u/bHaqpgcTjqG1vmQJk6/c9hYaPIUzNPZKywwfyp4nG8tRx4aN/sbCvXcsP9bwonheWWC+SpU455Loh3/tPaqABQ/rnK/LFV9+3+W8btKOyVAXz2xoERI+wpQnBIjY9StW7du/dUHI6Ym0KauAw0AAAAASUVORK5CYII=\">\n</center>\n\n",
      "datasource": null,
      "gridPos": {
        "h": 7,
        "w": 3,
        "x": 0,
        "y": 0
      },
      "id": 17,
      "mode": "markdown",
      "options": {},
      "timeFrom": null,
      "timeShift": null,
      "title": "",
      "transparent": true,
      "type": "text"
    },
    {
      "datasource": "${DS_OCTOPUSDEPLOY}",
      "gridPos": {
        "h": 7,
        "w": 21,
        "x": 3,
        "y": 0
      },
      "id": 7,
      "options": {
        "colorMode": "background",
        "fieldOptions": {
          "calcs": [
            "sum"
          ],
          "defaults": {
            "mappings": [
              {
                "from": "",
                "id": 1,
                "operator": "",
                "text": "",
                "to": "",
                "type": 1,
                "value": ""
              }
            ],
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {
                  "color": "semi-dark-blue",
                  "value": null
                }
              ]
            },
            "title": "Deployments ${__series.name}",
            "unit": "locale"
          },
          "overrides": [],
          "values": false
        },
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto"
      },
      "pluginVersion": "6.6.1",
      "targets": [
        {
          "alias": "",
          "format": "time_series",
          "hide": false,
          "rawSql": "SELECT\n  COUNT(d.TaskId) as Deployment,\n  CASE\n    WHEN s.State = 'Failed' THEN 'Failed'\n    WHEN s.State = 'Success' THEN 'Success'\n    WHEN s.State = 'Canceled' THEN 'Cancelled'\n    WHEN s.State = 'Queued' THEN 'Queued'\n    WHEN s.State = 'Executing' THEN 'Executing'\n    WHEN s.State = 'TimedOut' THEN 'Timed Out'\n    WHEN s.State = 'Cancelling' THEN 'Cancelling'\n  END as metric,\n  $__timeGroup(s.QueueTime, '$interval', 0 ) AS [time]\nFROM \n  [Octopus].[dbo].[Deployment] d\n  INNER JOIN [Octopus].[dbo].[DeploymentEnvironment] e ON e.Id = d.EnvironmentId\n  INNER JOIN [Octopus].[dbo].[Project] p ON p.Id = d.ProjectId\n  INNER JOIN [Octopus].[dbo].[ServerTask] s ON s.Id = d.TaskId\nWHERE \n  s.QueueTime >= CONVERT( DATETIMEOFFSET, $__timeFrom(), 0 ) AND\n  e.Name IN ($environment) AND\n  p.Name IN ($project)\nGROUP BY  $__timeGroup(s.QueueTime, '$interval', 0),  s.State\nORDER BY $__timeGroup(s.QueueTime, '$interval', 0), COUNT(1) DESC",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "",
      "type": "stat"
    },
    {
      "aliasColors": {},
      "bars": true,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_OCTOPUSDEPLOY}",
      "decimals": 0,
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 9,
        "w": 24,
        "x": 0,
        "y": 7
      },
      "hiddenSeries": false,
      "id": 37,
      "interval": "",
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": false,
        "hideEmpty": false,
        "hideZero": false,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": true,
        "sort": "total",
        "sortDesc": true,
        "total": true,
        "values": true
      },
      "lines": false,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [
        {
          "alias": "Failed",
          "color": "rgba(245, 54, 54, 0.9)"
        },
        {
          "alias": "Success",
          "color": "rgba(50, 172, 45, 0.97)"
        },
        {
          "alias": "Cancelled",
          "color": "rgba(237, 129, 40, 0.89)"
        },
        {
          "alias": "Duration",
          "bars": false,
          "color": "rgb(255, 255, 255)",
          "fill": 0,
          "fillGradient": 0,
          "lines": true,
          "points": true,
          "yaxis": 2
        },
        {
          "alias": "Queued",
          "color": "#434143"
        },
        {
          "alias": "Executing",
          "color": "#1f60c4"
        },
        {
          "alias": "Timed Out",
          "color": "#8f3bb8"
        },
        {
          "alias": "Canceling",
          "color": "#aa8800"
        }
      ],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "alias": "",
          "format": "time_series",
          "hide": false,
          "rawSql": "SELECT \n  COUNT(d.ReleaseId) AS Deployment,\n    CASE\n    WHEN s.State = 'Failed' THEN (p.Name + ' - Failed')\n    WHEN s.State = 'Success' THEN (p.Name + ' - Success')\n    WHEN s.State = 'Canceled' THEN (p.Name + ' - Cancelled')\n    WHEN s.State = 'Queued' THEN (p.Name + ' - Queued')\n    WHEN s.State = 'Executing' THEN (p.Name + ' - Executing')\n    WHEN s.State = 'TimedOut' THEN (p.Name + ' - Timed Out')\n    WHEN s.State = 'Cancelling' THEN (p.Name + ' - Cancelling')\n  END as metric,\n  -- $__timeGroup(s.CompletedTime, '$interval', 0 ) AS [time]\n  $__timeGroup(s.CompletedTime, '$interval', 0 ) AS [time]\nFROM \n  [Octopus].[dbo].[Deployment] d\n  INNER JOIN [Octopus].[dbo].[DeploymentEnvironment] e ON e.Id = d.EnvironmentId\n  INNER JOIN [Octopus].[dbo].[Project] p ON p.Id = d.ProjectId\n  INNER JOIN [Octopus].[dbo].[Release] r ON r.Id = d.ReleaseId\n  INNER JOIN [Octopus].[dbo].[ServerTask] s ON s.Id = d.TaskId\nWHERE \n  s.CompletedTime >=  CONVERT( DATETIMEOFFSET, $__timeFrom(), 0 ) AND\n  s.CompletedTime <   CONVERT( DATETIMEOFFSET, $__timeTo(), 0 ) AND\n  e.Name IN ($environment) AND\n  p.Name IN ($project)\nGROUP BY  $__timeGroup(s.CompletedTime, '$interval', 0), s.State, p.Name\nORDER BY $__timeGroup(s.CompletedTime, '$interval', 0)",
          "refId": "B"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Deployment Status by Product",
      "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": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "decimals": null,
          "format": "s",
          "label": "",
          "logBase": 1,
          "max": null,
          "min": null,
          "show": false
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": true,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_OCTOPUSDEPLOY}",
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 6,
        "w": 24,
        "x": 0,
        "y": 16
      },
      "hiddenSeries": false,
      "id": 30,
      "interval": "",
      "legend": {
        "avg": false,
        "current": false,
        "hideEmpty": false,
        "hideZero": false,
        "max": false,
        "min": false,
        "show": true,
        "total": true,
        "values": true
      },
      "lines": false,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [
        {
          "alias": "Failed",
          "color": "rgba(245, 54, 54, 0.9)"
        },
        {
          "alias": "Success",
          "color": "rgba(50, 172, 45, 0.97)"
        },
        {
          "alias": "Cancelled",
          "color": "rgba(237, 129, 40, 0.89)"
        },
        {
          "alias": "Duration",
          "bars": false,
          "color": "rgb(255, 255, 255)",
          "fill": 0,
          "fillGradient": 0,
          "lines": true,
          "points": true,
          "yaxis": 2
        },
        {
          "alias": "Queued",
          "color": "#434143"
        },
        {
          "alias": "Executing",
          "color": "#1f60c4"
        },
        {
          "alias": "Timed Out",
          "color": "#8f3bb8"
        },
        {
          "alias": "Canceling",
          "color": "#aa8800"
        }
      ],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "alias": "",
          "format": "time_series",
          "hide": false,
          "rawSql": "SELECT \n  AVG(DATEDIFF(ss, s.QueueTime, s.CompletedTime)) AS Duration,\n  -- $__timeGroup(s.CompletedTime, '$interval', 0 ) AS [time]\n  $__timeGroup(s.CompletedTime, '$interval', 0 ) AS [time]\nFROM \n  [Octopus].[dbo].[Deployment] d\n  INNER JOIN [Octopus].[dbo].[DeploymentEnvironment] e ON e.Id = d.EnvironmentId\n  INNER JOIN [Octopus].[dbo].[Project] p ON p.Id = d.ProjectId\n  INNER JOIN [Octopus].[dbo].[ServerTask] s ON s.Id = d.TaskId\nWHERE\n  s.CompletedTime >=  CONVERT( DATETIMEOFFSET, $__timeFrom(), 0 ) AND   \n  s.CompletedTime <   CONVERT( DATETIMEOFFSET, $__timeTo(), 0 ) AND\n  e.Name IN ($environment) AND\n  p.Name IN ($project)\nGROUP BY  $__timeGroup(s.CompletedTime, '$interval', 0)\nORDER BY $__timeGroup(s.CompletedTime, '$interval', 0)",
          "refId": "A"
        },
        {
          "alias": "",
          "format": "time_series",
          "hide": false,
          "rawSql": "SELECT \n  COUNT(d.ReleaseId) AS Deployment,\n    CASE\n    WHEN s.State = 'Failed' THEN 'Failed'\n    WHEN s.State = 'Success' THEN 'Success'\n    WHEN s.State = 'Canceled' THEN 'Cancelled'\n    WHEN s.State = 'Queued' THEN 'Queued'\n    WHEN s.State = 'Executing' THEN 'Executing'\n    WHEN s.State = 'TimedOut' THEN 'Timed Out'\n    WHEN s.State = 'Cancelling' THEN 'Cancelling'\n  END as metric,\n  -- $__timeGroup(s.CompletedTime, '$interval', 0 ) AS [time]\n  $__timeGroup(s.CompletedTime, '$interval', 0 ) AS [time]\nFROM \n  [Octopus].[dbo].[Deployment] d\n  INNER JOIN [Octopus].[dbo].[DeploymentEnvironment] e ON e.Id = d.EnvironmentId\n  INNER JOIN [Octopus].[dbo].[Project] p ON p.Id = d.ProjectId\n  INNER JOIN [Octopus].[dbo].[Release] r ON r.Id = d.ReleaseId\n  INNER JOIN [Octopus].[dbo].[ServerTask] s ON s.Id = d.TaskId\nWHERE \n  s.CompletedTime >=  CONVERT( DATETIMEOFFSET, $__timeFrom(), 0 ) AND\n  s.CompletedTime <   CONVERT( DATETIMEOFFSET, $__timeTo(), 0 ) AND\n  e.Name IN ($environment) AND\n  p.Name IN ($project)\nGROUP BY  $__timeGroup(s.CompletedTime, '$interval', 0), s.State\nORDER BY $__timeGroup(s.CompletedTime, '$interval', 0)",
          "refId": "B"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Deployment Status and Duration",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": null,
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "decimals": null,
          "format": "s",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": true,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_OCTOPUSDEPLOY}",
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 6,
        "w": 12,
        "x": 0,
        "y": 22
      },
      "hiddenSeries": false,
      "id": 34,
      "interval": "",
      "legend": {
        "avg": false,
        "current": false,
        "hideEmpty": false,
        "hideZero": false,
        "max": false,
        "min": false,
        "show": true,
        "total": true,
        "values": true
      },
      "lines": false,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [
        {
          "alias": "Failed",
          "color": "rgba(245, 54, 54, 0.9)"
        },
        {
          "alias": "Success",
          "color": "rgba(50, 172, 45, 0.97)"
        },
        {
          "alias": "Cancelled",
          "color": "rgba(237, 129, 40, 0.89)"
        },
        {
          "alias": "Duration",
          "bars": false,
          "color": "rgb(255, 255, 255)",
          "fill": 0,
          "fillGradient": 0,
          "lines": true,
          "points": true,
          "yaxis": 2
        },
        {
          "alias": "Queued",
          "color": "#434143"
        },
        {
          "alias": "Executing",
          "color": "#1f60c4"
        },
        {
          "alias": "Timed Out",
          "color": "#8f3bb8"
        },
        {
          "alias": "Canceling",
          "color": "#aa8800"
        }
      ],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "alias": "",
          "format": "time_series",
          "hide": false,
          "rawSql": "SELECT \n  AVG(DATEDIFF(ss, s.QueueTime, s.CompletedTime)) AS Duration,\n  -- $__timeGroup(s.CompletedTime, '$interval', 0 ) AS [time]\n  $__timeGroup(s.CompletedTime, '1h', 0 ) AS [time]\nFROM \n  [Octopus].[dbo].[Deployment] d\n  INNER JOIN [Octopus].[dbo].[DeploymentEnvironment] e ON e.Id = d.EnvironmentId\n  INNER JOIN [Octopus].[dbo].[Project] p ON p.Id = d.ProjectId\n  INNER JOIN [Octopus].[dbo].[ServerTask] s ON s.Id = d.TaskId\nWHERE\n  s.CompletedTime >=  CONVERT( DATETIMEOFFSET, $__timeFrom(), 0 ) AND   \n  s.CompletedTime <   CONVERT( DATETIMEOFFSET, $__timeTo(), 0 ) AND\n  e.Name IN ($environment) AND\n  p.Name IN ($project)\nGROUP BY  $__timeGroup(s.CompletedTime, '1h', 0)\nORDER BY $__timeGroup(s.CompletedTime, '1h', 0)",
          "refId": "A"
        },
        {
          "alias": "",
          "format": "time_series",
          "hide": false,
          "rawSql": "SELECT \n  COUNT(d.ReleaseId) AS Deployment,\n    CASE\n    WHEN s.State = 'Failed' THEN 'Failed'\n    WHEN s.State = 'Success' THEN 'Success'\n    WHEN s.State = 'Canceled' THEN 'Cancelled'\n    WHEN s.State = 'Queued' THEN 'Queued'\n    WHEN s.State = 'Executing' THEN 'Executing'\n    WHEN s.State = 'TimedOut' THEN 'Timed Out'\n    WHEN s.State = 'Cancelling' THEN 'Cancelling'\n  END as metric,\n  -- $__timeGroup(s.CompletedTime, '$interval', 0 ) AS [time]\n  $__timeGroup(s.CompletedTime, '1h', 0 ) AS [time]\nFROM \n  [Octopus].[dbo].[Deployment] d\n  INNER JOIN [Octopus].[dbo].[DeploymentEnvironment] e ON e.Id = d.EnvironmentId\n  INNER JOIN [Octopus].[dbo].[Project] p ON p.Id = d.ProjectId\n  INNER JOIN [Octopus].[dbo].[Release] r ON r.Id = d.ReleaseId\n  INNER JOIN [Octopus].[dbo].[ServerTask] s ON s.Id = d.TaskId\nWHERE \n  s.CompletedTime >=  CONVERT( DATETIMEOFFSET, $__timeFrom(), 0 ) AND\n  s.CompletedTime <   CONVERT( DATETIMEOFFSET, $__timeTo(), 0 ) AND\n  e.Name IN ($environment) AND\n  p.Name IN ($project)\nGROUP BY  $__timeGroup(s.CompletedTime, '1h', 0), s.State\nORDER BY $__timeGroup(s.CompletedTime, '1h', 0)",
          "refId": "B"
        }
      ],
      "thresholds": [],
      "timeFrom": "now/w",
      "timeRegions": [],
      "timeShift": null,
      "title": "Deployment Status and Duration (Week so far)",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": null,
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "decimals": null,
          "format": "s",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": true,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_OCTOPUSDEPLOY}",
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 6,
        "w": 12,
        "x": 12,
        "y": 22
      },
      "hiddenSeries": false,
      "id": 35,
      "interval": "",
      "legend": {
        "avg": false,
        "current": false,
        "hideEmpty": false,
        "hideZero": false,
        "max": false,
        "min": false,
        "show": true,
        "total": true,
        "values": true
      },
      "lines": false,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [
        {
          "alias": "Failed",
          "color": "rgba(245, 54, 54, 0.9)"
        },
        {
          "alias": "Success",
          "color": "rgba(50, 172, 45, 0.97)"
        },
        {
          "alias": "Cancelled",
          "color": "rgba(237, 129, 40, 0.89)"
        },
        {
          "alias": "Duration",
          "bars": false,
          "color": "rgb(255, 255, 255)",
          "fill": 0,
          "fillGradient": 0,
          "lines": true,
          "points": true,
          "yaxis": 2
        },
        {
          "alias": "Queued",
          "color": "#434143"
        },
        {
          "alias": "Executing",
          "color": "#1f60c4"
        },
        {
          "alias": "Timed Out",
          "color": "#8f3bb8"
        },
        {
          "alias": "Canceling",
          "color": "#aa8800"
        }
      ],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "alias": "",
          "format": "time_series",
          "hide": false,
          "rawSql": "SELECT \n  AVG(DATEDIFF(ss, s.QueueTime, s.CompletedTime)) AS Duration,\n  -- $__timeGroup(s.CompletedTime, '$interval', 0 ) AS [time]\n  $__timeGroup(s.CompletedTime, '15m', 0 ) AS [time]\nFROM \n  [Octopus].[dbo].[Deployment] d\n  INNER JOIN [Octopus].[dbo].[DeploymentEnvironment] e ON e.Id = d.EnvironmentId\n  INNER JOIN [Octopus].[dbo].[Project] p ON p.Id = d.ProjectId\n  INNER JOIN [Octopus].[dbo].[ServerTask] s ON s.Id = d.TaskId\nWHERE\n  s.CompletedTime >=  CONVERT( DATETIMEOFFSET, $__timeFrom(), 0 ) AND   \n  s.CompletedTime <   CONVERT( DATETIMEOFFSET, $__timeTo(), 0 ) AND\n  e.Name IN ($environment) AND\n  p.Name IN ($project)\nGROUP BY  $__timeGroup(s.CompletedTime, '15m', 0)\nORDER BY $__timeGroup(s.CompletedTime, '15m', 0)",
          "refId": "A"
        },
        {
          "alias": "",
          "format": "time_series",
          "hide": false,
          "rawSql": "SELECT \n  COUNT(d.ReleaseId) AS Deployment,\n    CASE\n    WHEN s.State = 'Failed' THEN 'Failed'\n    WHEN s.State = 'Success' THEN 'Success'\n    WHEN s.State = 'Canceled' THEN 'Cancelled'\n    WHEN s.State = 'Queued' THEN 'Queued'\n    WHEN s.State = 'Executing' THEN 'Executing'\n    WHEN s.State = 'TimedOut' THEN 'Timed Out'\n    WHEN s.State = 'Cancelling' THEN 'Cancelling'\n  END as metric,\n  -- $__timeGroup(s.CompletedTime, '$interval', 0 ) AS [time]\n  $__timeGroup(s.CompletedTime, '15m'', 0 ) AS [time]\nFROM \n  [Octopus].[dbo].[Deployment] d\n  INNER JOIN [Octopus].[dbo].[DeploymentEnvironment] e ON e.Id = d.EnvironmentId\n  INNER JOIN [Octopus].[dbo].[Project] p ON p.Id = d.ProjectId\n  INNER JOIN [Octopus].[dbo].[Release] r ON r.Id = d.ReleaseId\n  INNER JOIN [Octopus].[dbo].[ServerTask] s ON s.Id = d.TaskId\nWHERE \n  s.CompletedTime >=  CONVERT( DATETIMEOFFSET, $__timeFrom(), 0 ) AND\n  s.CompletedTime <   CONVERT( DATETIMEOFFSET, $__timeTo(), 0 ) AND\n  e.Name IN ($environment) AND\n  p.Name IN ($project)\nGROUP BY  $__timeGroup(s.CompletedTime, '15m', 0), s.State\nORDER BY $__timeGroup(s.CompletedTime, '15m', 0)",
          "refId": "B"
        }
      ],
      "thresholds": [],
      "timeFrom": "now/d",
      "timeRegions": [],
      "timeShift": null,
      "title": "Deployment Status and Duration (Today so far)",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": null,
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "decimals": null,
          "format": "s",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {
        "Canceling": "#aa8800",
        "Cancelled": "#ef843c",
        "Executing": "#1f60c4",
        "Failed": "#C4162A",
        "Queued": "#434143",
        "Success": "#37872D",
        "Timed Out": "#8f3bb8"
      },
      "breakPoint": "50%",
      "cacheTimeout": null,
      "combine": {
        "label": "Others",
        "threshold": 0
      },
      "datasource": "${DS_OCTOPUSDEPLOY}",
      "fontSize": "80%",
      "format": "short",
      "gridPos": {
        "h": 7,
        "w": 12,
        "x": 0,
        "y": 28
      },
      "id": 21,
      "interval": null,
      "legend": {
        "header": "",
        "percentage": true,
        "show": true,
        "values": false
      },
      "legendType": "Right side",
      "links": [],
      "maxDataPoints": 3,
      "nullPointMode": "connected",
      "options": {},
      "pieType": "donut",
      "pluginVersion": "6.6.1",
      "strokeWidth": "1",
      "targets": [
        {
          "alias": "",
          "format": "time_series",
          "hide": false,
          "rawSql": "SELECT\n  COUNT(d.TaskId) as Deployment,\n  CASE\n    WHEN s.State = 'Failed' THEN 'Failed'\n    WHEN s.State = 'Success' THEN 'Success'\n    WHEN s.State = 'Canceled' THEN 'Cancelled'\n    WHEN s.State = 'Queued' THEN 'Queued'\n    WHEN s.State = 'Executing' THEN 'Executing'\n    WHEN s.State = 'TimedOut' THEN 'Timed Out'\n    WHEN s.State = 'Cancelling' THEN 'Cancelling'\n  END as metric,\n  $__timeGroup(s.QueueTime, '$interval', 0 ) AS [time]\nFROM \n  [Octopus].[dbo].[Deployment] d\n  INNER JOIN [Octopus].[dbo].[DeploymentEnvironment] e ON e.Id = d.EnvironmentId\n  INNER JOIN [Octopus].[dbo].[Project] p ON p.Id = d.ProjectId\n  INNER JOIN [Octopus].[dbo].[ServerTask] s ON s.Id = d.TaskId\nWHERE \n  s.QueueTime >= CONVERT( DATETIMEOFFSET, $__timeFrom(), 0 ) AND\n  e.Name IN ($environment) AND\n  p.Name IN ($project)\nGROUP BY  $__timeGroup(s.QueueTime, '$interval', 0),  s.State\nORDER BY $__timeGroup(s.QueueTime, '$interval', 0)",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Deployments",
      "transparent": true,
      "type": "grafana-piechart-panel",
      "valueName": "total"
    },
    {
      "datasource": "${DS_OCTOPUSDEPLOY}",
      "gridPos": {
        "h": 5,
        "w": 12,
        "x": 12,
        "y": 28
      },
      "id": 32,
      "options": {
        "displayMode": "gradient",
        "fieldOptions": {
          "calcs": [
            "sum"
          ],
          "defaults": {
            "mappings": [],
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {
                  "color": "rgba(50, 172, 45, 0.97)",
                  "value": null
                }
              ]
            },
            "unit": "short"
          },
          "overrides": [],
          "values": false
        },
        "orientation": "vertical",
        "showUnfilled": true
      },
      "pluginVersion": "6.6.1",
      "targets": [
        {
          "alias": "",
          "format": "time_series",
          "hide": false,
          "rawSql": "SELECT\n  e.Name as Environment,\n  COUNT(d.TaskId) AS Duration,\n  $__timeGroup(s.CompletedTime, '$interval', 0 ) AS [time]\nFROM \n  [Octopus].[dbo].[Deployment] d\n  INNER JOIN [Octopus].[dbo].[DeploymentEnvironment] e ON e.Id = d.EnvironmentId\n  INNER JOIN [Octopus].[dbo].[Project] p ON p.Id = d.ProjectId\n  INNER JOIN [Octopus].[dbo].[ServerTask] s ON s.Id = d.TaskId\nWHERE\n  s.CompletedTime >=  CONVERT( DATETIMEOFFSET, $__timeFrom(), 0 ) AND   \n  s.CompletedTime <   CONVERT( DATETIMEOFFSET, $__timeTo(), 0 ) AND\n  e.Name IN ($environment) AND\n  p.Name IN ($project)\nGROUP BY  $__timeGroup(s.CompletedTime, '$interval', 0), e.Name\nORDER BY $__timeGroup(s.CompletedTime, '$interval', 0)",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Deployments per-environment",
      "type": "bargauge"
    },
    {
      "datasource": "${DS_OCTOPUSDEPLOY}",
      "gridPos": {
        "h": 5,
        "w": 12,
        "x": 12,
        "y": 33
      },
      "id": 27,
      "options": {
        "colorMode": "background",
        "fieldOptions": {
          "calcs": [
            "mean"
          ],
          "defaults": {
            "mappings": [],
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {
                  "color": "semi-dark-yellow",
                  "value": null
                }
              ]
            },
            "title": "⏱️ Avg. Duration of Successful Deployments",
            "unit": "s"
          },
          "overrides": [],
          "values": false
        },
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto"
      },
      "pluginVersion": "6.6.1",
      "targets": [
        {
          "alias": "",
          "format": "time_series",
          "hide": false,
          "rawSql": "SELECT \n  AVG(DATEDIFF(ss, s.QueueTime, s.CompletedTime)) AS Duration,\n  $__timeGroup(s.CompletedTime, '$interval', 0 ) AS [time]\nFROM \n  [Octopus].[dbo].[Deployment] d\n  INNER JOIN [Octopus].[dbo].[DeploymentEnvironment] e ON e.Id = d.EnvironmentId\n  INNER JOIN [Octopus].[dbo].[Project] p ON p.Id = d.ProjectId\n  INNER JOIN [Octopus].[dbo].[ServerTask] s ON s.Id = d.TaskId\nWHERE\n  s.CompletedTime >=  CONVERT( DATETIMEOFFSET, $__timeFrom(), 0 ) AND   \n  s.CompletedTime <   CONVERT( DATETIMEOFFSET, $__timeTo(), 0 ) AND\n  e.Name IN ($environment) AND\n  p.Name IN ($project) AND\n  s.State = 'Success'\nGROUP BY  $__timeGroup(s.CompletedTime, '$interval', 0)\nORDER BY $__timeGroup(s.CompletedTime, '$interval', 0)",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "",
      "transparent": true,
      "type": "stat"
    },
    {
      "columns": [],
      "datasource": "${DS_OCTOPUSDEPLOY}",
      "fontSize": "100%",
      "gridPos": {
        "h": 13,
        "w": 12,
        "x": 0,
        "y": 35
      },
      "id": 33,
      "options": {},
      "pageSize": 25,
      "showHeader": true,
      "sort": {
        "col": null,
        "desc": false
      },
      "styles": [
        {
          "alias": "Project 🚧",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "ProjectName",
          "thresholds": [],
          "type": "string",
          "unit": "short"
        },
        {
          "alias": "Count 🔢",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 0,
          "mappingType": 1,
          "pattern": "Total",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        }
      ],
      "targets": [
        {
          "alias": "",
          "format": "table",
          "hide": false,
          "rawSql": "SELECT TOP 10\n  p.Name AS ProjectName,\n  COUNT(p.Name) AS Total\nFROM \n  [Octopus].[dbo].[Deployment] d\n  INNER JOIN [Octopus].[dbo].[DeploymentEnvironment] e ON e.Id = d.EnvironmentId\n  INNER JOIN [Octopus].[dbo].[Project] p ON p.Id = d.ProjectId\n  INNER JOIN [Octopus].[dbo].[Release] r ON r.Id = d.ReleaseId\n  INNER JOIN [Octopus].[dbo].[ServerTask] s ON s.Id = d.TaskId\nWHERE\n  s.CompletedTime >=  CONVERT( DATETIMEOFFSET, $__timeFrom(), 0 ) AND\n  s.CompletedTime <   CONVERT( DATETIMEOFFSET, $__timeTo(), 0 ) AND\n  e.Name IN ($environment) AND\n  p.Name IN ($project)\nGROUP BY p.Name\nORDER BY count(1) DESC",
          "refId": "B"
        },
        {
          "alias": "",
          "format": "table",
          "hide": true,
          "rawSql": "SELECT \n  COUNT(d.ReleaseId) AS Deployment,\n  s.State AS metric,\n  -- $__timeGroup(s.CompletedTime, '$interval', 0 ) AS [time]\n  $__timeGroup(s.CompletedTime, '1d', 0 ) AS [time]\nFROM \n  [Octopus].[dbo].[Deployment] d\n  INNER JOIN [Octopus].[dbo].[DeploymentEnvironment] e ON e.Id = d.EnvironmentId\n  INNER JOIN [Octopus].[dbo].[Project] p ON p.Id = d.ProjectId\n  INNER JOIN [Octopus].[dbo].[Release] r ON r.Id = d.ReleaseId\n  INNER JOIN [Octopus].[dbo].[ServerTask] s ON s.Id = d.TaskId\nWHERE \n  s.CompletedTime >=  CONVERT( DATETIMEOFFSET, $__timeFrom(), 0 ) AND\n  s.CompletedTime <   CONVERT( DATETIMEOFFSET, $__timeTo(), 0 ) AND\n  e.Name IN ($environment) AND\n  p.Name IN ($project)\nGROUP BY  $__timeGroup(s.CompletedTime, '1d', 0), s.State\nORDER BY $__timeGroup(s.CompletedTime, '1d', 0)",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Most Deployed Projects",
      "transform": "table",
      "type": "table"
    },
    {
      "datasource": "${DS_OCTOPUSDEPLOY}",
      "gridPos": {
        "h": 5,
        "w": 12,
        "x": 12,
        "y": 38
      },
      "id": 28,
      "options": {
        "displayMode": "gradient",
        "fieldOptions": {
          "calcs": [
            "mean"
          ],
          "defaults": {
            "mappings": [],
            "max": 130,
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {
                  "color": "rgba(50, 172, 45, 0.97)",
                  "value": null
                }
              ]
            },
            "unit": "s"
          },
          "overrides": [],
          "values": false
        },
        "orientation": "vertical",
        "showUnfilled": true
      },
      "pluginVersion": "6.6.1",
      "targets": [
        {
          "alias": "",
          "format": "time_series",
          "hide": false,
          "rawSql": "SELECT\n  e.Name as Environment,\n  AVG(DATEDIFF(ss, s.QueueTime, s.CompletedTime)) AS Duration,\n  $__timeGroup(s.CompletedTime, '$interval', 0 ) AS [time]\nFROM \n  [Octopus].[dbo].[Deployment] d\n  INNER JOIN [Octopus].[dbo].[DeploymentEnvironment] e ON e.Id = d.EnvironmentId\n  INNER JOIN [Octopus].[dbo].[Project] p ON p.Id = d.ProjectId\n  INNER JOIN [Octopus].[dbo].[ServerTask] s ON s.Id = d.TaskId\nWHERE\n  s.CompletedTime >=  CONVERT( DATETIMEOFFSET, $__timeFrom(), 0 ) AND   \n  s.CompletedTime <   CONVERT( DATETIMEOFFSET, $__timeTo(), 0 ) AND\n  e.Name IN ($environment) AND\n  p.Name IN ($project)\nGROUP BY  $__timeGroup(s.CompletedTime, '$interval', 0), e.Name\nORDER BY $__timeGroup(s.CompletedTime, '$interval', 0)",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "⏱️ Avg. Duration of Releases",
      "type": "bargauge"
    },
    {
      "datasource": "${DS_OCTOPUSDEPLOY}",
      "gridPos": {
        "h": 5,
        "w": 12,
        "x": 12,
        "y": 43
      },
      "id": 29,
      "options": {
        "displayMode": "gradient",
        "fieldOptions": {
          "calcs": [
            "sum"
          ],
          "defaults": {
            "decimals": 2,
            "links": [],
            "mappings": [],
            "max": 360000,
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {
                  "color": "yellow",
                  "value": null
                }
              ]
            },
            "unit": "s"
          },
          "overrides": [],
          "values": false
        },
        "orientation": "vertical",
        "showUnfilled": true
      },
      "pluginVersion": "6.6.1",
      "targets": [
        {
          "alias": "",
          "format": "time_series",
          "hide": false,
          "rawSql": "SELECT\n  e.Name as Environment,\n  DATEDIFF(ss, s.QueueTime, s.CompletedTime) AS Duration,\n  $__timeGroup(s.CompletedTime, '$interval', 0 ) AS [time]\nFROM \n  [Octopus].[dbo].[Deployment] d\n  INNER JOIN [Octopus].[dbo].[DeploymentEnvironment] e ON e.Id = d.EnvironmentId\n  INNER JOIN [Octopus].[dbo].[Project] p ON p.Id = d.ProjectId\n  INNER JOIN [Octopus].[dbo].[ServerTask] s ON s.Id = d.TaskId\nWHERE\n  s.CompletedTime >=  CONVERT( DATETIMEOFFSET, $__timeFrom(), 0 ) AND   \n  s.CompletedTime <   CONVERT( DATETIMEOFFSET, $__timeTo(), 0 ) AND\n  e.Name IN ($environment) AND\n  p.Name IN ($project)\nGROUP BY  $__timeGroup(s.CompletedTime, '$interval', 0), e.Name, DATEDIFF(ss, s.QueueTime, s.CompletedTime)\nORDER BY $__timeGroup(s.CompletedTime, '$interval', 0)",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "⏱️ Total Duration of Releases",
      "type": "bargauge"
    },
    {
      "columns": [],
      "datasource": "${DS_OCTOPUSDEPLOY}",
      "fontSize": "100%",
      "gridPos": {
        "h": 9,
        "w": 24,
        "x": 0,
        "y": 48
      },
      "id": 14,
      "options": {},
      "pageSize": 100,
      "showHeader": true,
      "sort": {
        "col": null,
        "desc": false
      },
      "styles": [
        {
          "alias": "Project 🚧",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "ProjectName",
          "thresholds": [],
          "type": "string",
          "unit": "short"
        },
        {
          "alias": "State ⭐️",
          "align": "auto",
          "colorMode": "row",
          "colors": [
            "#C4162A",
            "#37872D",
            "#FA6400",
            "#434143",
            "#1F60C4",
            "#8F3BB8",
            "#AA8800"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "TaskStateCode",
          "thresholds": [
            "0.5",
            "1.5",
            "2.5",
            "3.5",
            "4.5",
            "5.5"
          ],
          "type": "string",
          "unit": "short",
          "valueMaps": [
            {
              "text": "Failed",
              "value": "0"
            },
            {
              "text": "Succeeded",
              "value": "1"
            },
            {
              "text": "Cancelled",
              "value": "2"
            },
            {
              "text": "Queued",
              "value": "3"
            },
            {
              "text": "Executing",
              "value": "4"
            },
            {
              "text": "Timed Out",
              "value": "5"
            },
            {
              "text": "Cancelling",
              "value": "6"
            }
          ]
        },
        {
          "alias": "Start Time 🏁",
          "align": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "StartTime",
          "thresholds": [],
          "type": "date",
          "unit": "dateTimeFromNow"
        },
        {
          "alias": "Completed Time 🏁",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "CompletedTime",
          "thresholds": [],
          "type": "date",
          "unit": "short"
        },
        {
          "alias": "Duration ⏱️",
          "align": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "Duration",
          "thresholds": [],
          "type": "number",
          "unit": "s"
        },
        {
          "alias": "Deployed By 👩‍💻",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "DeployedBy",
          "thresholds": [],
          "type": "string",
          "unit": "short"
        },
        {
          "alias": " ",
          "align": "",
          "colorMode": "cell",
          "colors": [
            "#2f2f32",
            "#2f2f32",
            "#2f2f32"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "Icon",
          "preserveFormat": false,
          "sanitize": false,
          "thresholds": [
            "0"
          ],
          "type": "string",
          "unit": "short",
          "valueMaps": [
            {
              "text": "⛔",
              "value": "0"
            },
            {
              "text": "✔️",
              "value": "1"
            },
            {
              "text": "⚠️",
              "value": "2"
            },
            {
              "text": "🕒",
              "value": "3"
            },
            {
              "text": "⚡",
              "value": "4"
            },
            {
              "text": "☄️",
              "value": "5"
            },
            {
              "text": "🚫",
              "value": "6"
            }
          ]
        },
        {
          "alias": "Environment 🌐",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "Environment",
          "thresholds": [],
          "type": "string",
          "unit": "short"
        },
        {
          "alias": "Version #️⃣",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "Version",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        }
      ],
      "targets": [
        {
          "alias": "",
          "format": "table",
          "hide": false,
          "rawSql": "SELECT top 100\n    CASE\n    WHEN s.State = 'Failed' THEN 0\n    WHEN s.State = 'Success' THEN 1\n    WHEN s.State = 'Canceled' THEN 2\n    WHEN s.State = 'Queued' THEN 3\n    WHEN s.State = 'Executing' THEN 4\n    WHEN s.State = 'TimedOut' THEN 5\n    WHEN s.State = 'Cancelling' THEN 6\n  END as Icon,\n  e.Name as Environment,\n  p.Name as ProjectName,\n  r.Version,\n  s.QueueTime AS StartTime,\n  s.CompletedTime,\n  DATEDIFF(ss, s.QueueTime, s.CompletedTime) AS Duration,\n  CASE\n    WHEN s.State = 'Failed' THEN 0\n    WHEN s.State = 'Success' THEN 1\n    WHEN s.State = 'Canceled' THEN 2\n    WHEN s.State = 'Queued' THEN 3\n    WHEN s.State = 'Executing' THEN 4\n    WHEN s.State = 'TimedOut' THEN 5\n    WHEN s.State = 'Cancelling' THEN 6\n  END as TaskStateCode,\n  d.DeployedBy\nFROM \n  [Octopus].[dbo].[Deployment] d\n  INNER JOIN [Octopus].[dbo].[DeploymentEnvironment] e ON e.Id = d.EnvironmentId\n  INNER JOIN [Octopus].[dbo].[Project] p ON p.Id = d.ProjectId\n  INNER JOIN [Octopus].[dbo].[Release] r ON r.Id = d.ReleaseId\n  INNER JOIN [Octopus].[dbo].[ServerTask] s ON s.Id = d.TaskId\nWHERE\n  s.QueueTime >= CONVERT( DATETIMEOFFSET, $__timeFrom(), 0 ) AND\n  CASE    WHEN CONVERT( DATETIMEOFFSET, $__timeTo(), 0 )  BETWEEN  DATEADD(DAY,-1,GETDATE()) AND GETDATE()\n          THEN  isnull(s.CompletedTime,CONVERT( DATETIMEOFFSET, $__timeTo(), 0 ))  \n          ELSE\n            s.CompletedTime\n  END   <= CONVERT( DATETIMEOFFSET, $__timeTo(), 0 )\n  AND--e.completed time will always =e.completed time so else statement will have no constraint\n  e.Name IN ($environment) AND\n  p.Name IN ($project)\nORDER BY s.QueueTime DESC",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Deployments",
      "transform": "table",
      "type": "table"
    },
    {
      "columns": [
        {
          "text": "Avg",
          "value": "avg"
        }
      ],
      "datasource": "${DS_OCTOPUSDEPLOY}",
      "fontSize": "100%",
      "gridPos": {
        "h": 11,
        "w": 15,
        "x": 0,
        "y": 57
      },
      "id": 19,
      "options": {},
      "pageSize": 25,
      "showHeader": true,
      "sort": {
        "col": null,
        "desc": false
      },
      "styles": [
        {
          "alias": "Project 🚧",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "ProjectName",
          "thresholds": [],
          "type": "string",
          "unit": "short"
        },
        {
          "alias": "State ⭐️",
          "align": "auto",
          "colorMode": "row",
          "colors": [
            "#C4162A",
            "#37872D",
            "#FA6400",
            "#434143",
            "#1F60C4",
            "#8F3BB8",
            "#AA8800"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "TaskStateCode",
          "thresholds": [
            "0.5",
            "1.5",
            "2.5",
            "3.5",
            "4.5",
            "5.5"
          ],
          "type": "string",
          "unit": "short",
          "valueMaps": [
            {
              "text": "Failed",
              "value": "0"
            },
            {
              "text": "Succeeded",
              "value": "1"
            },
            {
              "text": "Cancelled",
              "value": "2"
            },
            {
              "text": "Queued",
              "value": "3"
            },
            {
              "text": "Executing",
              "value": "4"
            },
            {
              "text": "Timed Out",
              "value": "5"
            },
            {
              "text": "Cancelling",
              "value": "6"
            }
          ]
        },
        {
          "alias": "Start Time 🏁",
          "align": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "StartTime",
          "thresholds": [],
          "type": "date",
          "unit": "dateTimeFromNow"
        },
        {
          "alias": "Completed Time 🏁",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "CompletedTime",
          "thresholds": [],
          "type": "date",
          "unit": "short"
        },
        {
          "alias": "Duration ⏱️",
          "align": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "Duration",
          "thresholds": [],
          "type": "number",
          "unit": "s"
        },
        {
          "alias": "Deployed By",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "DeployedBy",
          "thresholds": [],
          "type": "string",
          "unit": "short"
        },
        {
          "alias": " ",
          "align": "auto",
          "colorMode": "cell",
          "colors": [
            "#2f2f32",
            "#2f2f32",
            "#2f2f32"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "Icon",
          "thresholds": [
            "0"
          ],
          "type": "string",
          "unit": "short",
          "valueMaps": [
            {
              "text": "⛔",
              "value": "0"
            },
            {
              "text": "✔️",
              "value": "1"
            },
            {
              "text": "⚠️",
              "value": "2"
            },
            {
              "text": "🕒",
              "value": "3"
            },
            {
              "text": "⚡",
              "value": "4"
            },
            {
              "text": "☄️",
              "value": "5"
            },
            {
              "text": "🚫",
              "value": "6"
            }
          ]
        },
        {
          "alias": "Environment 🌐",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "Environment",
          "thresholds": [],
          "type": "string",
          "unit": "short"
        },
        {
          "alias": "Version #️⃣",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "Version",
          "thresholds": [],
          "type": "string",
          "unit": "short"
        }
      ],
      "targets": [
        {
          "alias": "",
          "format": "table",
          "hide": false,
          "rawSql": "SELECT TOP 10\n    CASE\n    WHEN s.State = 'Failed' THEN 0\n    WHEN s.State = 'Success' THEN 1\n    WHEN s.State = 'Canceled' THEN 2\n    WHEN s.State = 'Queued' THEN 3\n    WHEN s.State = 'Executing' THEN 4\n    WHEN s.State = 'TimedOut' THEN 5\n    WHEN s.State = 'Cancelling' THEN 6\n  END as Icon,\n  e.Name as Environment,\n  p.Name as ProjectName,\n  r.Version,\n  DATEDIFF(ss, s.QueueTime, s.CompletedTime) AS Duration,\n  CASE\n    WHEN s.State = 'Failed' THEN 0\n    WHEN s.State = 'Success' THEN 1\n    WHEN s.State = 'Canceled' THEN 2\n    WHEN s.State = 'Queued' THEN 3\n    WHEN s.State = 'Executing' THEN 4\n    WHEN s.State = 'TimedOut' THEN 5\n    WHEN s.State = 'Cancelling' THEN 6\n  END as TaskStateCode\nFROM \n  [Octopus].[dbo].[Deployment] d\n  INNER JOIN [Octopus].[dbo].[DeploymentEnvironment] e ON e.Id = d.EnvironmentId\n  INNER JOIN [Octopus].[dbo].[Project] p ON p.Id = d.ProjectId\n  INNER JOIN [Octopus].[dbo].[Release] r ON r.Id = d.ReleaseId\n  INNER JOIN [Octopus].[dbo].[ServerTask] s ON s.Id = d.TaskId\nWHERE\n  s.QueueTime >= CONVERT( DATETIMEOFFSET, $__timeFrom(), 0 ) AND\n  CASE    WHEN CONVERT( DATETIMEOFFSET, $__timeTo(), 0 )  BETWEEN  DATEADD(DAY,-1,GETDATE()) AND GETDATE()\n          THEN  isnull(s.CompletedTime,CONVERT( DATETIMEOFFSET, $__timeTo(), 0 ))  \n  ELSE\n    s.CompletedTime\n  END   <= CONVERT( DATETIMEOFFSET, $__timeTo(), 0 )\n  AND--e.completed time will always =e.completed time so else statement will have no constraint\n  e.Name IN ($environment) AND\n  p.Name IN ($project)\nORDER BY s.DurationSeconds DESC",
          "refId": "B"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Deployments with Longest Duration",
      "transform": "table",
      "transparent": true,
      "type": "table"
    },
    {
      "columns": [],
      "datasource": "${DS_OCTOPUSDEPLOY}",
      "fontSize": "100%",
      "gridPos": {
        "h": 11,
        "w": 9,
        "x": 15,
        "y": 57
      },
      "id": 31,
      "options": {},
      "pageSize": 25,
      "showHeader": true,
      "sort": {
        "col": null,
        "desc": false
      },
      "styles": [
        {
          "alias": "Project 🚧",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "ProjectName",
          "thresholds": [],
          "type": "string",
          "unit": "short"
        },
        {
          "alias": "Total Failures ⛔",
          "align": "",
          "colorMode": "row",
          "colors": [
            "rgb(194, 156, 3)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(245, 54, 54, 0.9)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 0,
          "mappingType": 1,
          "pattern": "Total",
          "thresholds": [
            "2",
            "5"
          ],
          "type": "number",
          "unit": "short"
        },
        {
          "alias": "Environment 🌐",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "Environment",
          "thresholds": [],
          "type": "string",
          "unit": "short"
        }
      ],
      "targets": [
        {
          "alias": "",
          "format": "table",
          "hide": false,
          "rawSql": "SELECT TOP 10\n  p.Name AS ProjectName,\n  e.Name AS Environment,\n  COUNT(p.Name) AS Total\nFROM \n  [Octopus].[dbo].[Deployment] d\n  INNER JOIN [Octopus].[dbo].[DeploymentEnvironment] e ON e.Id = d.EnvironmentId\n  INNER JOIN [Octopus].[dbo].[Project] p ON p.Id = d.ProjectId\n  INNER JOIN [Octopus].[dbo].[Release] r ON r.Id = d.ReleaseId\n  INNER JOIN [Octopus].[dbo].[ServerTask] s ON s.Id = d.TaskId\nWHERE\n  s.CompletedTime >=  CONVERT( DATETIMEOFFSET, $__timeFrom(), 0 ) AND\n  s.CompletedTime <   CONVERT( DATETIMEOFFSET, $__timeTo(), 0 ) AND\n  e.Name IN ($environment) AND\n  p.Name IN ($project) AND\n  s.State = 'Failed'\nGROUP BY p.Name, e.Name\nORDER BY count(1) DESC",
          "refId": "B"
        },
        {
          "alias": "",
          "format": "table",
          "hide": true,
          "rawSql": "SELECT \n  COUNT(d.ReleaseId) AS Deployment,\n  s.State AS metric,\n  -- $__timeGroup(s.CompletedTime, '$interval', 0 ) AS [time]\n  $__timeGroup(s.CompletedTime, '1d', 0 ) AS [time]\nFROM \n  [Octopus].[dbo].[Deployment] d\n  INNER JOIN [Octopus].[dbo].[DeploymentEnvironment] e ON e.Id = d.EnvironmentId\n  INNER JOIN [Octopus].[dbo].[Project] p ON p.Id = d.ProjectId\n  INNER JOIN [Octopus].[dbo].[Release] r ON r.Id = d.ReleaseId\n  INNER JOIN [Octopus].[dbo].[ServerTask] s ON s.Id = d.TaskId\nWHERE \n  s.CompletedTime >=  CONVERT( DATETIMEOFFSET, $__timeFrom(), 0 ) AND\n  s.CompletedTime <   CONVERT( DATETIMEOFFSET, $__timeTo(), 0 ) AND\n  e.Name IN ($environment) AND\n  p.Name IN ($project)\nGROUP BY  $__timeGroup(s.CompletedTime, '1d', 0), s.State\nORDER BY $__timeGroup(s.CompletedTime, '1d', 0)",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Failed Project Deployment Count",
      "transform": "table",
      "transparent": true,
      "type": "table"
    },
    {
      "columns": [
        {
          "text": "Avg",
          "value": "avg"
        }
      ],
      "datasource": "${DS_OCTOPUSDEPLOY}",
      "fontSize": "100%",
      "gridPos": {
        "h": 10,
        "w": 24,
        "x": 0,
        "y": 68
      },
      "id": 20,
      "options": {},
      "pageSize": 25,
      "showHeader": true,
      "sort": {
        "col": null,
        "desc": false
      },
      "styles": [
        {
          "alias": "State ⭐️",
          "align": "auto",
          "colorMode": "row",
          "colors": [
            "#C4162A",
            "#37872D",
            "#FA6400",
            "#434143",
            "#1F60C4",
            "#8F3BB8",
            "#AA8800"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "TaskStateCode",
          "thresholds": [
            "0.5",
            "1.5",
            "2.5",
            "3.5",
            "4.5",
            "5.5"
          ],
          "type": "string",
          "unit": "short",
          "valueMaps": [
            {
              "text": "Failed",
              "value": "0"
            },
            {
              "text": "Succeeded",
              "value": "1"
            },
            {
              "text": "Cancelled",
              "value": "2"
            },
            {
              "text": "Queued",
              "value": "3"
            },
            {
              "text": "Executing",
              "value": "4"
            },
            {
              "text": "Timed Out",
              "value": "5"
            },
            {
              "text": "Cancelling",
              "value": "6"
            }
          ]
        },
        {
          "alias": "Duration ⏱️",
          "align": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": false,
          "mappingType": 1,
          "pattern": "Duration",
          "thresholds": [],
          "type": "number",
          "unit": "s"
        },
        {
          "alias": " ",
          "align": "left",
          "colorMode": "cell",
          "colors": [
            "#2f2f32",
            "#2f2f32",
            "#2f2f32"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "Icon",
          "thresholds": [
            "0"
          ],
          "type": "string",
          "unit": "short",
          "valueMaps": [
            {
              "text": "⛔",
              "value": "0"
            },
            {
              "text": "✔️",
              "value": "1"
            },
            {
              "text": "⚠️",
              "value": "2"
            },
            {
              "text": "🕒",
              "value": "3"
            },
            {
              "text": "⚡",
              "value": "4"
            },
            {
              "text": "☄️",
              "value": "5"
            },
            {
              "text": "🚫",
              "value": "6"
            }
          ]
        },
        {
          "alias": "Task 🛠️",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "TaskName",
          "preserveFormat": false,
          "sanitize": false,
          "thresholds": [],
          "type": "string",
          "unit": "short"
        },
        {
          "alias": "Error ⛔",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "ErrorMessage",
          "preserveFormat": false,
          "sanitize": false,
          "thresholds": [],
          "type": "string",
          "unit": "short"
        },
        {
          "alias": "Description 📄",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "Description",
          "thresholds": [],
          "type": "string",
          "unit": "short"
        }
      ],
      "targets": [
        {
          "alias": "",
          "format": "table",
          "hide": false,
          "rawSql": "SELECT TOP 10\n    CASE\n    WHEN s.State = 'Failed' THEN 0\n    WHEN s.State = 'Success' THEN 1\n    WHEN s.State = 'Canceled' THEN 2\n    WHEN s.State = 'Queued' THEN 3\n    WHEN s.State = 'Executing' THEN 4\n    WHEN s.State = 'TimedOut' THEN 5\n    WHEN s.State = 'Cancelling' THEN 6\n  END as Icon,\n  s.Name as TaskName,\n  s.Description as Description,\n  s.ErrorMessage,\n  DATEDIFF(ss, s.QueueTime, s.CompletedTime) AS Duration,\n  CASE\n    WHEN s.State = 'Failed' THEN 0\n    WHEN s.State = 'Success' THEN 1\n    WHEN s.State = 'Canceled' THEN 2\n    WHEN s.State = 'Queued' THEN 3\n    WHEN s.State = 'Executing' THEN 4\n    WHEN s.State = 'TimedOut' THEN 5\n    WHEN s.State = 'Cancelling' THEN 6\n  END as TaskStateCode\nFROM \n  [Octopus].[dbo].[Deployment] d\n  INNER JOIN [Octopus].[dbo].[DeploymentEnvironment] e ON e.Id = d.EnvironmentId\n  INNER JOIN [Octopus].[dbo].[Project] p ON p.Id = d.ProjectId\n  INNER JOIN [Octopus].[dbo].[Release] r ON r.Id = d.ReleaseId\n  INNER JOIN [Octopus].[dbo].[ServerTask] s ON s.Id = d.TaskId\nWHERE\n  s.QueueTime >= CONVERT( DATETIMEOFFSET, $__timeFrom(), 0 ) AND\n  CASE    WHEN CONVERT( DATETIMEOFFSET, $__timeTo(), 0 )  BETWEEN  DATEADD(DAY,-1,GETDATE()) AND GETDATE()\n          THEN  isnull(s.CompletedTime,CONVERT( DATETIMEOFFSET, $__timeTo(), 0 ))  \n          ELSE\n            s.CompletedTime\n  END   <= CONVERT( DATETIMEOFFSET, $__timeTo(), 0 )\n  AND--e.completed time will always =e.completed time so else statement will have no constraint\n  e.Name IN ($environment) AND\n  p.Name IN ($project)\nORDER BY s.DurationSeconds DESC",
          "refId": "B"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Tasks with Longest Duration",
      "transform": "table",
      "type": "table"
    }
  ],
  "refresh": "10s",
  "schemaVersion": 22,
  "style": "dark",
  "tags": [
    "OctopusDeploy"
  ],
  "templating": {
    "list": [
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_OCTOPUSDEPLOY}",
        "definition": "SELECT Distinct(EnvironmentName) FROM [DeploymentHistory] WHERE QueueTime >= CONVERT( DATETIMEOFFSET, $__timeFrom(), 0 )",
        "hide": 0,
        "includeAll": true,
        "label": "🌐 Environment",
        "multi": true,
        "name": "environment",
        "options": [],
        "query": "SELECT Distinct(EnvironmentName) FROM [DeploymentHistory] WHERE QueueTime >= CONVERT( DATETIMEOFFSET, $__timeFrom(), 0 )",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "current": {
          "selected": true,
          "text": "",
          "value": ""
        },
        "hide": 0,
        "label": "🔎 Project Search",
        "name": "projectsearch",
        "options": [
          {
            "selected": true,
            "text": "",
            "value": ""
          }
        ],
        "query": "",
        "skipUrlSync": false,
        "type": "textbox"
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_OCTOPUSDEPLOY}",
        "definition": "SELECT Distinct(ProjectName) FROM [DeploymentHistory] WHERE EnvironmentName IN ($environment)  AND QueueTime >= CONVERT( DATETIMEOFFSET, $__timeFrom(), 0 ) AND ProjectName LIKE '%$projectsearch%'",
        "hide": 0,
        "includeAll": true,
        "label": "🚧 Project",
        "multi": true,
        "name": "project",
        "options": [],
        "query": "SELECT Distinct(ProjectName) FROM [DeploymentHistory] WHERE EnvironmentName IN ($environment)  AND QueueTime >= CONVERT( DATETIMEOFFSET, $__timeFrom(), 0 ) AND ProjectName LIKE '%$projectsearch%'",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "auto": true,
        "auto_count": 30,
        "auto_min": "15m",
        "current": {
          "selected": false,
          "text": "auto",
          "value": "$__auto_interval_interval"
        },
        "hide": 0,
        "label": "⏳ Time Grain",
        "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": "15m",
            "value": "15m"
          },
          {
            "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,15m,30m,1h,6h,12h,1d,7d,14d,30d",
        "refresh": 2,
        "skipUrlSync": false,
        "type": "interval"
      }
    ]
  },
  "time": {
    "from": "now-30d",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ]
  },
  "timezone": "",
  "title": "Octopus Deploy",
  "uid": "3hW54K8Wz",
  "version": 122
}