docs/sources/operations/meta-monitoring/mixins.md
Loki is instrumented to expose metrics about itself via the /metrics endpoint, designed to be scraped by Prometheus. Each Loki release includes a mixin. The Loki mixin provides a set of Grafana dashboards, Prometheus recording rules and alerts for monitoring Loki.
To set up monitoring using the mixin, you need to:
This procedure assumes that you have set up Loki using the Helm chart.
{{< admonition type="note" >}} Be sure to update the commands and configuration to match your own deployment. {{< /admonition >}}
After Loki metrics are scraped by the Kubernetes Monitoring Helm chart and stored in a Prometheus compatible time-series database, you can monitor Loki’s operation using the Loki mixin.
Each Loki release includes a mixin that includes:
To install the mixins in Grafana and Mimir, the general steps are as follows:
Download the mixin dashboards from the Loki repository.
Import the dashboards in your Grafana instance.
Upload alerts.yaml and rules.yaml files to Prometheus or Mimir with mimirtool.
loki-mixin dashboardsFirst, clone the Loki repository from Github:
git clone https://github.com/grafana/loki
cd loki
Once you have a local copy of the repository, navigate to the production/loki-mixin-compiled directory.
cd production/loki-mixin-compiled
This directory contains a compiled version of the alert and recording rules, as well as the dashboards.
{{< admonition type="note" >}}
If you want to change any of the mixins, make your updates in the production/loki-mixin directory.
Use the instructions in the README in that directory to regenerate the files.
{{< /admonition >}}
The dashboards directory includes the monitoring dashboards that can be installed into your Grafana instance.
Refer to Import a dashboard in the Grafana documentation.
{{< admonition type="tip" >}} Install all dashboards. You can only import one dashboard at a time. Create a new folder in the Dashboards area, for example “Loki Monitoring”, as an easy location to save the imported dashboards. {{< /admonition >}}
To create a folder:
To import a dashboard:
production/loki-mixin-compiled/dashboards and select the dashboard to import. Or, drag the dashboard file, for example, loki-operational.json, onto the Upload area of the Import dashboard screen.The imported files are listed in the Loki Monitoring dashboard folder.
To view the dashboards in Grafana:
The rules and alerts need to be installed into a Prometheus instance, Mimir or a Grafana Enterprise Metrics cluster.
You can find the YAML files for alerts and rules in the following directories in the Loki repo:
For microservices mode:
production/loki-mixin-compiled/alerts.yaml (Optional)production/loki-mixin-compiled/rules.yaml (Required)You use mimirtool to load the mixin alerts and rules definitions into a Prometheus instance, Mimir, or a Grafana Enterprise Metrics cluster. The following examples show how to load the mixin alerts and rules into a Grafana Cloud instance.
Download mimirtool.
Export the authentication credentials for connecting to your Grafana Cloud Mimir instance.
export MIMIR_ADDRESS=<CLOUD-MIMIR-URL>
export MIMIR_API_USER=<CLOUD-MIMIR-USER>
export MIMIR_API_KEY=<CLOUD-MIMIR-API-KEY>
export MIMIR_TENANT_ID=<CLOUD-MIMIR-USER> # Same as MIMIR_API_USER when using Grafana Cloud
The best place to locate these credentials is to:
URL and user for Prometheus
Using the same terminal we exported the Mimir environment variables into earlier, run the following command to load the recording rules:
mimirtool rules load rules.yaml
(Optional) Load the alert rules:
mimirtool rules load alerts.yaml
Refer to the mimirtool documentation for more information.
After you have installed the Loki mixin dashboards, alerts, and recording rules, you can now monitor your production Loki cluster using Grafana. Make sure you review the mixins when you upgrade Loki to make sure you are using the latest version of the mixin.
You can now move onto: