搜索
首页数据库Redis使用 Redis Exporter 服务监控 Redis Droplet

方法一:手动配置

我们继续本节的手动配置方法。

创建Prometheus系统用户和组

创建一个名为的系统用户和组“prometheus”来管理导出器

sudo groupadd --system prometheus
sudo useradd -s /sbin/nologin --system -g prometheus prometheus

下载并安装 Redis Exporter

下载从 GitHub 提取最新版本的 Redis Exporter 下载的文件,并将二进制文件移动到 /usr/local/bin/ 目录。

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/

验证 Redis 导出器安装

redis_exporter --version

这是示例输出:

使用 Redis Exporter 服务监控 Redis Droplet

为 Redis Exporter 配置 systemd 服务

创建 systemd 服务单元文件来管理 Redis Exporter

sudo vim /etc/systemd/system/redis_exporter.service

将以下内容添加到file:

redis_exporter.service
[Unit]Description=Prometheus Redis ExporterDocumentation=https://github.com/oliver006/redis_exporterWants=network-online.targetAfter=network-online.target[Service]Type=simpleUser=prometheusGroup=prometheusExecReload=/bin/kill -HUP $MAINPIDExecStart=/usr/local/bin/redis_exporter 
  --log-format=txt 
  --namespace=redis 
  --web.listen-address=:9121 
  --web.telemetry-path=/metricsSyslogIdentifier=redis_exporterRestart=always[Install]WantedBy=multi-user.target

重新加载 systemd 并启动 Redis Exporter服务

sudo systemctl daemon-reload
sudo systemctl enable redis_exporter
sudo systemctl start redis_exporter

配置 Prometheus Droplet(手动方法)

让我们手动配置 Prometheous Droplet。

备份 prometheus.yml 文件

cp /etc/prometheus/prometheus.yml /etc/prometheus/prometheus.yml-$(date  '%d%b%Y-%H:%M')

添加 Redis Exporter 端点scraped

登录到您的 Prometheus 服务器并添加要抓取的 Redis Exporter 端点。

将 IP 地址和端口替换为您的 Redis Exporter 端点(9121 是 Redis Exporter 的默认端口)服务)。

vi /etc/prometheus/prometheus.yml
prometheus.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:

手动配置到此结束。现在,让我们继续基于脚本的配置。

方法 2:使用脚本进行配置

您还可以通过运行两个脚本来实现此目的 - 一个用于目标 Droplet,另一个用于 Prometheus Droplet。

让我们从配置目标 Droplet 开始。

通过 SSH 连接到目标Droplet。

使用以下命令下载目标配置脚本:

wget https://solutions-files.ams3.digitaloceanspaces.com/Redis-Monitoring/DO_Redis_Target_Config.sh

下载脚本后,确保它具有可执行权限运行:

chmod  x DO_Redis_Target_Config.sh

通过运行以下命令执行脚本:

./DO_Redis_Target_Config.sh

配置

使用 Redis Exporter 服务监控 Redis Droplet

注意:如果redis_exporter.service文件已经存在,脚本将不会运行。

使用 Redis Exporter 服务监控 Redis Droplet

配置 Prometheus Droplet(脚本方法)

SSH 到 Prometheus Droplet 并使用以下命令下载脚本:

wget https://solutions-files.ams3.digitaloceanspaces.com/Redis-Monitoring/DO_Redis_Prometheus_Config.sh

下载脚本后,请确保它具有可执行权限运行:

chmod  x DO_Redis_Prometheus_Config.sh

执行脚本running:

./DO_Redis_Prometheus_Config.sh

输入要添加到监控的 Droplet 数量。

输入主机名和IP地址。

使用 Redis Exporter 服务监控 Redis Droplet

配置完成。

添加后,通过访问 URL prometheushostname:9090/targets 检查目标是否更新。

注意:如果您输入的 IP 地址已添加到 监控时,您将被要求再次输入详细信息。另外,如果 您没有更多服务器可以添加,可以输入 0 退出 script

使用 Redis Exporter 服务监控 Redis Droplet

配置 Grafana

通过浏览器访问 Grafana-IP:3000 登录 Grafana 仪表板。

