> ## Documentation Index
> Fetch the complete documentation index at: https://gcore.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Monitoring for load balancers

export const Caution = ({children}) => {
  return <div class="my-4 px-5 py-4 overflow-hidden rounded-2xl flex gap-3 border danger-admonition dark:danger-admonition">
      <div class="mt-0.5 w-4">
        <svg width="14" height="14" viewBox="0 0 14 14" fill="rgb(239, 68, 68)" xmlns="http://www.w3.org/2000/svg" class="w-4 h-4 text-sky-500" aria-label="Danger">
          <path fill-rule="evenodd" clip-rule="evenodd" d="M7 1.3C10.14 1.3 12.7 3.86 12.7 7C12.7 10.14 10.14 12.7 7 12.7C5.48908 12.6974 4.0408 12.096 2.97241 11.0276C1.90403 9.9592 1.30264 8.51092 1.3 7C1.3 3.86 3.86 1.3 7 1.3ZM7 0C3.14 0 0 3.14 0 7C0 10.86 3.14 14 7 14C10.86 14 14 10.86 14 7C14 3.14 10.86 0 7 0ZM8 3H6V8H8V3ZM8 9H6V11H8V9Z"></path>
        </svg>
      </div>
      <div class="text-sm prose min-w-0">
        {children}
      </div>
    </div>;
};

Gcore collects and stores metrics and logs from various cloud resources, including load balancers. This guide explains the different monitoring features and how to configure them for an existing load balancer.

## Prometheus listener

Load balancers use listeners to associate a port with a pool of instances. In addition to the regular balancing listeners, you can create one that exposes an endpoint with the balancer's metrics. This enables you to scrape them with Prometheus and view them with Grafana.

