﻿# Monitoring of databases

> [HTML Version](monitoring-databases.html)

DBSExporter is an add-on designed for monitoring PostgreSQL, MongoDB, RabbitMQ, Redis, and S3 storage databases.

The installation of the add-on consists of the following steps:

1. [Download the Helm chart and configuration file](#download-helm-chart-and-config-file).

2. [Create a configuration token to use MinIO metrics for Prometheus](#create-configuration-token).

3. [Fill in the configuration file](#filling-out-configuration-file).

4. [Install Node Exporter on the database servers](#node-exporter).

5. [Install the DBSExporter chart using Helm in the Kubernetes cluster](#install-chart-dbsexporter).

## Step 1: Download the Helm chart and configuration file

To install via the internet, obtain the \[OBJECT\] configuration file by executing the following command:

````
helm repo add brix365 https://charts.brix365.com  
helm repo update  
helm show values brix365/dbsexporter > values-dbsexporter.yaml

````
For offline installation without internet access

1. On a computer with internet access, download the archive of the latest version of the DBSExporter chart from the BRIX repository using the command:

````
helm repo add brix365 https://charts.brix365.com  
helm repo update  
helm pull brix365/dbsexporter````
 

2. Copy the obtained chart archive \[OBJECT\] to the server where the installation will take place.

3. Unpack the chart, and copy the default configuration file \[OBJECT\] to \[OBJECT\].

````
tar -xf dbsexporter-X.Y.Z.tgz  
cp dbsexporter/values.yaml values-dbsexporter.yaml
````

## ````
Step 2: Create a configuration token to use MinIO metrics for Prometheus

Create \[OBJECT\] and send the command to generate a token by executing the following:

````
mc alias set my\_alias http://minio.local accessKey secretKey  
mc admin prometheus generate my\_alias

## ````
Step 3: Fill in the configuration file

Fill in the configuration file to install DBSExporter

  
Use the generated token when configuring the MinIO connection in the \[OBJECT\] file.

````
  
dbsexporter:  
  # Enable chart imports  
  grafana-dashboards:  
    dashboards:  
      enabled: true  
      grafanaFolder: dbs  
  # MinIO connection settings  
  prometheus-minio-exporter:  
    nameOverride: minio  
    instances:  
    - name: minio-job  
      token: generated\_token  
      path: /minio/v2/metrics/cluster  
      host: 'minio.local'  
      port: 80  
      scheme: http  
  # MongoDB connection settings  
  prometheus-mongodb-exporter:  
    nameOverride: mongo  
    instances:  
    - name: mongodb  
      uri: "mongodb://mongodb:27017"  
  # Postgres connection settings  
  prometheus-postgres-exporter:  
    nameOverride: postgres  
    config:  
      instances:  
      - name: postgres  
        # Specify  a data source amd a data source secret.  
        host: 'example.ru'  
        user: postgres  
        userSecret: \{\}  
          #  Secret name  
          # name:  
          #  User key inside the secret  
          # key:  
        password: postgres\_password  
        # Specify passwordFile if the database password is stored in a file.  
        passwordFile: ''  
        # Specify passwordSecret if the database password is stored in a secret.  
        passwordSecret: \{\}  
          #  Secret name  
          # name:  
          #  Password key inside the secret  
          # key:  
        pgpassfile: ''  
        # If pgpassfile is set, it is used to initialize the environment variable PGPASSFILE.  
        port: "5432"  
        database: ''  
        sslmode: disable  
        extraParams: ''  
\# rabbitMQ connection settings  
  prometheus-rabbitmq-exporter:  
    nameOverride: rabbitmq  
    rabbitmq:  
      instances:  
      - name: rabbitmq  
        url: 'http://rabbitmq:15672'  
        user: rabbitmq\_user  
        password: rabbitmq\_password  
        # The specified password will be placed in Secret:  
        existingPasswordSecret: rabbitmq-secret  
        existingPasswordSecretKey: password  
        capabilities: bert,no\_sort  
        include\_queues: ".\*"  
        include\_vhost: ".\*"  
        skip\_queues: "^\$"  
        skip\_verify: "false"  
        skip\_vhost: "^\$"  
        exporters: "exchange,node,overview,queue"  
        output\_format: "TTY"  
        timeout: 60  
        max\_queues: 0  
        excludeMetrics: ""  
        # Allows overriding environment variables using an external ConfigMap.  
        configMapOverrideReference: ""  
\# Redis connection setting  
  prometheus-redis-exporter:  
    nameOverride: redis  
    instances:  
    - name: redis1  
      redisAddress: 'redis://redis:6379/0'
````

````
Configuring connection parameters to a private registry for installation in a closed environment without internet access

  
To connect to the private registry:

1. Download BRIX images and upload them to a local image registry. Refer to [Download BRIX images](downloadin-images-elma365.md) for more details.

2. Specify the address and path for the parameter \[OBJECT\].

3. Provide the name of the secret with access rights to the private registry in the parameter \[OBJECT\]. The secret must be manually created and encrypted in Base64.

````
prometheus-minio-exporter:  
\# Connection parameters to the private registry  
    image:  
\# Address and path for the private registry  
      repository: registry.example.com/minio\_exporter  
\#      tag: "1.0.15"  
    imagePullSecrets:  
      - myRegistryKeySecretName  
prometheus-mongodb-exporter:  
\# Connection parameters to the private registry  
    image:  
\# Address and path for the private registry  
      repository: registry.example.com/mongodb\_exporter  
\#      tag: "0.31.0"  
    imagePullSecrets:  
      - myRegistryKeySecretName  
prometheus-postgres-exporter:  
\# Connection parameters to the private registry  
    image:  
\# Address and path for the private registry  
      repository: registry.example.com/postgres-exporter  
\#      tag: "v0.13.2"  
    imagePullSecrets:  
      - myRegistryKeySecretName  
\# rabbitMQ connection settings  
prometheus-rabbitmq-exporter:  
\# Connection parameters to the private registry  
    image:  
\# Address and path for the private registry  
      repository: registry.example.com/rabbitmq-exporter  
\#      tag: "v0.29.0"  
    imagePullSecrets:  
      - myRegistryKeySecretName  
prometheus-redis-exporter:  
\# Connection parameters to the private registry  
\#    image:  
\# Address and path for the private registry  
      repository: registry.example.com/redis\_exporter  
\#      tag: "v1.44.0"  
    imagePullSecrets:  
      - myRegistryKeySecretName````
 

Where **repository **format is: address — \[OBJECT\].

You can add the following additional settings in the \[OBJECT\] configuration file:

1. Connect several databases both internal and external to DBSExporter. To do this, duplicate the parameters of the \[OBJECT\] block and configure the connection parameters for each replica. For example:

````
instances:      
  - name: mongodb-1  
    uri: "mongodb://mongodb-1:27017"  
  - name: mongodb-2  
    uri: "mongodb://mongodb-2:27017"

2. ````
Enable Yandex Cloud metrics collection.

Collection of Yandex Cloud metrics is a chargeable service. Read more in the [official documentation of the service](https://yandex.cloud/en/docs/monitoring/pricing?utm_referrer=about%3Ablank).

Example of how to enable Yandex Cloud metrics collection:

````
global:  
\# Export yandex metrics  
  yandexExporter:  
    enabled: true  
    bearerToken: "your\_bearerToken"  
    folderId: "your\_folderId"  
    services: \["managed-mongodb", "managed-postgresql"\]  
    relabelings: \{\}

3. ````
Connect Deckhouse with DBSExporter. For example:

````
global:      
provisioner: "deckhouse"

## ````
Step 4: Install Node Exporter on the database servers

To monitor database servers, install Node Exporter. For this:

1. Download Node Exporter on the database server:

````
wget https://github.com/prometheus/node\_exporter/releases/download/v1.8.2/node\_exporter-1.8.2.linux-amd64.tar.gz

2. ````
Unpack the archive downloaded on the previous step:

````
tar xvf node\_exporter-1.8.2.linux-amd64.tar.gz \&\& cd node\_exporter-1.8.2.linux-amd64

3. ````
Copy the \[OBJECT\] file:

````
sudo cp node\_exporter /usr/local/bin/

4. ````
Create a user for Node Exporter:

````
sudo useradd --no-create-home --shell /bin/false nodeusr

5. ````
Define the owner for the \[OBJECT\] executable file:

````
sudo chown -R nodeusr:nodeusr /usr/local/bin/node\_exporter;

6. ````
Create the \[OBJECT\] file to launch Node Exporter as a service:

````
cat <<EOF | sudo tee /etc/systemd/system/node\_exporter.service;  
\[Unit\]  
Description=NodeExporter  
\[Service\]  
TimeoutStartSec=0  
User=nodeusr  
ExecStart=/usr/local/bin/node\_exporter \\  
\--web.listen-address=:9100  
\[Install\]  
WantedBy=multi-user.target  
EOF

7. ````
Reload \[OBJECT\] configuration: 

````
sudo systemctl daemon-reload

8. ````
Launch the \[OBJECT\] service:

````
sudo systemctl enable --now node\_exporter.service

````
After installing Node Exporter, fill in the parameters in the \[OBJECT\] configuration file to monitor the database servers. In this case, host addresses will be extracted from the \[OBJECT\] points of the configuration file. Example of how to set the parameters:

````
\# Settings of node exporter  
  nodeExporter:  
    enabled: true  
    port: 9100  
    relabelings: \{\}

## ````
Step 5: Install the DBSExporter chart using Helm in the Kubernetes cluster

Execute the installation of the DBSExporter chart in \[OBJECT\].

For online installation:

````
helm upgrade --install -n monitoring dbsexporter brix365/dbsexporter -f values-dbsexporter.yaml

````
For offline installation without internet access, navigate to the directory with the downloaded chart and execute the command:

````
helm upgrade --install dbsexporter ./dbsexporter -f values-dbsexporter.yaml -n monitoring
````