Grafana下载地址:https://grafana.com/grafana/download
版本:4.4.1
选择相应的操作系统下载并安装
基于simple-json-datasource数据源插件连接IoTDB数据库。
插件下载地址:https://github.com/grafana/simple-json-datasource
下载并解压,将文件放到Grafana的目录中: data\plugin\
(Windows)或/var/lib/grafana/plugins
(Linux)
启动 Grafana
参考:https://github.com/apache/incubator-iotdb
下载源代码
git clone https://github.com/apache/incubator-iotdb.git mvn clean package -pl grafana -am -Dmaven.test.skip=true cd grafana
将application.properties
文件从conf/
目录复制到target
目录下,并编辑属性值
spring.datasource.url = jdbc:iotdb://127.0.0.1:6667/ spring.datasource.username = root spring.datasource.password = root spring.datasource.driver-class-name=org.apache.iotdb.jdbc.IoTDBDriver server.port = 8888
采用IoTDB作为后端数据源,前四行定义了数据库的属性,默认端口为6667,用户名和密码都为root,指定数据源驱动的名称。
编辑server.port的值修改连接器的端口,默认是8888。
启动数据库,参考:https://github.com/thulab/iotdb
运行后端数据源连接器,在控制台输入
$ java -jar iotdb-grafana-{version}.war . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.5.4.RELEASE) ...
Grafana的默认端口为 3000,在浏览器中访问 http://localhost:3000
用户名和密码都为 admin
在首页点击左上角的图标,选择Data Sources
,点击右上角Add data source
图标,填写data source
相关配置,在Config
中Type
选择SimpleJson
,Url
填写http://localhost:8888
端口号和数据源连接器的端口号一致,填写完整后选择Add
,数据源添加成功。
在首页点击左上角的图标,选择Dashboards
- New
,新建仪表板。在面板中可添加多种类型的图表。
以折线图为例说明添加时序数据的过程:
选择Graph
类型,在空白处出现无数据点的图,点击标题选择Edit
,在图下方出现属性值编辑和查询条件选择区域,在Metrics
一栏中Add Query
添加查询,点击select metric
下拉框中出现IoTDB中所有时序的名称,在右上角选择时间范围,绘制出对应的查询结果。可设置定时刷新,实时展现时序数据。