跳至主要內容

监控面板安装部署

大约 4 分钟

监控面板安装部署

从 Apache IoTDB 1.0 版本开始,我们引入了系统监控模块,可以完成对 Apache IoTDB 的重要运行指标进行监控,本文介绍了如何在 Apache IoTDB 分布式开启系统监控模块,并且使用 Prometheus + Grafana 的方式完成对系统监控指标的可视化。

前期准备

软件要求

  1. Apache IoTDB:1.0 版本及以上,可以前往官网下载:https://iotdb.apache.org/Download/open in new window
  2. Prometheus:2.30.3 版本及以上,可以前往官网下载:https://prometheus.io/download/open in new window
  3. Grafana:8.4.2 版本及以上,可以前往官网下载:https://grafana.com/grafana/downloadopen in new window
  4. IoTDB-Grafana安装包:Grafana看板为IoTDB企业版工具,您可联系您的销售获取相关安装包

集群要求

进行以下操作前请确认IoTDB集群已启动。

说明

本文将在一台机器(1 个 ConfigNode 和 1 个 DataNode)环境上进行监控面板搭建,其他集群配置是类似的,用户可以根据自己的集群情况(ConfigNode 和 DataNode 的数量)进行配置调整。本文搭建的集群的基本配置信息如下表所示。

集群角色节点IP监控模块推送器监控模块级别监控 Port
ConfigNode127.0.0.1PROMETHEUSIMPORTANT9091
DataNode127.0.0.1PROMETHEUSIMPORTANT9093

配置 Prometheus 采集监控指标

  1. 下载安装包。下载Prometheus的二进制包到本地,解压后进入对应文件夹:
tar xvfz prometheus-*.tar.gz
cd prometheus-*
  1. 修改配置。修改Prometheus的配置文件prometheus.yml如下
    a. 新增 confignode 任务收集 ConfigNode 的监控数据
    b. 新增 datanode 任务收集 DataNode 的监控数据
global:
  scrape_interval: 15s

scrape_configs:
  - job_name: "prometheus"
    static_configs:
    - targets: ["localhost:9090"]
  - job_name: "confignode"
    static_configs:
    - targets: ["localhost:9091"]
    honor_labels: true
  - job_name: "datanode"
    static_configs:
    - targets: ["localhost:9093"]
    honor_labels: true
  1. 启动Promethues。Prometheus 监控数据的默认过期时间为 15d。在生产环境中,建议将其调整为 180d 以上,以对更长时间的历史监控数据进行追踪,启动命令如下所示:
./prometheus --config.file=prometheus.yml --storage.tsdb.retention.time=180d
  1. 确认启动成功。在浏览器中输入 http://localhost:9090open in new window,进入Prometheus,点击进入Status下的Target界面(如下图1),当看到State均为Up时表示配置成功并已经联通(如下图2),点击左侧链接可以跳转到网页监控。


使用 Grafana 查看监控数据

Step1:Grafana 安装、配置与启动

  1. 下载Grafana的二进制包到本地,解压后进入对应文件夹:
tar -zxvf grafana-*.tar.gz
cd grafana-*
  1. 启动Grafana并进入:
./bin/grafana-server web 
  1. 在浏览器中输入 http://localhost:3000open in new window,进入Grafana,默认初始用户名和密码均为 admin。
  2. 首先我们在 Configuration 中配置 Data Source 为 Prometheus
  1. 在配置 Data Source 时注意 Prometheus 所在的URL,配置好后点击Save & Test 出现 Data source is working 提示则为配置成功

Step2:使用IoTDB官方提供的Grafana看板

  1. 进入 Grafana,选择 Dashboards 的 Browse
  1. 点击右侧 Import 按钮
  1. 选择一种方式导入 Dashboard
    a. 上传本地已下载的 Dashboard 的 Json 文件
    b. 输入 Grafana 官网获取到的 Dashboard 的 URL 或者 ID
    c. 将 Dashboard 的 Json 文件内容直接粘贴进入
  1. 选择 Dashboard 的 Prometheus 为刚刚配置好的 Data Source,然后点击 Import
  1. 之后进入 Dashboard,选择 job 为 ConfigNode,就看到如下的监控面板
  1. 同样地,我们可以导入 Apache DataNode Dashboard,选择 job 为 DataNode,就看到如下的监控面板:

Step3:创建新的 Dashboard 进行数据可视化

  1. 首先创建Dashboard,然后创建Panel
  1. 之后就可以在面板根据自己的需求对监控相关的数据进行可视化(所有相关的监控指标可以先在job中选择confignode/datanode筛选)
  1. 选择关注的监控指标可视化完成后,我们就得到了这样的面板:

Copyright © 2023 The Apache Software Foundation.
Apache and the Apache feather logo are trademarks of The Apache Software Foundation

Have a question? Connect with us on QQ, WeChat, or Slack. Join the community now.

We use Google Analytics to collect anonymous, aggregated usage information.