Prometheus 和 Grafana 与 Redis 企业版软件

使用Prometheus和Grafana收集和可视化Redis企业版软件的指标。

您可以使用Prometheus和Grafana来收集和可视化您的Redis Enterprise Software指标。

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

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

您可以使用Prometheus和Grafana来:

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

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

  • 显示Redis企业版软件指标以及其他系统的数据

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 指标。 Redis Enterprise 版本 7.8.2 引入了新的指标流引擎预览,该引擎在 https://:8070/v2 上暴露 v2 Prometheus 抓取端点。

快速开始

开始使用 Prometheus 和 Grafana:

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

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

  3. 将以下内容添加到配置文件中,并将替换为您的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"] # For v2, use ["<cluster_name>:8070/v2"]
    
  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://:9090
      The Prometheus connection form in Grafana.
    Note:
    • 如果Grafana服务器无法访问网络端口,请从访问菜单中选择浏览器选项。
    • 在测试环境中,您可以选择跳过TLS验证
  6. 为集群、数据库、节点和分片指标添加仪表板。 要添加预配置的仪表板:

    1. In the Grafana dashboards menu, select Manage.
    2. Click Import.
    3. Upload one or more Grafana dashboards.

Redis Enterprise 的 Grafana 仪表板

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

这些仪表板是开源的。如需更多仪表板选项或提交问题,请参阅Redis Enterprise 可观测性 Github 仓库

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

RATE THIS PAGE
Back to top ↑