Export logs of usage insights
By exporting usage logs to Loki, you can directly query them and create dashboards of the information that matters to you most, such as dashboard errors, most active organizations, or your top-10 most-used queries.
- A user opens a dashboard.
- A query is sent to a data source.
A log is created every time a user opens a dashboard or when a query is sent to a data source in the dashboard view. A query that is performed via Explore does not generate a log.
Format
The following procedure assumes that you have installed Loki. Refer to Install Loki.
Now that your logs are exported into Loki, you can build Grafana dashboards to understand your Grafana instance usage.
- Add Loki as a data source. Refer to Grafana fundamentals tutorial.
- Import one of the following dashboards:
- Play with usage insights to understand them:
- In Explore, you can use the query
{datasource="gdev-loki",kind="usage_insights"}
to retrieve all logs related to yourgdev-loki
data source. - In a dashboard, you can build a table panel with the query
topk(10, sum by (error) (count_over_time({kind="usage_insights", datasource="gdev-prometheus"} | json | error != "" [$__interval])))
to display the 10 most common errors your users see using thegdev-prometheus
data source.
- In Explore, you can use the query