Skip to content

Commit

Permalink
examples: add Grafana to down-sampling vehicle.speed using IoTDB
Browse files Browse the repository at this point in the history
Extend the documentation for the IoTDB Data Processing example that shows
down-sampling of VSS vehicle.speed to include using Grafana.

Signed-off-by: Stephen Lawrence <[email protected]>
  • Loading branch information
slawr committed Aug 6, 2024
1 parent 1ff5e75 commit 17d04da
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions examples/vehicle-speed-downsample-iotdb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,30 @@ It costs 0.028s
### Suggested next steps
+ Repeat the query with the same input data, but with different `k` parameter values to see what affects the number of samples has on the accuracy of the trace compared to the input data.
+ Amend the query with other [SQL clauses](https://iotdb.apache.org/UserGuide/latest/User-Manual/Query-Data.html) to shape what you are interested in, e.g. use `WHERE` to define a time filter.
+ A great way to explore these sampling queries is by using Grafana. In Grafana you can execute the queries and have it plot the result against other results (e.g. the original data or variations in `k`) in real time.
+ A great way to explore these sampling queries is by using Grafana as discussed below.
+ Try the other [IoTDB data processing functions](https://covesa.github.io/cdsp/manuals/apache-iotdb/#data-processing-functions)

## Using Grafana to visualise the result
Using Grafana we can send the same queries to IoTDB whilst visualising the results interactively.
Using Grafana we can send the same SQL queries to IoTDB and have Grafana visualize the results interactively.

Example with screenshots TBA
For example, we can ask Grafana to plot both the input data set and the down-sampled data on the same graph as shown below.

![Screenshot of a diagram showing two overlapping graphs of the input and output datasets](images/vss-down-sample-graph.png)
*Figure 1: Grafana visualisation of the results. Key: Green=input data, yellow=down-sampled result*

If we edit the query for the down-sample to change the `k` parameter to 10 or 1000 and re-run the query we can see the effect of how well it follows the original input data in real time.

This ability to use the same SQL query in the IoTDB CLI Client, any code and Grafana is in-line with our desire to use consistent data models and processes in a data centric architecture.

### Setup
#### Grafana connection setup
The IoTDB project maintains the IoTDB Grafana Plugin to allow Grafana to interact with IoTDB data sources using the IoTDB REST API. This Plugin has been upstreamed into the Grafana project and can be installed from Grafana. Installation and usage instructions can be found in the IoTDB [online documentation](https://iotdb.apache.org/UserGuide/latest/Ecosystem-Integration/Grafana-Plugin.html).

Note: The Plugin install instructions describe enabling the IoTDB REST API, which is disabled by default in IoTDB. This has already been done for you in the Playground IoTDB Docker image.

#### Grafana panel setup
As stated at the start of this Grafana section we can simply use the same queries we used earlier in the How-To in Grafana.

The screenshot below from Grafana v10.4 shows the Panel setup used to generate the graphs shown in Figure 1. Two queries are added to the Panel, one to return the input timeseries, the other to return the down-sampled data.
![Screenshot of a diagram showing two overlapping graphs of the input and output datasets](images/grafana-vss-down-sample-query.png)
*Figure 2: Grafana Panel setup to produce Figure 1.*
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 17d04da

Please sign in to comment.