Prometheus 和 Grafana 与 Redis Enterprise

使用 Prometheus 和 Grafana 收集和可视化 Redis 云指标。

您可以使用 Prometheus 和 Grafana 收集和可视化 Redis Enterprise 软件指标。

指标在集群、节点、数据库、分片和代理级别公开。

  • Prometheus 是一个开源系统监控和警报工具包,它聚合来自不同来源的指标。
  • Grafana 是一个开源指标可视化工具,它处理 Prometheus 数据。

您可以使用 Prometheus 和 Grafana 来

  • 收集和显示在 管理控制台 中不可用的指标

  • 为节点或集群事件设置自动警报

  • 与来自其他系统的數據一起显示 Redis Enterprise 软件指标

Graphic showing how Prometheus and Grafana collect and display data from a Redis Enterprise Cluster. Prometheus collects metrics from the Redis Enterprise cluster, and Grafana queries those metrics for visualization.

在每个集群中,metrics_exporter 进程在端口 8070 上公开 Prometheus 指标。

快速入门

要开始使用 Prometheus 和 Grafana

  1. 在本地机器上创建一个名为“prometheus”的目录。

  2. 在该目录中,创建一个名为 prometheus.yml 的配置文件。

  3. 将以下内容添加到配置文件中,并将 <cluster_name> 替换为 Redis Enterprise 集群的 FQDN

    注意
    建议仅在开发和测试中在 Docker 中运行 Prometheus。
    global:
      scrape_interval: 15s
      evaluation_interval: 15s
    
    # Attach these labels to any time series or alerts when communicating with
    # external systems (federation, remote storage, Alertmanager).
      external_labels:
        monitor: "prometheus-stack-monitor"
    
    # Load and evaluate rules in this file every 'evaluation_interval' seconds.
    #rule_files:
    # - "first.rules"
    # - "second.rules"
    
    scrape_configs:
    # scrape Prometheus itself
      - job_name: prometheus
        scrape_interval: 10s
        scrape_timeout: 5s
        static_configs:
          - targets: ["localhost:9090"]
    
    # scrape Redis Enterprise
      - job_name: redis-enterprise
        scrape_interval: 30s
        scrape_timeout: 30s
        metrics_path: /
        scheme: https
        tls_config:
          insecure_skip_verify: true
        static_configs:
          - targets: ["<cluster_name>:8070"]
    
  4. 设置 Prometheus 和 Grafana 服务器。要在 Docker 上设置 Prometheus 和 Grafana

    1. 创建一个 docker-compose.yml 文件

      version: '3'
      services:
          prometheus-server:
              image: prom/prometheus
              ports:
                  - 9090:9090
              volumes:
                  - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
      
          grafana-ui:
              image: grafana/grafana
              ports:
                  - 3000:3000
              environment:
                  - GF_SECURITY_ADMIN_PASSWORD=secret
              links:
                  - prometheus-server:prometheus
      
    2. 要启动容器,请运行

      $ docker compose up -d
      
    3. 要检查所有容器是否已启动,请运行:docker ps

    4. 在浏览器中,登录到 http://localhost:9090 上的 Prometheus,以确保服务器正在运行。

    5. 选择**状态**,然后选择**目标**,以检查 Prometheus 是否正在从您的 Redis Enterprise 集群收集数据。

      The Redis Enterprise target showing that Prometheus is connected to the Redis Enterprise Cluster.

      如果 Prometheus 已连接到集群,您可以在 Prometheus 主页上的表达式字段中输入**node_up**,以查看集群指标。

  5. 配置 Grafana 数据源

    1. 登录 Grafana。如果您在本地安装了 Grafana,请访问 http://localhost:3000 并使用以下信息登录:

      • 用户名:admin
      • 密码:secret
    2. 在 Grafana 配置菜单中,选择**数据源**。

    3. 选择**添加数据源**。

    4. 从数据源类型列表中选择**Prometheus**。

      The Prometheus data source in the list of data sources on Grafana.
    5. 输入 Prometheus 配置信息

      • 名称:redis-enterprise
      • URL:http://<您的 Prometheus 服务器名称>:9090
      The Prometheus connection form in Grafana.
    注意
    • 如果 Grafana 服务器无法访问网络端口,请从访问菜单中选择**浏览器**选项。
    • 在测试环境中,您可以选择**跳过 TLS 验证**。
  6. 添加用于集群、数据库、节点和分片指标的仪表盘。要添加预配置的仪表盘,请执行以下操作:

    1. 在 Grafana 仪表盘菜单中,选择**管理**。
    2. 点击**导入**。
    3. 上传一个或多个Grafana 仪表盘

Grafana 仪表盘用于 Redis Enterprise

Redis 为 Redis Enterprise 和 Grafana 发布了四个预配置的仪表盘

这些仪表盘是开源的。有关其他仪表盘选项,或要提交问题,请查看Redis Enterprise 可观测性 Github 仓库

有关配置 Grafana 仪表盘的更多信息,请参见Grafana 文档

RATE THIS PAGE
Back to top ↑