IoTDB-Grafana

Outline

  • IoTDB-Grafana
    • Grafana installation
      • Install Grafana
      • Install data source plugin
      • Start Grafana
    • IoTDB installation
    • IoTDB-Grafana installation
      • Start IoTDB-Grafana
    • Explore in Grafana
      • Add data source
      • Design in dashboard

IoTDB-Grafana

Grafana is an open source volume metrics monitoring and visualization tool, which can be used to display time series data and application runtime analysis. Grafana supports Graphite, InfluxDB and other major time series databases as data sources. IoTDB-Grafana is a connector which we developed to show time series data in IoTDB by reading data from IoTDB and sends to Grafana(https://grafana.com/). Before using this tool, make sure Grafana and IoTDB are correctly installed and started.

Grafana installation

Install Grafana

Install data source plugin

After downloading this plugin, use the grafana-cli tool to install SimpleJson from the commandline:

  1. grafana-cli plugins install grafana-simple-json-datasource

Alternatively, manually download the .zip file and unpack it into grafana plugins directory.

  • {grafana-install-directory}\data\plugins\ (Windows)
  • /var/lib/grafana/plugins (Linux)
  • /usr/local/var/lib/grafana/plugins(Mac)

Start Grafana

If Unix is used, Grafana will start automatically after installing, or you can run sudo service grafana-server start command. See more information hereGrafana - 图1 (opens new window).

If Mac and homebrew are used to install Grafana, you can use homebrew to start Grafana. First make sure homebrew/services is installed by running brew tap homebrew/services, then start Grafana using: brew services start grafana. See more information hereGrafana - 图2 (opens new window).

If Windows is used, start Grafana by executing grafana-server.exe, located in the bin directory, preferably from the command line. See more information hereGrafana - 图3 (opens new window).

IoTDB installation

See https://github.com/apache/iotdb

IoTDB-Grafana installation

  1. git clone https://github.com/apache/iotdb.git

Start IoTDB-Grafana

Option one

Import the entire project, after the maven dependency is installed, directly runiotdb/grafana/rc/main/java/org/apache/iotdb/web/grafanadirectoryTsfileWebDemoApplication.java, this grafana connector is developed by springboot

Option two

In /grafana/target/directory

  1. cd iotdb
  2. mvn clean package -pl grafana -am -Dmaven.test.skip=true
  3. cd grafana/target
  4. java -jar iotdb-grafana-{version}.war

If following output is displayed, then iotdb-grafana connector is successfully activated.

  1. $ java -jar iotdb-grafana-{version}.war
  2. . ____ _ __ _ _
  3. /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
  4. ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
  5. \\/ ___)| |_)| | | | | || (_| | ) ) ) )
  6. ' |____| .__|_| |_|_| |_\__, | / / / /
  7. =========|_|==============|___/=/_/_/_/
  8. :: Spring Boot :: (v1.5.4.RELEASE)
  9. ...

To configure properties, move the grafana/src/main/resources/application.properties to the same directory as the war package (grafana/target)

Explore in Grafana

The default port of Grafana is 3000, see http://localhost:3000/

Username and password are both “admin” by default.

Add data source

Select Data Sources and then Add data source, select SimpleJson in Type and URL is http://localhost:8888. After that, make sure IoTDB has been started, click “Save & Test”, and “Data Source is working” will be shown to indicate successful configuration. Grafana - 图4

Grafana - 图5

Design in dashboard

Add diagrams in dashboard and customize your query. See http://docs.grafana.org/guides/getting\_started/

Grafana - 图6

config grafana

  1. # ip and port of IoTDB
  2. spring.datasource.url=jdbc:iotdb://127.0.0.1:6667/
  3. spring.datasource.username=root
  4. spring.datasource.password=root
  5. spring.datasource.driver-class-name=org.apache.iotdb.jdbc.IoTDBDriver
  6. server.port=8888
  7. # Use this value to set timestamp precision as "ms", "us" or "ns", which must to be same with the timestamp
  8. # precision of Apache IoTDB engine.
  9. timestamp_precision=ms
  10. # Use this value to set down sampling true/false
  11. isDownSampling=true
  12. # defaut sampling intervals
  13. interval=1m
  14. # aggregation function to use to downsampling the data (int, long, float, double)
  15. # COUNT, FIRST_VALUE, LAST_VALUE, MAX_TIME, MAX_VALUE, AVG, MIN_TIME, MIN_VALUE, NOW, SUM
  16. continuous_data_function=AVG
  17. # aggregation function to use to downsampling the data (boolean, string)
  18. # COUNT, FIRST_VALUE, LAST_VALUE, MAX_TIME, MIN_TIME, NOW
  19. discrete_data_function=LAST_VALUE

The specific configuration information of interval is as follows

<1h: no sampling

1h~1d : intervals = 1m

1d~30d:intervals = 1h

>30d:intervals = 1d

After configuration, please re-run war package

  1. java -jar iotdb-grafana-{version}.war