Provisioning Grafana and Prometheus

AI Tools

Prometheus gathers statistics from the Lightbits cluster. Grafana in turn represents everything in graphs on dashboards. This monitoring package can monitor several clusters at once, and multiple clusters can be configured.

The following details how to provision a monitoring stack with Prometheus and Grafana. The instructions below are relevant for Lightbits versions 3.4.1 and above.

Note

Ensure that SELinux firewall permissions are permissive before deploying.

Prerequisites

Designate a non-Lightbits server for the Lightbits monitoring solution to be installed. Ensure that the following software is installed on the designated monitoring host.

Hardware specifications:

  • 10 cores

  • 32 GB RAM

  • 128 GB of storage

  • Connectivity to Lightbits' access network (Lightbits exporter service and API service).

Installing Monitoring Packages

To install the monitoring packages, run the following:

sudo yum install lightos-monitoring-images lightos-monitoring-clustering
Note

For Deb-packaged based OSs (for example, Ubuntu), see Connecting to the Cluster Client DEB Repository, and then run: sudo apt-get install lightos-monitoring-images lightos-monitoring-clustering.

Monitoring Stack Deployment

To start running the Prometheus and Grafana containers, run the following (clustering):

/var/lib/monitoring-images/deploy.sh deploy

Configuring Prometheus

Prometheus should be configured with all of the jobs to scrape, and alert and recording rules. The only remaining step in configuring Prometheus is adding all the targets for the Lightbits cluster.

Since this information is deployment-specific, each one should follow the provided example and set the host accordingly.

Note

Each Prometheus instance can monitor multiple clusters at the same time.

To add a cluster to monitor or to update an existing cluster, run the commands in the section below.

Adding Prometheus Targets

The following example illustrates how to generate the configuration for a cluster named cluster_1, which has three servers:

  • rack01-server01

  • rack01-server02

  • rack01-server03

You will then need to configure Prometheus to scrape the services that run on all of the nodes.

The following command generates targets.yaml files that define Prometheus endpoints to scrape. See the <file_sd_config> section of the Prometheus Documentation for additional information.

/var/lib/monitoring-images/deploy.sh add_cluster \ -c cluster1 \ -i rack01-server01,rack01-server02,rack01-server03

This action creates the following files:

/var/lib/monitoring-clustering/file_sd_configs/api-service/cluster1-targets.yaml - labels: job: cluster_1 targets: - rack01-server01:443 - rack01-server02:443 - rack01-server03:443 /var/lib/monitoring-clustering/file_sd_configs/lightbox-exporter/cluster1-targets.yaml - labels: job: cluster_1 targets: - rack01-server01:8090 - rack01-server02:8090 - rack01-server03:8090
Note

Ensure that the yaml configuration files have the minimum permissions, and reset the files permissions in the Prometheus container to be rw-r--r-- and not rw-------.

Since we bind-mounted the /var/lib/monitoring-clustering/file_sd_configs folder to the Prometheus container, this command issues a reload to Prometheus that is configured to collect these endpoints.

Verify that the targets were configured correctly by viewing http://<prometheus_host>:9090/targets.

--high-precision and --dual-instance Flags

The command also includes two optional flags: --high-precision and --dual-instance.

When set, --high-precision writes a per-cluster target file under file_sd_configs/high-precision/, pointing at port 9190, alongside the existing api-service (443) and lightbox-exporter (8090) targets. A static high-precision scrape job (5s interval / 4s timeout) is added to prometheus.yml, reading /targets/high-precision/*.yaml. The job is a no-op when no high-precision clusters are registered.

When --dual-instance is combined with --high-precision, each server produces two high-precision targets, on ports 9190 and 9191, instead of a single 9190 target. The --dual-instance flag is independent of --high-precision, and can be reused for other target types in the future. Currently, it only takes effect within the high-precision target set.

Example:

/var/lib/monitoring-images/deploy.sh add_cluster -c test-cluster -i rack01-server01,rack01-server02,rack01-server03 --high-precision
Note

You will need to select the high precision dashboard in Grafana to view.

In the figure below:

  1. Legacy metrics are scraped at a low rate via lightbox-exporter (port 8090). These are not affected by this design: the scrape path and contents are unchanged.

  2. High precision metrics are scraped directly from each front-end instance (ports 9190 and 9191 in dual-instance configurations).

  3. Prometheus configurations with a set of new scrape targets (one per node) effectively enable the HF metrics.

  4. A new dedicated HF volume performance Grafana dashboard that presents data in real time, and with ~1s resolution.

  5. Installation/upgrade paths enable ports 9190/9191 in firewall/iptables.

  6. No other actions are required to enable HF metrics - via API or otherwise.


Removing Prometheus Targets

The following command will undo the former command:

/var/lib/monitoring-images/deploy.sh remove_cluster -c cluster1

This will delete the following files:

  • /var/lib/monitoring-clustering/file_sd_configs/api-service/cluster1-targets.yaml

  • /var/lib/monitoring-clustering/file_sd_configs/lightbox-exporter/cluster1-targets.yaml

And issue a reload to Prometheus.

You can verify that the configuration works by:

  • Navigating to http://<prometheus_host>:9090/config - making sure that the expected configuration is used.

  • Navigating to http://<prometheus_host>:9090/targets?search= - making sure that the targets configured in the previous step are updated.

Note:

remove_cluster also cleans up the high-precision target file, and deploy pre-creates the directory so that Prometheus watches a real path.

Configuring Grafana

Grafana should be configured automatically with the deployed Prometheus instance as a data source and all the dashboards that Lightbits provides to monitor the cluster.

Cleaning Up Deployed Containers

To run the deployment again or clean the machine from artifacts that this operation applied, run the following command:

/var/lib/monitoring-images/deploy.sh clean

Uninstalling Monitoring Packages

To uninstall monitoring packages, run the following command:

sudo yum remove lightos-monitoring-images lightos-monitoring-clustering
Note

For Deb-packaged based OSs (for example, Ubuntu), run: sudo apt-get remove lightos-monitoring-images lightos-monitoring-clustering

Enabling Persistent Journal log

To aid with troubleshooting and support, Lightbits recommends setting the journal to keep logs even after reboots and shutdowns. To ensure that the OS disk does not fill up, Lightbits also recommends updating the log rotation.

Enable persistent journaling:

sudo sed -i 's/#Storage.*/Storage=persistent/' /etc/systemd/journald.conf

Enable log rotation:

sudo sed -i 's| missingok$| daily\n rotate 30\n compress\n missingok\n notifempty|g' /etc/logrotate.d/syslog