Introduction
Effective monitoring of Redis databases is basal for maintaining optimal performance, identifying imaginable bottlenecks, and ensuring wide strategy reliability. Redis Exporter Service is simply a robust inferior designed to show Redis databases utilizing Prometheus.
This tutorial will guideline you done nan complete setup and configuration of Redis Exporter Service, ensuring you found a monitoring solution seamlessly. By pursuing this tutorial, you’ll execute a afloat operational monitoring setup to efficaciously show nan capacity metrics of your Redis database.
Note: The approximate setup clip for this tutorial is astir 25 minutes
Prerequisites
Before you begin, make judge you person nan pursuing prerequisites successful place:
- You’ll request to person Redis database servers group up and moving connected a Ubuntu Droplet. You tin mention to our tutorials connected How to Install and Secure Redis connected Ubuntu. The servers you want to show should beryllium accessible from nan instrumentality wherever you scheme to instal Redis Exporter Service.
- You’ll request SSH access to Redis servers to instal and configure Redis Exporter Service.
- Prometheus MySQL Exporter integrates pinch Prometheus for metrics scraping and Grafana for visualization. Here we are utilizing Prometheus and Grafana images from DigitalOcean Marketplace to show nan database Droplets.
Note: In this tutorial, we will locomotion done 2 different methods to group up Redis Exporter Service for monitoring Redis databases. You tin take betwixt manual configuration and script-based automation, each tailored to different preferences and operational requirements. Follow nan instructions for each method to deploy Redis Exporter Service connected your infrastructure effectively. This elasticity allows you to prime nan champion deployment strategy and operational workflow approach.
Method 1: Manual Configuration
Let’s proceed pinch nan manual configuration method successful this section.
Create Prometheus System User and Group
Create a strategy personification and group named “prometheus” to negociate nan exporter service.
sudo groupadd --system prometheus sudo useradd -s /sbin/nologin --system -g prometheus prometheusDownload and Install Redis Exporter
Download nan latest merchandise of Redis Exporter from GitHub, extract nan downloaded files, and move nan binary to nan /usr/local/bin/ directory.
curl -s https://api.github.com/repos/oliver006/redis_exporter/releases/latest | grep browser_download_url | grep linux-amd64 | cut -d '"' -f 4 | wget -qi - tar xvf redis_exporter-*.linux-amd64.tar.gz sudo mv redis_exporter-*.linux-amd64/redis_exporter /usr/local/bin/Verify Redis Exporter Installation
redis_exporter --versionHere is nan sample Output:
Configure systemd Service for Redis Exporter
Create a systemd work portion record to negociate nan Redis Exporter service.
sudo vim /etc/systemd/system/redis_exporter.serviceAdd nan pursuing contented to nan file:
redis_exporter.service
[Unit] Description=Prometheus Redis Exporter Documentation=https://github.com/oliver006/redis_exporter Wants=network-online.target After=network-online.target [Service] Type=simple User=prometheus Group=prometheus ExecReload=/bin/kill -HUP $MAINPID ExecStart=/usr/local/bin/redis_exporter \ --log-format=txt \ --namespace=redis \ --web.listen-address=:9121 \ --web.telemetry-path=/metrics SyslogIdentifier=redis_exporter Restart=always [Install] WantedBy=multi-user.targetReload systemd and Start Redis Exporter Service
sudo systemctl daemon-reload sudo systemctl enable redis_exporter sudo systemctl commencement redis_exporterConfiguring nan Prometheus Droplet (Manual Method)
Let’s configure nan Prometheous droplet for nan manual configuration.
Take a backup of nan prometheus.yml file
cp /etc/prometheus/prometheus.yml /etc/prometheus/prometheus.yml-$(date +'%d%b%Y-%H:%M')Add nan Redis Exporter endpoints to beryllium scraped
Log successful to your Prometheus server and adhd nan Redis Exporter endpoints to beryllium scraped.
Replace nan IP addresses and ports pinch your Redis Exporter endpoints (9121 is nan default larboard for Redis Exporter Service).
vi /etc/prometheus/prometheus.ymlprometheus.yml
scrape_configs: - job_name: server1_db static_configs: - targets: ['10.10.1.10:9121'] labels: alias: db1 - job_name: server2_db static_configs: - targets: ['10.10.1.11:9121'] labels:This is nan extremity of nan manual configuration. Now, let’s proceed pinch nan script-based configuration.
Method 2: Configuring Using Scripts
You tin besides execute this by moving 2 scripts - 1 for nan target droplets and nan different for nan Prometheus droplet.
Let’s commencement by configuring nan Target Droplets.
SSH into nan Target Droplet.
Download nan Target Configuration book by utilizing nan pursuing command:
wget https://solutions-files.ams3.digitaloceanspaces.com/Redis-Monitoring/DO_Redis_Target_Config.shOnce nan book is downloaded, guarantee it has executable permissions by running:
chmod +x DO_Redis_Target_Config.shExecute nan book by running:
./DO_Redis_Target_Config.shThe configuration is complete.
Note: If nan redis_exporter.service record already exists, nan book will not run.
Configuring nan Prometheus Droplet (Script Method)
SSH into nan Prometheus Droplet and download nan book by utilizing nan pursuing command:
wget https://solutions-files.ams3.digitaloceanspaces.com/Redis-Monitoring/DO_Redis_Prometheus_Config.shOnce nan book is downloaded, guarantee it has executable permissions by running:
chmod +x DO_Redis_Prometheus_Config.shExecute nan book by running:
./DO_Redis_Prometheus_Config.shEnter nan number of Droplets to adhd to monitoring.
Enter nan hostnames and IP addresses.
The configuration is complete.
Once added, cheque whether nan targets are updated by accessing nan URL prometheushostname:9090/targets.
Note: If you participate an IP reside already added to nan monitoring, you will beryllium asked to participate nan specifications again. Also, if you do not person immoderate much servers to add, you tin participate 0 to exit nan script
Configuring Grafana
Log into nan Grafana dashboard by visiting Grafana-IP:3000 connected a browser.
Go to Configuration > Data Sources.
Click connected Add information source.
Search and Select Prometheus.
Enter Name arsenic Prometheus, and URL (Prometheushostname:9090) and click “Save & Test”. If you spot “Data root is working”, you person successfully added nan information source. Once done, spell to Create > Import.
You tin manually configure nan dashboard aliases import nan dashboard by uploading nan JSON file. A JSON template for Redis monitoring tin beryllium recovered successful nan beneath link:
https://solutions-files.ams3.digitaloceanspaces.com/Redis-Monitoring/DO_Grafana-Redis_Monitoring.jsonFill successful nan fields and Import.
The Grafana dashboard is ready. Select nan big and cheque if nan metrics are visible. Please consciousness free to modify and edit nan dashboard arsenic needed.
Conclusion
In this tutorial, you learned to automate nan deployment of nan Redis Exporter connected your servers. The book originates by checking if nan redis_exporter.service portion record already exists and exits if it does, avoiding redundant setups. It past creates a Prometheus strategy personification and group for unafraid work isolation. The book downloads and installs nan Redis Exporter binaries, placing them successful /usr/local/bin/ for standardization.
Next, it generates and configures a strategy portion record (redis_exporter.service), specifying basal settings and restarting policies. The book reloads systemd to use nan caller configuration, enables nan work to commencement astatine boot, and starts it immediately.
By automating these steps, nan book simplifies nan deployment process, minimizes quality error, and ensures a accordant setup crossed servers, providing an businesslike solution for integrating Redis metrics into your Prometheus monitoring infrastructure.
As a adjacent step, you tin besides mention to our tutorial connected Monitoring MySQL and MariaDB Droplets Using Prometheus MySQL Exporter.