Grafana dashboard: Usage Insights - 1 - Overview
Description: This is a Usage Insights dashboard expecting Grafana events in logfmt instead of json.


{
  "__inputs": [
    {
      "description": "Provisioned Loki log stream for usage insights in Grafana Cloud.",
      "label": "loki-datasource",
      "name": "DS_LOKI",
      "pluginId": "loki",
      "pluginName": "Loki",
      "type": "datasource"
    },
    {
      "description": "Provisioned Prometheus metrics on general usage in Grafana Cloud.",
      "label": "prometheus",
      "name": "DS_PROMETHEUS",
      "pluginId": "prometheus",
      "pluginName": "Prometheus",
      "type": "datasource"
    }
  ],
  "description": "This is a Usage Insights dashboard expecting Grafana events in logfmt instead of json.",
  "editable": false,
  "gnetId": 15083,
  "graphTooltip": 0,
  "links": [
    {
      "icon": "cloud",
      "targetBlank": false,
      "title": "Data Source Insights",
      "tooltip": "",
      "type": "link",
      "url": "/d/AEbrOO2Mz"
    },
    {
      "icon": "bolt",
      "targetBlank": false,
      "title": "Query Errors Insights",
      "tooltip": "",
      "type": "link",
      "url": "/d/MpmkYhRVz"
    }
  ],
  "panels": [
    {
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "title": "Usage Insight KPI",
      "type": "row"
    },
    {
      "datasource": {
        "type": "loki",
        "uid": "${DS_LOKI}"
      },
      "description": "",
      "fieldConfig": {
        "defaults": {
          "color": {
            "fixedColor": "purple",
            "mode": "fixed"
          },
          "unit": "short"
        }
      },
      "gridPos": {
        "h": 4,
        "w": 6,
        "x": 0,
        "y": 1
      },
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "justifyMode": "center",
        "orientation": "auto",
        "reduceOptions": {
          "fields": "/^Value \\#A$/"
        },
        "textMode": "value"
      },
      "targets": [
        {
          "expr": "sum(count_over_time({instance_type=\"grafana\", instance_id=~\"$instance_id\"} [$__range]))",
          "legendFormat": "",
          "queryType": "instant",
          "refId": "A"
        }
      ],
      "title": "Total usage insights events",
      "type": "stat"
    },
    {
      "datasource": {
        "type": "loki",
        "uid": "${DS_LOKI}"
      },
      "description": "",
      "fieldConfig": {
        "defaults": {
          "color": {
            "fixedColor": "purple",
            "mode": "fixed"
          },
          "custom": {
            "filterable": false
          }
        }
      },
      "gridPos": {
        "h": 4,
        "w": 6,
        "x": 6,
        "y": 1
      },
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "fields": "/^Value \\#A$/"
        },
        "textMode": "value"
      },
      "targets": [
        {
          "expr": "count(sum by (datasourceId) (count_over_time({instance_type=\"grafana\", instance_id=~\"$instance_id\"} | logfmt | error=\"\" | datasourceName != \"-- Grafana --\" | datasourceName != \"-- Mixed --\" [$__range])))",
          "legendFormat": "",
          "queryType": "instant",
          "refId": "A"
        }
      ],
      "title": "Data sources Used",
      "type": "stat"
    },
    {
      "datasource": {
        "type": "loki",
        "uid": "${DS_LOKI}"
      },
      "description": "",
      "fieldConfig": {
        "defaults": {
          "color": {
            "fixedColor": "purple",
            "mode": "fixed"
          }
        }
      },
      "gridPos": {
        "h": 4,
        "w": 6,
        "x": 12,
        "y": 1
      },
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "fields": "/^Value \\#A$/"
        },
        "textMode": "value"
      },
      "targets": [
        {
          "expr": "count(sum by (dashboardId) (count_over_time({instance_type=\"grafana\", instance_id=~\"$instance_id\" } | logfmt |  error=\"\" [$__range])))",
          "legendFormat": "",
          "queryType": "instant",
          "refId": "A"
        }
      ],
      "title": "Dashboards Used",
      "type": "stat"
    },
    {
      "datasource": {
        "type": "loki",
        "uid": "${DS_LOKI}"
      },
      "description": "",
      "fieldConfig": {
        "defaults": {
          "color": {
            "fixedColor": "purple",
            "mode": "fixed"
          }
        }
      },
      "gridPos": {
        "h": 4,
        "w": 6,
        "x": 18,
        "y": 1
      },
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "fields": "/^Value \\#A$/"
        },
        "textMode": "value"
      },
      "targets": [
        {
          "expr": "count(sum by (userId) (count_over_time({instance_type=\"grafana\", instance_id=~\"$instance_id\"} | logfmt [$__range])))",
          "legendFormat": "",
          "queryType": "instant",
          "refId": "A"
        }
      ],
      "title": "Users Seen",
      "type": "stat"
    },
    {
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 5
      },
      "title": "Usage Insight Details",
      "type": "row"
    },
    {
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": {
        "type": "loki",
        "uid": "${DS_LOKI}"
      },
      "fieldConfig": {
        "defaults": {
          "unit": "short"
        }
      },
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 8,
        "w": 24,
        "x": 0,
        "y": 6
      },
      "hiddenSeries": false,
      "interval": "5m",
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "nullPointMode": "null as zero",
      "options": {
        "alertThreshold": true
      },
      "percentage": false,
      "pointradius": 0.5,
      "points": true,
      "renderer": "flot",
      "seriesOverrides": [
        {
          "$$hashKey": "object:220",
          "alias": "/errors/",
          "color": "#E02F44"
        },
        {
          "$$hashKey": "object:221",
          "alias": "/successes/",
          "color": "#3274D9"
        },
        {
          "$$hashKey": "object:736",
          "alias": "/views/",
          "color": "#56A64B"
        }
      ],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "sum by(host) (count_over_time({instance_type=\"grafana\", instance_id=~\"$instance_id\"} | logfmt | eventName=\"data-request\" | error = \"\" [$__interval]))",
          "legendFormat": "Data Request successes",
          "refId": "A"
        },
        {
          "expr": "sum by(host) (count_over_time({instance_type=\"grafana\", instance_id=~\"$instance_id\"} | logfmt | eventName=\"data-request\" | error != \"\" [$__interval]))",
          "legendFormat": "Data Requests errors",
          "refId": "B"
        },
        {
          "expr": "sum by(host) (count_over_time({instance_type=\"grafana\", instance_id=~\"$instance_id\"} | logfmt | eventName=\"dashboard-view\" [$__interval]))",
          "legendFormat": "Dashboard views",
          "refId": "C"
        }
      ],
      "title": "Usage insights events",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "mode": "time",
        "show": true
      },
      "yaxes": [
        {
          "$$hashKey": "object:234",
          "decimals": 0,
          "format": "short",
          "logBase": 1,
          "show": true
        },
        {
          "$$hashKey": "object:235",
          "format": "short",
          "logBase": 1,
          "show": false
        }
      ],
      "yaxis": {
        "align": false
      }
    },
    {
      "datasource": {
        "type": "loki",
        "uid": "${DS_LOKI}"
      },
      "fieldConfig": {
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Views"
            },
            "properties": [
              {
                "id": "custom.displayMode",
                "value": "lcd-gauge"
              },
              {
                "id": "color",
                "value": {
                  "mode": "continuous-BlPu"
                }
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 7,
        "w": 8,
        "x": 0,
        "y": 14
      },
      "interval": "",
      "options": {
        "showHeader": true,
        "sortBy": [
          {
            "desc": true,
            "displayName": "Views"
          }
        ]
      },
      "targets": [
        {
          "expr": "topk(10, sum by (dashboardId,dashboardName,folderName) (count_over_time({instance_type=\"grafana\", instance_id=~\"$instance_id\"} | logfmt | eventName=\"dashboard-view\" [$__range])))",
          "legendFormat": "{{dashboardName}}",
          "queryType": "range",
          "refId": "A"
        }
      ],
      "title": "Top 10 dashboards",
      "transformations": [
        {
          "id": "reduce",
          "options": {
            "labelsToFields": true,
            "reducers": [
              "last"
            ]
          }
        },
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Field": true,
              "Time": true,
              "dashboardId": true,
              "folderName": true
            },
            "renameByName": {
              "Last": "Views",
              "dashboardName": "Name"
            }
          }
        }
      ],
      "type": "table"
    },
    {
      "datasource": {
        "type": "loki",
        "uid": "${DS_LOKI}"
      },
      "fieldConfig": {
        "defaults": {
          "links": [
            {
              "title": "Go to datasource usage insights",
              "url": "/d/AEbrOO2Mz/usage-insights-for-datasource?var-datasource_id=${__data.fields.ID}&var-datasource_name=${__data.fields.Name:percentencode}&${__url_time_range}"
            }
          ]
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Query Count"
            },
            "properties": [
              {
                "id": "custom.displayMode",
                "value": "lcd-gauge"
              },
              {
                "id": "color",
                "value": {
                  "mode": "continuous-BlPu"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "ID"
            },
            "properties": [
              {
                "id": "custom.width",
                "value": 41
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 7,
        "w": 8,
        "x": 8,
        "y": 14
      },
      "interval": "",
      "options": {
        "showHeader": true,
        "sortBy": [
          {
            "desc": true,
            "displayName": "Query Count"
          }
        ]
      },
      "targets": [
        {
          "expr": "topk(10, sum by (datasourceName, datasourceId) (count_over_time({instance_type=\"grafana\", instance_id=~\"$instance_id\"} | logfmt | eventName=\"data-request\" | datasourceName != \"-- Grafana --\" | datasourceName != \"-- Mixed --\" [$__range])))",
          "legendFormat": "",
          "queryType": "range",
          "refId": "A"
        }
      ],
      "title": "Top 10 data sources",
      "transformations": [
        {
          "id": "reduce",
          "options": {
            "labelsToFields": true,
            "reducers": [
              "last"
            ]
          }
        },
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Field": true,
              "Time": true
            },
            "renameByName": {
              "Last": "Query Count",
              "datasourceId": "ID",
              "datasourceName": "Name"
            }
          }
        }
      ],
      "type": "table"
    },
    {
      "datasource": {
        "type": "loki",
        "uid": "${DS_LOKI}"
      },
      "fieldConfig": {
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Views"
            },
            "properties": [
              {
                "id": "custom.displayMode",
                "value": "lcd-gauge"
              },
              {
                "id": "color",
                "value": {
                  "mode": "continuous-BlPu"
                }
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 7,
        "w": 8,
        "x": 16,
        "y": 14
      },
      "interval": "",
      "options": {
        "showHeader": true,
        "sortBy": [
          {
            "desc": true,
            "displayName": "Views"
          }
        ]
      },
      "targets": [
        {
          "expr": "topk(10, sum by (username) (count_over_time({instance_type=\"grafana\", instance_id=~\"$instance_id\"} | logfmt | eventName=\"dashboard-view\" [$__range])))",
          "legendFormat": "{{username}}",
          "queryType": "range",
          "refId": "A"
        }
      ],
      "title": "Top 10 users",
      "transformations": [
        {
          "id": "reduce",
          "options": {
            "labelsToFields": true,
            "reducers": [
              "last"
            ]
          }
        },
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Field": true,
              "Time": true
            },
            "renameByName": {
              "Last": "Views",
              "username": "Name"
            }
          }
        }
      ],
      "type": "table"
    },
    {
      "datasource": {
        "type": "loki",
        "uid": "${DS_LOKI}"
      },
      "description": "Click on the error count to view errors",
      "fieldConfig": {
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Error Count"
            },
            "properties": [
              {
                "id": "custom.displayMode",
                "value": "lcd-gauge"
              },
              {
                "id": "color",
                "value": {
                  "mode": "continuous-YlRd"
                }
              },
              {
                "id": "links",
                "value": [
                  {
                    "targetBlank": true,
                    "title": "View errors",
                    "url": "/d/MpmkYhRVz?var-search=${__data.fields.UID}"
                  }
                ]
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "UID"
            },
            "properties": [
              {
                "id": "custom.hidden",
                "value": true
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 7,
        "w": 8,
        "x": 0,
        "y": 21
      },
      "interval": "",
      "options": {
        "showHeader": true,
        "sortBy": [
          {
            "desc": true,
            "displayName": "Error Count"
          }
        ]
      },
      "targets": [
        {
          "expr": "topk(10, sum by (dashboardUid,dashboardName) (count_over_time({instance_type=\"grafana\", instance_id=~\"$instance_id\"} | logfmt | eventName=\"data-request\" | error!=\"\" [$__range])))",
          "legendFormat": "",
          "queryType": "range",
          "refId": "A"
        }
      ],
      "title": "Top 10 dashboards with errors",
      "transformations": [
        {
          "id": "reduce",
          "options": {
            "labelsToFields": true,
            "reducers": [
              "last"
            ]
          }
        },
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Field": true,
              "Time": true
            },
            "renameByName": {
              "Last": "Error Count",
              "dashboardName": "Name",
              "dashboardUid": "UID"
            }
          }
        }
      ],
      "type": "table"
    },
    {
      "datasource": {
        "type": "loki",
        "uid": "${DS_LOKI}"
      },
      "description": "Click on the data source name or ID to view details, click on the error count to view errors",
      "fieldConfig": {
        "defaults": {
          "links": [
            {
              "title": "Go to data source usage insights",
              "url": "/d/AEbrOO2Mz/usage-insights-for-datasource?var-datasource_id=${__data.fields.ID}&var-datasource_name=${__data.fields.Name:percentencode}&${__url_time_range}"
            }
          ]
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Error Count"
            },
            "properties": [
              {
                "id": "custom.displayMode",
                "value": "lcd-gauge"
              },
              {
                "id": "color",
                "value": {
                  "mode": "continuous-YlRd"
                }
              },
              {
                "id": "links",
                "value": [
                  {
                    "targetBlank": true,
                    "title": "View errors",
                    "url": "/d/MpmkYhRVz?var-search=${__data.fields.Name}"
                  }
                ]
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "ID"
            },
            "properties": [
              {
                "id": "custom.width",
                "value": 41
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 7,
        "w": 8,
        "x": 8,
        "y": 21
      },
      "interval": "",
      "options": {
        "showHeader": true,
        "sortBy": [
          {
            "desc": true,
            "displayName": "Error Count"
          }
        ]
      },
      "targets": [
        {
          "expr": "topk(10, sum by (datasourceName, datasourceId) (count_over_time({instance_type=\"grafana\", instance_id=~\"$instance_id\"} | logfmt | eventName=\"data-request\" | datasourceName != \"-- Grafana --\" | datasourceName != \"-- Mixed --\" | error!=\"\" [$__range])))",
          "legendFormat": "",
          "queryType": "range",
          "refId": "A"
        }
      ],
      "title": "Top 10 data sources with errors",
      "transformations": [
        {
          "id": "reduce",
          "options": {
            "labelsToFields": true,
            "reducers": [
              "last"
            ]
          }
        },
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Field": true,
              "Time": true
            },
            "renameByName": {
              "Last": "Error Count",
              "datasourceId": "ID",
              "datasourceName": "Name"
            }
          }
        }
      ],
      "type": "table"
    },
    {
      "datasource": {
        "type": "loki",
        "uid": "${DS_LOKI}"
      },
      "description": "Click on the error count to view errors",
      "fieldConfig": {
        "defaults": {
          "custom": {
            "displayMode": "auto",
            "filterable": false
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Error Count"
            },
            "properties": [
              {
                "id": "custom.displayMode",
                "value": "lcd-gauge"
              },
              {
                "id": "color",
                "value": {
                  "mode": "continuous-YlRd"
                }
              },
              {
                "id": "links",
                "value": [
                  {
                    "targetBlank": true,
                    "title": "View errors",
                    "url": "/d/MpmkYhRVz?var-search=${__data.fields.Username}"
                  }
                ]
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 7,
        "w": 8,
        "x": 16,
        "y": 21
      },
      "interval": "",
      "options": {
        "showHeader": true,
        "sortBy": [
          {
            "desc": true,
            "displayName": "Error Count"
          }
        ]
      },
      "targets": [
        {
          "expr": "topk(10, sum by (username) (count_over_time({instance_type=\"grafana\", instance_id=~\"$instance_id\"} | logfmt | eventName=\"data-request\" | error!=\"\" | datasourceName != \"-- Grafana --\" | datasourceName != \"-- Mixed --\" [$__range])))",
          "legendFormat": "{{username}}",
          "queryType": "range",
          "refId": "A"
        }
      ],
      "title": "Top 10 users seeing errors",
      "transformations": [
        {
          "id": "reduce",
          "options": {
            "labelsToFields": true,
            "reducers": [
              "last"
            ]
          }
        },
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Field": true,
              "Time": true
            },
            "renameByName": {
              "Last": "Error Count",
              "username": "Username"
            }
          }
        }
      ],
      "type": "table"
    }
  ],
  "refresh": "",
  "schemaVersion": 32,
  "style": "dark",
  "tags": [
    "grafanacloud"
  ],
  "templating": {
    "list": [
      {
        "allValue": ".*",
        "current": {
          "selected": false,
          "text": "All",
          "value": "$__all"
        },
        "datasource": {
          "type": "prometheus",
          "uid": "${DS_PROMETHEUS}"
        },
        "definition": "grafanacloud_grafana_instance_info{}",
        "hide": 0,
        "includeAll": true,
        "label": "Instance",
        "multi": false,
        "name": "instance_id",
        "query": {
          "query": "grafanacloud_grafana_instance_info{}",
          "refId": "StandardVariableQuery"
        },
        "refresh": 1,
        "regex": "/,id=\"(?<value>[^\"]+)|,slug=\"(?<text>[^\"]+)/g",
        "skipUrlSync": false,
        "sort": 5,
        "type": "query"
      }
    ]
  },
  "time": {
    "from": "now-24h",
    "to": "now"
  },
  "timezone": "",
  "title": "Usage Insights - 1 - Overview",
  "uid": "XU8HAD5Gk",
  "version": 28
}