VK Cloud logo

Monitoring load balancers with Prometheus

For VK Cloud load balancers, you can configure monitoring — collecting and exporting OpenStack Octavia metrics using Prometheus and visualizing these metrics on dashboards using Grafana.

The following will show how to set up load balancer monitoring using the Grafana and Prometheus services deployed on a VM with a Linux OS. If your infrastructure already has a Grafana and Prometheus environment configured, skip the steps related to deploying and configuring it.

Preparatory steps

  1. Install the OpenStack client with the octavia and neutron packages and authenticate in the project.

  2. Deploy the Grafana service from the application marketplace. If you are configuring monitoring for a load balancer in a private network, the VM on which the service is deployed must be in the same subnet as this load balancer. Services from the application marketplace already contain basic settings for operating in VK Cloud. For more information about the available settings, see the official Grafana documentation.

  3. Connect to the VM where the Grafana service is installed and install Prometheus on it:

    sudo apt updatewget https://github.com/prometheus/prometheus/releases/download/v2.45.1/prometheus-2.45.1.linux-amd64.tar.gztar xvf prometheus-2.45.1.linux-amd64.tar.gzcd prometheus-2.45.1.linux-amd64

1. Get information about the load balancer

  1. Go to the VK Cloud management console.

  2. Select a project.

  3. Go to the Virtual networks → Load balancers section.

    A list of load balancers will be displayed.

  4. Click the name of the desired load balancer.

  5. In the IP addresses block, find and write down the load balancer IP addresses.

  6. In the Load balancer information block, find and write down the load balancer ID.

2. Create a Prometheus Listener

Run the command:

openstack loadbalancer listener create \    --name prometheus-listener \     --protocol PROMETHEUS \     --protocol-port 9100 \    <LOAD_BALANCER_ID>

3. Perform the integration with Prometheus

  1. Connect to the VM where Prometheus is installed.

  2. Open the Prometheus configuration file:

    nano /etc/prometheus/prometheus.yml
  3. Find the scrape_configs block and add the following setting to it:

    - job_name: 'Octavia'    static_configs:      - targets: ['<LOAD_BALANCER_IP_ADDRESS>:9100']

    Here <LOAD_BALANCER_IP_ADDRESS> is the internal or external IP address of the load balancer. Use the external IP address if the Grafana and Prometheus server is not in the same private subnet as the load balancer.

  4. Start Prometheus:

    sudo apt install screenscreen -dm ./prometheus --config.file=./prometheus.yml --web.listen-address=localhost:9090

    If the configuration was performed on a running Prometheus, restart it:

    systemctl restart prometheus

4. Add the Octavia dashboard to Grafana

  1. Log in to Grafana.
  2. Add the Prometheus data source to Grafana, if this has not been done before:
    1. Go to the Configuration → Data sources section.
    2. Click Add data source.
    3. Select the data source type: Prometheus.
    4. In the URL field, enter http://localhost:9090.
    5. Click Save & test.
  3. Add the ready-made dashboard for Octavia metrics:
    1. Go to the Dashboards section.
    2. Click the NEW button and select Import in the menu.
    3. In the Import via grafana.com field, enter the ID: 15828.
    4. Click the Load button.
  4. In the Prometheus field, select the previously created Prometheus data source.
  5. Click the Import button.
  6. Make sure the dashboard has been created:
    1. Go to the Dashboards → Browse section.
    2. Open the OpenStack Octavia Amphora Load Balancer dashboard page.

Delete unused resources

A running VM with Grafana and Prometheus consumes computing resources. If you no longer need it, delete it.

Was this article helpful?