<Tip>
  Tip: Import [this pre-made Grafana dashboard](https://grafana.com/grafana/dashboards/15828-openstack-octavia-amphora-load-balancer/) to display your metrics.
</Tip>

### Enable Prometheus listener

You can enable the Prometheus listener from the Customer Portal by following these steps:

<Steps>
  <Step title="Open the listener settings">
    To enable the metrics endpoint, open the **Gcore Customer Portal**, navigate to **Cloud** > **Networking** > **Load Balancers**, and click the name of a load balancer in the list.

    <img src="https://mintcdn.com/gcore/PmEtx6iz1ctErdKn/images/docs/cloud/networking/load-balancers/manage-load-balancers/load-balancers-page.png?fit=max&auto=format&n=PmEtx6iz1ctErdKn&q=85&s=a041ae34e83bddd1dea085ffbe8d7641" alt="Load balancers list" style={{ width:"62%" }} width="5652" height="2612" data-path="images/docs/cloud/networking/load-balancers/manage-load-balancers/load-balancers-page.png" />

    This will take you to the **Load Balancer Details** page.
  </Step>

  <Step title="Initialize the listener creation">
    Select the **Listeners** tab, scroll down until you see the **Add Listener** button, and click it.

    <img src="https://mintcdn.com/gcore/PmEtx6iz1ctErdKn/images/docs/cloud/networking/load-balancers/manage-load-balancers/listeners-tab.png?fit=max&auto=format&n=PmEtx6iz1ctErdKn&q=85&s=505defb79d5fa8690b216abceff99e34" alt="Load balancers details dialog with Listeners tab" style={{ width:"36%" }} width="4096" height="1208" data-path="images/docs/cloud/networking/load-balancers/manage-load-balancers/listeners-tab.png" />

    This will open the **Add Listener** dialog.
  </Step>

  <Step title="Configure the listener">
    Enter a **Name** for your listener, set a **Port** and a **Connection limit**, and for the **Protocol** select **Prometheus**.

    Just like with regular listeners, you have the following options to secure your Prometheus listener:

    * Define an allowed IP range with CIDRs.
    * Define a list of users who get access through Basic Auth.
    * Enable SSL/TLS by [<u>adding certificates</u>](/cloud/networking/load-balancers/add-certificates-to-load-balancer).
    * Enable mTLS [<u>via the Gcore Cloud API</u>](/cloud/networking/load-balancers/configure-mtls-authentication).
  </Step>

  <Step title="Finalize the listener">
    Click the **Create Listener** button and wait until the Prometheus listener appears in the list.

    You can now add the listener as a target to a Prometheus instance by adding the following lines to its prometheus.yml under the scrape\_configs section:

    ```yaml theme={null}
    - job_name: <LOAD_BALANCER_NAME>
        metrics_path: /metrics
        static_configs:
        - targets:
          - <LOAD_BALANCER_IP>:<PROMETHEUS_LISTENER_PORT>
    ```
  </Step>
</Steps>

### Disable Prometheus listener

<Info>
  Before you delete a Prometheus listener, you should delete the corresponding job from all *prometheus.yml* files.
</Info>

You can disable the Prometheus listener in the **Customer Portal** by following these steps:

<Steps>
  <Step title="Open the load balancer settings">
    Open the **Gcore Customer Portal**, navigate to **Cloud** > **Networking** > **Load Balancers**, and click a load balancer's name in the list.

    <img src="https://mintcdn.com/gcore/PmEtx6iz1ctErdKn/images/docs/cloud/networking/load-balancers/manage-load-balancers/load-balancers-page.png?fit=max&auto=format&n=PmEtx6iz1ctErdKn&q=85&s=a041ae34e83bddd1dea085ffbe8d7641" alt="Load balancers list" style={{ width:"58%" }} width="5652" height="2612" data-path="images/docs/cloud/networking/load-balancers/manage-load-balancers/load-balancers-page.png" />
  </Step>

  <Step title="Delete the listener">
    Select the **Listeners** tab, scroll down until you see the Prometheus listener, click on its corresponding action menu on the right, and click **Delete**.
  </Step>
</Steps>

## Logging as a service

Gcore offers Managed Logging, also known as logging as a service (LaaS) for all cloud resources.

<Info>
  When you enable logging on a load balancer, LaaS will store the logs in the same region as the load balancer.
</Info>

### Enable logging

You can enable logging via the **Customer Portal** by following these steps:

<Steps>
  <Step title="Open the load balancer settings">
    To enable the logging, open the **Gcore Customer Portal**, navigate to **Cloud** > **Networking** > **Load Balancers**, and click the name of a load balancer in the list.

    <img src="https://mintcdn.com/gcore/PmEtx6iz1ctErdKn/images/docs/cloud/networking/load-balancers/manage-load-balancers/load-balancers-page.png?fit=max&auto=format&n=PmEtx6iz1ctErdKn&q=85&s=a041ae34e83bddd1dea085ffbe8d7641" alt="Load balancers list" style={{ width:"63%" }} width="5652" height="2612" data-path="images/docs/cloud/networking/load-balancers/manage-load-balancers/load-balancers-page.png" />
  </Step>

  <Step title="Initialize logging">
    Select the **Logging** tab, and activate the **Enable Logging** toggle.

    You can either use an existing log **Topic** or create a new one, allowing you to define a **Retention** period.

    <img src="https://mintcdn.com/gcore/YEsPf7l6EvNuxMEL/images/docs/cloud/networking/load-balancers/logging-for-load-balancers/logging-load-balancer-20.png?fit=max&auto=format&n=YEsPf7l6EvNuxMEL&q=85&s=e3da568b6a4923da3f4ed4caa0f65439" alt="Load balancer logging tab with Enable Logging toggle" style={{ width:"73%" }} width="1999" height="1024" data-path="images/docs/cloud/networking/load-balancers/logging-for-load-balancers/logging-load-balancer-20.png" />
  </Step>

  <Step title="Finalize logging">
    Click the **Save changes** button, and Gcore’s LaaS will set up the logging for the load balancer.
  </Step>
</Steps>

### View the logs

You can now view your logs in the **Customer Portal** or [<u>your own Grafana instance</u>](/cloud/logging-as-a-service/view-opensearch-logs-in-Grafana). To view the logs in the **Customer Portal**, follow these steps:

<Steps>
  <Step title="Open Managed Logging">
    Open the **Gcore Customer Portal** and navigate to **Cloud** > **Managed Logging**.

    <img src="https://mintcdn.com/gcore/YEsPf7l6EvNuxMEL/images/docs/cloud/networking/load-balancers/logging-for-load-balancers/logging-namespace.png?fit=max&auto=format&n=YEsPf7l6EvNuxMEL&q=85&s=d518ae2613436e16165b7e7805f6b3ce" alt="Managed logging settings" style={{ width:"36%" }} width="1999" height="1910" data-path="images/docs/cloud/networking/load-balancers/logging-for-load-balancers/logging-namespace.png" />
  </Step>

  <Step title="Open OpenSearch dashboard">
    Select a log topic from the list and click the corresponding **View Logs** link.
  </Step>
</Steps>

### Disable logging

You can disable logging via the **Customer Portal** by following these steps:

<Steps>
  <Step title="Open the load balancer settings">
    Open the **Gcore Customer Portal**, navigate to **Cloud** > **Networking** > **Load Balancers**, and click a load balancer's name in the list.

    <img src="https://mintcdn.com/gcore/PmEtx6iz1ctErdKn/images/docs/cloud/networking/load-balancers/manage-load-balancers/load-balancers-page.png?fit=max&auto=format&n=PmEtx6iz1ctErdKn&q=85&s=a041ae34e83bddd1dea085ffbe8d7641" alt="Load balancers list" style={{ width:"50%" }} width="5652" height="2612" data-path="images/docs/cloud/networking/load-balancers/manage-load-balancers/load-balancers-page.png" />
  </Step>

  <Step title="Deactivate logging">
    Select the **Logging** tab, deactivate the **Enable Logging** toggle, and click the **Save changes** button.

    <img src="https://mintcdn.com/gcore/PmEtx6iz1ctErdKn/images/docs/cloud/networking/load-balancers/manage-load-balancers/logging-tab.png?fit=max&auto=format&n=PmEtx6iz1ctErdKn&q=85&s=214bc4e3369ee8b25cb363e0e388ca6b" alt="Load balancer logging tab" style={{ width:"49%" }} width="4040" height="1632" data-path="images/docs/cloud/networking/load-balancers/manage-load-balancers/logging-tab.png" />
  </Step>
</Steps>

## Cloud API endpoints

You can request status, metrics, and general statistics for your load balancers via the Gcore Cloud API.

### Load balancer status

The status endpoints provide details about a load balancer's operating and provisioning status, its listeners, and their pools.

You can find more information about the endpoints on the following documentation pages.

* [Status of one specific load balancer](/api-reference/cloud/LoadBalancerStatusInstanceViewSet.get)
* [Status of all load balancers](/api-reference/cloud/LoadBalancerStatusViewSet.get)

### Load balancer metrics

The metrics endpoint provides information about CPU, memory, and network utilization.

You can find more information about the endpoints on the following documentation pages.

* [Metrics of one specific load balancer](/api-reference/cloud/LoadbalancerMetricsHandler.post)

### Load balancer and listener statistics

The get endpoints for load balancers and listeners provide data about connections, traffic, and errors when called with `?show_stats=true`.

You can find more information about the endpoints on the following documentation pages.

* [Get one specific load balancer](/api-reference/cloud/LoadBalancerInstanceViewSet.get)
* [Get one listener](/api-reference/cloud/LoadBalancerListenerInstanceViewSet.get)
* [Get all listeners](/api-reference/cloud/LoadBalancerListenerViewSet.get)
