side menu

Install Prometheus Adapter

Prometheus Adapter is a component that connects metrics collected by the Prometheus service to the Kubernetes Horizontal Pod Autoscaler (HPA).

 

Prometheus Adapter provides access to user-defined and external metrics via the Kubernetes API. This allows you to automatically scale applications based on any Prometheus metrics: requests per second, accumulated messages in the RabbitMQ queue, response latency, and other user-defined indicators.

 

Installing the Prometheus Adapter is not required if you are using:

 

 

This article will cover how to install and configure Prometheus Adapter in a cluster.

 

Before starting the installation, make sure you have monitoring tools and database monitoring (RabbitMQ) installed.

 

To install the add-on, follow these steps:

 

  1. Download the Helm chart and configuration file.
  2. Fill out the configuration file.
  3. Install the add-on using Helm in a Kubernetes cluster.
  4. Configure BRIX to work with Prometheus Adapter.

 

Important: If you are using Prometheus Adapter together with Prometheus Operator, configure them to use the same Prometheus data source to collect application metrics.

 

 

Step 1: Download the Helm chart and configuration file

 

To install via the Internet, obtain the values-prometheus-adapter.yaml configuration file by running the command:

helm repo add brix365 https://charts.brix365.com
helm repo update
helm show values brix365/prometheus-adapter > values-prometheus-adapter.yaml

Obtaining the configuration file for installation in an isolated enviroment without internet access

 

Step 2: Fill out the configuration file

Fill out the values-prometheus-adapter.yaml configuration file to install Prometheus Adapter.

 

Important: Check the url: http://monitoring-kube-prometheus-prometheus.monitoring.svc parameter. It should point to your Prometheus service.

 

Sample configuration file for installing Prometheus Adapter

 

Filling in the connection parameters to a private registry for installation in an isolated enviroment without internet access

 

Step 3: Install the prometheus-adapter chart using Helm in the Kubernetes cluster

Install the prometheus-adapter chart in the monitoring namespace:

 

  • For online installation use the command:

helm upgrade --install -n monitoring prometheus-adapter brix365/prometheus-adapter -f values-prometheus-adapter.yaml

  • To install without internet access, go to the repository with the downloaded chart and run the command:

helm upgrade --install prometheus-adapter ./prometheus-adapter -f values-prometheus-adapter.yaml -n monitoring

 

Step 4: Configure BRIX to work with Prometheus Adapter

 

Prometheus Adapter enables the HPA mechanism to automatically scale BRIX application pods based on the load on the RabbitMQ message queue.

 

To use RabbitMQ metrics for HPA, enable the following parameters in the global configuration of the BRIX application. To do this, edit the values-brix365.yaml file used during installation.

Начало внимание

Before editing the values-brix365.yaml file, create a backup copy as incorrectly configured parameters may cause the BRIX application to malfunction.

Конец внимание

 

Configure the following parameters:

 

brix365:
  global:
    monitoring:
      externalRmqMetrics: true       # Enable RabbitMQ Metrics for HPA 
      rmqExporterVhost: "brix365"    # Specify a vhost for the HPA metrics exporter (by default: "brix365")
    autoscaling:
      rabbitmqQueueLength: 500       # Maximum number of messages in the RabbitMQ queue for autoscaling

For more information about all the parameters in the values-brix365.yaml configuration file and how to work with them, see Modify BRIX Enterprise parameters.

 

Configure the Deckhouse ServiceMetric resource for BRIX autoscaling

 

If you are using Deckhouse with the built-in monitoring module, you can use RabbitMQ queue metrics for pod autoscaling in BRIX. These metrics are collected using the Deckhouse ServiceMetric resource. The HPA will use these metrics to make scaling decisions.

 

To create the ServiceMetric resource:

 

  1. Save the manifest to a file, such as rabbitmq-metrics.yaml:

apiVersion: deckhouse.io/v1beta1
kind: ServiceMetric
metadata:
  name: rabbitmq-queue-messages
spec:
  query: |
    sum(rabbitmq_queue_messages{<<.LabelMatchers>>, queue!=""}) by (queue)
---
apiVersion: deckhouse.io/v1beta1
kind: ServiceMetric
metadata:
  name: rabbitmq-queue-messages-postman
spec:
  query: |
    sum(rabbitmq_queue_messages{<<.LabelMatchers>>, queue="_postman._new_messages"}) by (queue)

 

  1. Apply the manifest with the command:

kubectl apply -f rabbitmq-metrics.yaml