+++ title = "Using Loki in Grafana" description = "Guide for using Loki in Grafana" keywords = ["grafana", "loki", "logging", "guide"] type = "docs" aliases = ["/datasources/loki"] [menu.docs] name = "Loki" parent = "datasources" weight = 11 +++ # Using Loki in Grafana > BETA: Querying Loki data requires Grafana's Explore section. > Grafana v6.x comes with Explore enabled by default. > In Grafana v5.3.x and v5.4.x. you need to enable Explore manually. > Viewing Loki data in dashboard panels is not supported yet, but is being worked on. Grafana ships with built-in support for Loki, Grafana's log aggregation system. Just add it as a datasource and you are ready to query your log data in [Explore](/features/explore). ## Adding the data source to Grafana 1. Open Grafana and make sure you are logged in. 2. In the side menu under the `Configuration` link you should find a link named `Data Sources`. 3. Click the `Add data source` button at the top. 4. Select `Loki` from the list of data sources. > NOTE: If you're not seeing the `Data Sources` link in your side menu it means that your current user does not have the `Admin` role for the current organization. | Name | Description | | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | | _Name_ | The datasource name. This is how you refer to the datasource in panels, queries, and Explore. | | _Default_ | Default datasource means that it will be pre-selected for new panels. | | _URL_ | The URL of the Loki instance, e.g., `http://localhost:3100` | | _Maximum lines_ | Upper limit for number of log lines returned by Loki (default is 1000). Decrease if your browser is sluggish when displaying logs in Explore. | ## Querying Logs Querying and displaying log data from Loki is available via [Explore](/features/explore). Select the Loki data source, and then enter a log query to display your logs. > Viewing Loki data in dashboard panels is not supported yet, but is being worked on. ### Log Queries A log query consists of two parts: **log stream selector**, and a **search expression**. For performance reasons you need to start by choosing a log stream by selecting a log label. The Logs Explorer (the `Log labels` button) next to the query field shows a list of labels of available log streams. An alternative way to write a query is to use the query field's autocomplete - you start by typing a left curly brace `{` and the autocomplete menu will suggest a list of labels. Press the `enter` key to execute the query. Once the result is returned, the log panel shows a list of log rows and a bar chart where the x-axis shows the time and the y-axis shows the frequency/count.