Grafana dashboard: State of Postgres 2022 Answer Insights
Description: Postgres dashboard


{
  "__inputs": [
    {
      "name": "DS_STATE_OF_POSTGRES",
      "label": "State_of_Postgres",
      "description": "",
      "type": "datasource",
      "pluginId": "postgres",
      "pluginName": "PostgreSQL"
    }
  ],
  "__elements": [],
  "__requires": [
    {
      "type": "panel",
      "id": "barchart",
      "name": "Bar chart",
      "version": ""
    },
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "8.4.7"
    },
    {
      "type": "panel",
      "id": "piechart",
      "name": "Pie chart",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "postgres",
      "name": "PostgreSQL",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "stat",
      "name": "Stat",
      "version": ""
    },
    {
      "type": "panel",
      "id": "table",
      "name": "Table",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "target": {
          "limit": 100,
          "matchAny": false,
          "tags": [],
          "type": "dashboard"
        },
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1658150754876,
  "links": [],
  "liveNow": false,
  "panels": [
    {
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisLabel": "",
            "axisPlacement": "auto",
            "axisSoftMin": 0,
            "fillOpacity": 80,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineWidth": 1,
            "scaleDistribution": {
              "type": "linear"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 11,
        "w": 15,
        "x": 0,
        "y": 0
      },
      "id": 13,
      "options": {
        "barRadius": 0,
        "barWidth": 0.97,
        "groupWidth": 0.7,
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom"
        },
        "orientation": "auto",
        "showValue": "never",
        "stacking": "normal",
        "tooltip": {
          "mode": "multi",
          "sort": "none"
        },
        "xTickLabelRotation": -45,
        "xTickLabelSpacing": 100
      },
      "targets": [
        {
          "datasource": {
            "type": "postgres",
            "uid": "${DS_STATE_OF_POSTGRES}"
          },
          "format": "table",
          "group": [],
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "\tSELECT UNNEST(string_to_array(answer_value,'|')) answer_value,\n\t  count(*) FILTER(where r.min_yrs_exp=0) AS \"<1 year\",\n\t  count(*) FILTER(where r.min_yrs_exp=1) AS \"1-2 years\",\n\t  count(*) FILTER(where r.min_yrs_exp=3) AS \"3-5 years\",\n\t  count(*) FILTER(where r.min_yrs_exp=6) AS \"6-10 years\",\n\t  count(*) FILTER(where r.min_yrs_exp=11) AS \"11-15 years\",\n\t  count(*) FILTER(where r.min_yrs_exp=15) AS \"15+ years\"\t  \n\tFROM answer a\n\t  inner join response r on a.response_token = r.token\n\tWHERE question_id = '$question_id'\n\tand response_token IN (select token from response where min_yrs_exp in ($min_yrs_exp))\n\tGROUP BY 1\n\tORDER BY 1;\n",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              }
            ]
          ],
          "timeColumn": "time",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "$question_text - by Years of PG Experience",
      "type": "barchart"
    },
    {
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            }
          },
          "mappings": []
        },
        "overrides": []
      },
      "gridPos": {
        "h": 15,
        "w": 9,
        "x": 15,
        "y": 0
      },
      "id": 10,
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "values": [
            "percent"
          ]
        },
        "pieType": "pie",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": true
        },
        "tooltip": {
          "mode": "single",
          "sort": "none"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "postgres",
            "uid": "${DS_STATE_OF_POSTGRES}"
          },
          "format": "table",
          "group": [],
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "SELECT count(*), UNNEST(string_to_array(answer_value,'|')) answer_value\nFROM answer a \nWHERE question_id = '$question_id'\n and a.response_token in (select token from response where min_yrs_exp in ($min_yrs_exp) and region in ($region) and pg_contrib in ($pg_contrib))\nGROUP BY 2;",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              }
            ]
          ],
          "timeColumn": "time",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "$question_text",
      "type": "piechart"
    },
    {
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisLabel": "",
            "axisPlacement": "auto",
            "axisSoftMin": 0,
            "fillOpacity": 80,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineWidth": 1,
            "scaleDistribution": {
              "type": "linear"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 12,
        "w": 15,
        "x": 0,
        "y": 11
      },
      "id": 14,
      "options": {
        "barRadius": 0,
        "barWidth": 0.97,
        "groupWidth": 0.7,
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom"
        },
        "orientation": "auto",
        "showValue": "never",
        "stacking": "normal",
        "tooltip": {
          "mode": "single",
          "sort": "none"
        },
        "xTickLabelRotation": -45,
        "xTickLabelSpacing": 100
      },
      "targets": [
        {
          "datasource": {
            "type": "postgres",
            "uid": "${DS_STATE_OF_POSTGRES}"
          },
          "format": "table",
          "group": [],
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "\tSELECT UNNEST(string_to_array(answer_value,'|')) answer_value,\n\t  count(*) FILTER(where r.region like 'APAC%') AS \"APAC (Asia-Pacific)\",\n\t  count(*) FILTER(where r.region like 'South%') AS \"South America\",\n\t  count(*) FILTER(where r.region like 'Prefer%') AS \"Prefer not to say\",\n\t  count(*) FILTER(where r.region like 'North%') AS \"North America\",\n\t  count(*) FILTER(where r.region like 'EMEA%') AS \"EMEA (Europe, Middle East, Africa)\"\t  \n\tFROM answer a\n\t  inner join response r on a.response_token = r.token\n\tWHERE question_id = '$question_id'\n\tand response_token IN (select token from response where region in ($region))\n\tGROUP BY 1\n\tORDER BY 1;\n",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              }
            ]
          ],
          "timeColumn": "time",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "$question_text - by World Region",
      "type": "barchart"
    },
    {
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {
            "align": "auto",
            "displayMode": "auto"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 19,
        "w": 9,
        "x": 15,
        "y": 15
      },
      "id": 17,
      "options": {
        "footer": {
          "fields": "",
          "reducer": [
            "sum"
          ],
          "show": false
        },
        "showHeader": true
      },
      "pluginVersion": "8.4.7",
      "targets": [
        {
          "datasource": {
            "type": "postgres",
            "uid": "${DS_STATE_OF_POSTGRES}"
          },
          "format": "table",
          "group": [],
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "select answer_value from answer where question_id = '$question_id_free_form'\nand response_token in (select token from response where pg_contrib in ($pg_contrib) and min_yrs_exp in ($min_yrs_exp) and region in ($region));\n",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              }
            ]
          ],
          "timeColumn": "time",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "$question_text_free_form",
      "type": "table"
    },
    {
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisLabel": "",
            "axisPlacement": "auto",
            "axisSoftMin": 0,
            "fillOpacity": 80,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineWidth": 1,
            "scaleDistribution": {
              "type": "linear"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 12,
        "w": 15,
        "x": 0,
        "y": 23
      },
      "id": 15,
      "options": {
        "barRadius": 0,
        "barWidth": 0.97,
        "groupWidth": 0.7,
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom"
        },
        "orientation": "auto",
        "showValue": "never",
        "stacking": "normal",
        "tooltip": {
          "mode": "single",
          "sort": "none"
        },
        "xTickLabelRotation": -45,
        "xTickLabelSpacing": 100
      },
      "targets": [
        {
          "datasource": {
            "type": "postgres",
            "uid": "${DS_STATE_OF_POSTGRES}"
          },
          "format": "table",
          "group": [],
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "\tSELECT UNNEST(string_to_array(answer_value,'|')) answer_value,\n\t  count(*) FILTER(where r.pg_contrib=0) AS \"No contributions\",\n\t  count(*) FILTER(where r.pg_contrib=1) AS \"Contributes some\",\n\t  count(*) FILTER(where r.pg_contrib=2) AS \"Contributes often\"\n\tFROM answer a\n\t  inner join response r on a.response_token = r.token\n\tWHERE question_id = '$question_id'\n\tand response_token IN (select token from response where pg_contrib in ($pg_contrib))\n\tGROUP BY 1\n\tORDER BY 1;\n",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              }
            ]
          ],
          "timeColumn": "time",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "$question_text - by Postgres Contribution",
      "type": "barchart"
    },
    {
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 4,
        "w": 2,
        "x": 22,
        "y": 34
      },
      "id": 12,
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "textMode": "auto"
      },
      "pluginVersion": "8.4.7",
      "targets": [
        {
          "datasource": {
            "type": "postgres",
            "uid": "${DS_STATE_OF_POSTGRES}"
          },
          "format": "table",
          "group": [],
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "select count(*) value from response;",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              }
            ]
          ],
          "timeColumn": "time",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "Panel Title",
      "type": "stat"
    }
  ],
  "refresh": "",
  "schemaVersion": 35,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "current": {},
        "definition": "select title from question where question_type = ANY('{\"yes_no\", \"multiple_choice\", \"opinion_scale\"}');",
        "hide": 0,
        "includeAll": false,
        "label": "Question (non-free form)",
        "multi": false,
        "name": "question_text",
        "options": [],
        "query": "select title from question where question_type = ANY('{\"yes_no\", \"multiple_choice\", \"opinion_scale\"}');",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query",
        "datasource": "${DS_STATE_OF_POSTGRES}"
      },
      {
        "current": {},
        "definition": "select id from question where title = '$question_text';",
        "hide": 2,
        "includeAll": false,
        "multi": false,
        "name": "question_id",
        "options": [],
        "query": "select id from question where title = '$question_text';",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query",
        "datasource": "${DS_STATE_OF_POSTGRES}"
      },
      {
        "current": {
          "selected": false,
          "text": [
            "All"
          ],
          "value": [
            "$__all"
          ]
        },
        "hide": 0,
        "includeAll": true,
        "label": "Min Years of PG Experience",
        "multi": true,
        "name": "min_yrs_exp",
        "options": [
          {
            "selected": true,
            "text": "All",
            "value": "$__all"
          },
          {
            "selected": false,
            "text": "0",
            "value": "0"
          },
          {
            "selected": false,
            "text": "1",
            "value": "1"
          },
          {
            "selected": false,
            "text": "3",
            "value": "3"
          },
          {
            "selected": false,
            "text": "6",
            "value": "6"
          },
          {
            "selected": false,
            "text": "11",
            "value": "11"
          },
          {
            "selected": false,
            "text": "15",
            "value": "15"
          }
        ],
        "query": "0,1,3,6,11,15",
        "queryValue": "",
        "skipUrlSync": false,
        "type": "custom"
      },
      {
        "current": {},
        "definition": "select distinct region from response where region is not null;",
        "hide": 0,
        "includeAll": true,
        "label": "World Region",
        "multi": true,
        "name": "region",
        "options": [],
        "query": "select distinct region from response where region is not null;",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 1,
        "type": "query",
        "datasource": "${DS_STATE_OF_POSTGRES}"
      },
      {
        "current": {
          "selected": false,
          "text": [
            "All"
          ],
          "value": [
            "$__all"
          ]
        },
        "description": "0=No, 1=Some, 2=Often",
        "hide": 0,
        "includeAll": true,
        "label": "Postgres Contributor",
        "multi": true,
        "name": "pg_contrib",
        "options": [
          {
            "selected": true,
            "text": "All",
            "value": "$__all"
          },
          {
            "selected": false,
            "text": "0",
            "value": "0"
          },
          {
            "selected": false,
            "text": "1",
            "value": "1"
          },
          {
            "selected": false,
            "text": "2",
            "value": "2"
          }
        ],
        "query": "0,1,2",
        "queryValue": "",
        "skipUrlSync": false,
        "type": "custom"
      },
      {
        "current": {},
        "definition": "select title from question where question_type = ANY('{\"long_text\"}');",
        "hide": 0,
        "includeAll": false,
        "label": "Question (free form)",
        "multi": false,
        "name": "question_text_free_form",
        "options": [],
        "query": "select title from question where question_type = ANY('{\"long_text\"}');",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query",
        "datasource": "${DS_STATE_OF_POSTGRES}"
      },
      {
        "current": {},
        "definition": "select id from question where title = '$question_text_free_form';",
        "hide": 2,
        "includeAll": false,
        "multi": false,
        "name": "question_id_free_form",
        "options": [],
        "query": "select id from question where title = '$question_text_free_form';",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query",
        "datasource": "${DS_STATE_OF_POSTGRES}"
      }
    ]
  },
  "time": {
    "from": "now-30d",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "State of Postgres 2022 Answer Insights",
  "uid": "RISu2F3nk",
  "version": 12,
  "weekStart": "",
  "gnetId": 17815,
  "description": "Postgres dashboard"
}