Go到配置 > 数据来源。

使用 Redis Exporter 服务监控 Redis Droplet

单击“添加数据源”。

使用 Redis Exporter 服务监控 Redis Droplet

搜索并选择 Prometheus。

使用 Redis Exporter 服务监控 Redis Droplet

输入名称 Prometheus 和 URL (Prometheus主机名:9090)并单击“保存并测试”。如果看到“数据源正在运行”,则说明您已成功添加数据源。完成后,转到创建 > 导入。

使用 Redis Exporter 服务监控 Redis Droplet

您可以手动配置仪表板或通过以下方式导入仪表板 上传 JSON 文件。用于 Redis 监控的 JSON 模板可以是 在以下链接中找到:

https://solutions-files.ams3.digitaloceanspaces.com/Redis-Monitoring/DO_Grafana-Redis_Monitoring.json

填写字段并导入。

使用 Redis Exporter 服务监控 Redis Droplet

Grafana 仪表板是 准备好。选择主机并检查是否 指标是可见的。请随意修改和编辑仪表板 根据需要。

使用 Redis Exporter 服务监控 Redis Droplet

以上是使用 Redis Exporter 服务监控 Redis Droplet的详细内容。更多信息请关注PHP中文网其他相关文章!

声明
本文转载于:digitalocean.com。如有侵权,请联系admin@php.cn删除
图文详解mysql架构原理图文详解mysql架构原理May 17, 2022 pm 05:54 PM

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于架构原理的相关内容,MySQL Server架构自顶向下大致可以分网络连接层、服务层、存储引擎层和系统文件层,下面一起来看一下,希望对大家有帮助。

mysql怎么替换换行符mysql怎么替换换行符Apr 18, 2022 pm 03:14 PM

在mysql中,可以利用char()和REPLACE()函数来替换换行符;REPLACE()函数可以用新字符串替换列中的换行符,而换行符可使用“char(13)”来表示,语法为“replace(字段名,char(13),'新字符串') ”。

mysql的msi与zip版本有什么区别mysql的msi与zip版本有什么区别May 16, 2022 pm 04:33 PM

mysql的msi与zip版本的区别:1、zip包含的安装程序是一种主动安装,而msi包含的是被installer所用的安装文件以提交请求的方式安装;2、zip是一种数据压缩和文档存储的文件格式,msi是微软格式的安装包。

mysql怎么去掉第一个字符mysql怎么去掉第一个字符May 19, 2022 am 10:21 AM

方法:1、利用right函数,语法为“update 表名 set 指定字段 = right(指定字段, length(指定字段)-1)...”;2、利用substring函数,语法为“select substring(指定字段,2)..”。

mysql怎么将varchar转换为int类型mysql怎么将varchar转换为int类型May 12, 2022 pm 04:51 PM

转换方法:1、利用cast函数,语法“select * from 表名 order by cast(字段名 as SIGNED)”;2、利用“select * from 表名 order by CONVERT(字段名,SIGNED)”语句。

MySQL复制技术之异步复制和半同步复制MySQL复制技术之异步复制和半同步复制Apr 25, 2022 pm 07:21 PM

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于MySQL复制技术的相关问题,包括了异步复制、半同步复制等等内容,下面一起来看一下,希望对大家有帮助。

带你把MySQL索引吃透了带你把MySQL索引吃透了Apr 22, 2022 am 11:48 AM

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了mysql高级篇的一些问题,包括了索引是什么、索引底层实现等等问题,下面一起来看一下,希望对大家有帮助。

mysql怎么判断是否是数字类型mysql怎么判断是否是数字类型May 16, 2022 am 10:09 AM

在mysql中,可以利用REGEXP运算符判断数据是否是数字类型,语法为“String REGEXP '[^0-9.]'”;该运算符是正则表达式的缩写,若数据字符中含有数字时,返回的结果是true,反之返回的结果是false。

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
2 周前By尊渡假赌尊渡假赌尊渡假赌
仓库:如何复兴队友
4 周前By尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒险:如何获得巨型种子
3 周前By尊渡假赌尊渡假赌尊渡假赌

热工具

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具