Project: Grafana (Observability and Analysis / Observability)
File: export-logs.md

aliases: ../../enterprise/usage-insights/export-logs/ description: Export logs of usage insights keywords: grafana export usage-insights enterprise labels: products: cloud enterprise title: Export logs of usage insights weight: 900 {{% admonition type="note" %}} Available in version 7.4 and later, and . {{% /admonition %}} 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. This configuration is done for you in Grafana Cloud, with provisioned dashboards. Read about them in the . Usage insights logs are JSON objects that represent certain user activities, such as: 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. Logs of usage insights contain the following fields, where the fields followed by \* are always available, and the others depend on the logged event: | Field name | Type | Description | | - | - | -- | | `eventName`\* | string | Type of the event, which can be either `data-request` or `dashboard-view`. | | `folderName`\* | string | Name of the dashboard folder. | | `dashboardName`\* | string | Name of the dashboard where the event happened. | | `dashboardId`\* | number | ID of the dashboard where the event happened. | | `datasourceName`| string | Name of the data source that was queried. | | `datasourceType` | string | Type of the data source that was queried. For example, `prometheus`, `elasticsearch`, or `loki`. | | `datasourceId` | number | ID of the data source that was queried. | | `panelId` | number | ID of the panel of the query. | | `panelName` | string | Name of the panel of the query. | | `error` | string | Error returned by the query. | | `duration` | number | Duration of the query. | | `source` | string | Source of the

For example, `dashboard` or `explore`. | | `orgId`\* | number | ID of the users organization. | | `orgName`\* | string | Name of the users organization. | | `timestamp`\* | string | The date and time that the request was made, in Coordinated Universal Time (UTC) in format. | | `tokenId`\* | number | ID of the users authentication token. | | `username`\* | string | Name of the Grafana user that made the request. | | `userId`\* | number | ID of the Grafana user that made the request. | | `totalQueries`\* | number | Number of queries executed for the data request. | | `cachedQueries`\* | number | Number of fetched queries that came from the cache. | To export your logs, enable the usage insights feature and an export location in the configuration file: ```ini [usage_insights.export] enabled = true storage = loki ``` The options for storage type are `loki` and `logger` (added in Grafana Enterprise 8.2). If the storage type is set to `loki` you'll need to also configure Grafana to export to a Loki ingestion server. To do this, you'll need Loki installed. Refer to for instructions on how to install Loki. ```ini [usage_insights.export.storage.loki] type = grpc url = localhost:9095 tls = true tenant_id = ``` Using `logger` will print usage insights to your . There is no option for configuring the `logger` storage type. If you export logs into Loki, you can build Grafana dashboards to understand your Grafana instance usage. Add Loki as a data source. Refer to . 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 your `gdev-loki` data source. In a dashboard, you can build a table panel with the query `topk(10, sum by (error) (countovertime({kind="usageinsights", datasource="gdev-prometheus"} | json | error != "" [$_interval])))` to display the 10 most common errors your users see using the `gdev-prometheus` data source. In a dashboard, you can build a graph panel with the queries `sum by(host) (countovertime({kind="usage_insights"} | json | eventName="data-request" | error != "" .