VK Cloud logo
Updated at December 18, 2023   03:36 PM

Monitoring Redis with Prometheus, Node exporter and Grafana

Prometheus is a server designed to collect and store metrics received from processes (exporters). The accumulated data can be viewed both through the Prometheus web interface and through separate visualization tools, for example, Grafana.

This instruction will help:

  • deploy Prometheus 2.45.1 server in CentOS 8.4 operating system in VK Cloud;
  • install the Node exporter extension in the Redis 5 Single configuration DBMS;
  • customize the visualization of data from Redis in Prometheus and Grafana 10.

Prometheus server, DBMS and Grafana will be deployed on separate VMs.

Preparatory steps

  1. Create a virtual network, for example, monitoring-net.

  2. Create VM for Prometheus server:

    • name: Centos_8_5_Prometheus;
    • operating system: CentOS 8.4;
    • network: monitoring-net;
    • public IP address: assign it, as an example is given 87.239.239.239;
    • security groups: default, all.

    The internal IP address of the created instance: 10.0.3.7.

  3. Create a DB instance:

    • name: Redis-5;
    • DBMS: Redis 5;
    • configuration type: Single;
    • network: monitoring-net;

    The internal IP address of the created instance: 10.0.3.13.

  4. Deploy Grafana 10 is on the monitoring-net network.

2. Install and configure Prometheus

  1. Install the Node exporter extension for the Redis-5 DB instance. When installing, specify the parameter listen_port = 9100.

  2. Connect to the Centos_8_5_Prometheus VM.

  3. Download Prometheus and unzip the downloaded archive:

    sudo suexport VERSION="2.45.1"wget https://github.com/prometheus/prometheus/releases/download/v$VERSION/prometheus-$VERSION.linux-amd64.tar.gz -O - | tar -xzv -C /tmp
  4. Copy the contents of the repository prometheus-2.45.1.linux-amd64:

    mkdir /etc/prometheusmkdir /var/lib/prometheuscp /tmp/prometheus-$VERSION.linux-amd64/prometheus /usr/local/bincp /tmp/prometheus-$VERSION.linux-amd64/promtool /usr/local/bincp -r /tmp/prometheus-$VERSION.linux-amd64/consoles /etc/prometheuscp -r /tmp/prometheus-$VERSION.linux-amd64/console_libraries /etc/prometheuscp /tmp/prometheus-$VERSION.linux-amd64/prometheus.yml /etc/prometheus/
  5. (Optional) Delete files from the temporary folder:

    rm -rf /tmp/prometheus-$VERSION.linux-amd64
  6. Create a group and a user prometheus, assign him rights to the associated repositories:

    groupadd --system prometheususeradd --system -g prometheus -s /bin/false prometheuschown -R prometheus:prometheus /var/lib/prometheus /etc/prometheuschown prometheus:prometheus /usr/local/bin/prometheus /usr/local/bin/promtool
  7. In the file /etc/prometheus/prometheus.yml add content to the scrape_configs block:

    - job_name: "node"  scrape_interval: 10s  static_configs:    - targets: ["10.0.3.13:9100"]
  8. Create a Prometheus startup script /etc/systemd/system/prometheus.service with the contents:

    [Unit]Description=PrometheusWants=network-online.targetAfter=network-online.target[Service]User=prometheusGroup=prometheusExecStart=/usr/local/bin/prometheus \    --config.file /etc/prometheus/prometheus.yml \    --storage.tsdb.path /var/lib/prometheus \    --web.console.templates=/etc/prometheus/consoles \    --web.console.libraries=/etc/prometheus/console_librariesExecReload=/bin/kill -HUP $MAINPID[Install]WantedBy=default.target
  9. Run Prometheus:

    systemctl daemon-reloadsystemctl start prometheus.servicesystemctl enable prometheus.service
  10. Make sure that Prometheus is working correctly:

    systemctl status prometheus.service

    The output of the command must contain the active status.

  11. Wait a few minutes for the data to accumulate.

  12. Go to the address http://87.239.239.239:9090.

    The Prometheus server web interface opens.

  13. (Optional) Review the available data:

  14. (Optional) Unbind floating address from VM Centos_8_5_Prometheus.

3. Set up data visualization in Grafana

  1. Go to the Grafana web interface.
  2. Add new data source: to Prometheus server URL specify http://10.0.3.7:9090.
  3. Install sets of graphs for visualizing the received data, for example, by importing a ready-made version — Node Exporter Full.

4. (Optional) Check the monitoring data after the test load

  1. Create a test load on the Redis-5 VM in a way that is convenient for you.

  2. Make sure to change the indicators of the Grafana charts.

Delete unused resources

The created resources are charged and quotas are spent. If you don't need them anymore:

  1. Delete deployed virtual machines.
  2. Delete a virtual machine with Grafana.
  3. Remove the floating IP address assigned to the Centos_8_5_Prometheus VM.
  4. Delete the port to which the virtual IP address is assigned.
  5. Delete a monitoring-net network.