Set up a Grafana dashboard¶
To visualize the metrics and logs data, set up Grafana. LXD provides a Grafana dashboard that is configured to display the LXD metrics scraped by Prometheus and events sent to Loki.
Note
The dashboard requires Grafana 8.4 or later.
See the Grafana documentation for instructions on installing and signing in:
Complete the following steps to import the LXD dashboard:
Configure Prometheus as a data source:
From the Basic (quick setup) panel, choose Data Sources.
Select Prometheus.
In the URL field, enter the address of your Prometheus installation (
http://localhost:9090/
if running Prometheus locally).Keep the default configuration for the other fields and click Save & test.
Configure Loki as another data source:
Select Loki.
In the URL field, enter the address of your Loki installation (
http://localhost:3100/
if running Loki locally).Keep the default configuration for the other fields and click Save & test.
Import the LXD dashboard:
Go back to the Basic (quick setup) panel and now choose Dashboards > Import a dashboard.
In the Find and import dashboards field, enter the dashboard ID
19131
.Click Load.
In the LXD drop-down menu, select the Prometheus and Loki data sources that you configured.
Click Import.
You should now see the LXD dashboard. You can select the project and filter by instances.
At the bottom of the page, you can see data for each instance.
Note
For proper operation of the Loki part of the dashboard, you need to ensure that the instance
field matches the Prometheus job name.
You can change the instance
field through the loki.instance
configuration key.
The Prometheus job_name
value can be found in /var/snap/prometheus/current/prometheus.yml
(if you are using the snap) or /etc/prometheus/prometheus.yaml
(otherwise).
To set the loki.instance
configuration key, run the following command:
lxc config set loki.instance=<job_name_value>
You can check that setting via:
lxc config get loki.instance