Customize your dashboard

With your first Grafana-Synapse dashboard in place, you can now start customizing.

Grafana has a tutorial on panels, so we mainly focus on some of the basics. You can also find inspiration via our dashboard playgrounds.


Templates - getting started

We recommend that you load the dynamic dashboard template as your starting point.

For inspiration, see also the templates in our Grafana-Athena customization section. These can be quickly modified for use with Grafana-Synapse.


Variables

The dashboard template uses variables. These allow end users of the dashboard to dynamically control certain values, e.g. the device, message and signal.


Create a new panel

The Synapse data source uses standard SQL (T-SQL) to query data[1].

To create a new panel, click ‘Add/Visualization’ (top middle) and paste a query as below:

SELECT
    DATEADD(MILLISECOND, (DATEPART(MILLISECOND, t) / $__interval_ms) * $__interval_ms, DATEADD(SECOND, DATEDIFF(SECOND, '2020', t), '2020')) AS time,
    AVG(mysignal) as AVG_mysignal
FROM
    OPENROWSET(
        BULK '${device:csv}/MyMessage/*/*/*/*',
        DATA_SOURCE = 'ParquetDataLake',
        FORMAT = 'PARQUET'
    ) AS r
WHERE
    CONCAT(r.filepath(1), '-', r.filepath(2), '-', r.filepath(3)) BETWEEN CONVERT(date, $__timeFrom()) AND CONVERT(date, $__timeTo())
    AND $__timeFilter(t)
GROUP BY
    DATEDIFF(SECOND, '2020', t), DATEPART(MILLISECOND, t) / $__interval_ms
ORDER BY
    time
OFFSET 0 ROWS;

Simply replace MyMessage with your message name (e.g. CAN2_gnssspeed) and mysignal with a signal (e.g. Speed) from that message[2]. You can also query multiple signals/aggregations:

AVG(MySignal1) as AVG_mysignal1, MAX(MySignal2) as MAX_mysignal2

Transformations

Grafana transformations allow you to transform your data to create e.g. calculated signals, filters and more. In the GPS/IMU templates, transformations are e.g. used to filter which signals are shown in certain panels - as well as scale speed (m/s) to speed (km/h).


[1]Note that the query uses OPENROWSET to fetch data, rather than referencing the tables that were mapped during the Synapse deployment. This is required in order to leverage partition pruning as done in the WHERE section via the filepath comparison. You could remove this pruning and refer to table names directly, but your queries would become drastically slower and scan more data (hence become more expensive). However, we do use the table mapping in the dynamic dropdown functionality of the Grafana dashboard template.
[2]If in doubt on message/signal names, you can browse them via the variable dropdowns. Note that message names are case sensitive in Synapse