Get historical measurements per channel in Grafana

Get historical measurements per channel in Grafana
Warehouse humidity measurements for paper storage and cardboard monitoring
CO2 monitoring in livestock: long overdue
Innovative monitoring of embankments along the A10 with Reporter
A weather station with water level sensor for a marina or harbour
Colruyt Group uses Reporter for soil moisture measurements at the organic farm Het Zilverleen
Salinity detection in groundwater: Monitoring salt levels during dewatering
Royal Latem Golf Club uses Reporter for water monitoring
Connecting a water flow sensor to the cloud
Sensor adapters, what are they and how do they work?
Rode Rozen & Tortilla's uses Reporter for reliable temperature monitoring
Artes Woudenberg uses Reporter for wind monitoring during restoration of Brussels Palace of Justice
Smart sensors for ports and terminals
Rain monitoring for dry bulk terminals and ports
Pluym - Van Loon uses Reporter for groundwater level monitoring at construction sites
Construction site monitoring - safety & efficiency
Effective industrial odour monitoring
Why temperature control is incomplete without remote monitoring
Taste Restaurantgroup uses Reporter for freezer monitoring
Cemminerals uses Reporter to measure the temperature of canal water
Rombaut Plant uses Reporter for frost monitoring in potted plants
Vandijk Technics uses Reporter for temperature registration in cold rooms
Combined relative air humidity and leaf wetness measurement
Innovative tree monitoring: Ecomatik dendrometer integrated with Reporter
De Bossen measures soil moisture for a bountiful pole bean harvest
TM Edison uses Reporter during the construction of energy island
What is the difference between direct vs indirect energy meters?
Weather monitoring: measuring wind at a festival site
Choose the right flow meter for your next water project
How to measure Dew Point and Wet Bulb temperature
Precision test for the Sensirion SHT35 humidity sensor
Installing a weather station on caravans, holiday homes or recreational vehicles
The effect of wind on measuring particulate matter
Connecting a Watermark sensor to the cloud
Watermark vs SMT100: volumetric water content or soil water tension?
Smart geotechnical data gathering and interpretation
6 tips for making the most of your cold room
Temperature registration for HACCP
Quickly tackle the 7 principles of HACCP
6 lists to quickly get started with HACCP
Monitoring soil moisture contents for crop farming
Green Wall Monitoring: Why your vertical garden needs smart garden sensors
How is Reporter powered?
Storm & scaffolding: leveraging weather stations for enhanced construction site safety
Level measurement in a container or well
The ease of Reporter: Sumaq's a fan!
Protecting fruit tree blossoms from freezing
Adverse weather warning for your construction site
Real-time Frost Monitoring & Alert System
Pseudomonas syringae prevention in fruit trees
Cold storage of cut flowers with temperature monitoring

Do you want to visualise a channel of your multi-parameter sensor? Then this step-by-step guide is for you.

Have you already read and completed the steps of part one of this guide? Make sure these have been carried out correctly before continuing.

Step 1: Get the right API call

If you want to get measurement data from one channel, you'll need to use the correct type of API call:

https://api.crodeon.com/api/v2/reporters/{master_id}/sensors/{device_id}/channels/{channel_index}/measurements

For this API you need the following information from your Reporter:

  • master_id = Reporter device ID
  • device_id = Sensor device ID
  • channel_index = Channel index (parameter of the selected sensor)

In this guide we will need the Reporter device ID of which you want to visualise the data. You can find this information on the 'Configure Reporter' page on the Crodeon Dashboard. For this example, we'll be using our demo weather station in Roermond (NL):

Reporter device ID

Step 2: Create new Grafana Dashboard

We have chosen our type of API call, now we can start building our Grafana dashboard using our Reporter data! Therefore we will create a new dashboard to start:

new dashboard

In this guide we will refer to the Settings of a dashboard. The settings can be entered/exited through following button:

dashboard settings

When in the settings, you can navigate Back to dashboard with a button on the same location.

Furthermore, we will create some variables in the following steps. If you need more information on variables and Grafana, you can consult following documentation on grafana.com.

Step 3: Create API linked variables

To be able to user our API call, we need some variables which we will create variables for our Grafana dashboard for.

API variable Grafana dashboard variable
master_id ReporterDeviceID
device_id SensorDeviceID
channel_index ChannelIndex

Steps to add the variable

1. Navigate to the Settings of the dashboard.

2. Go to the Variables tab.

3. Now click Add Variable

4. The first variable will be the Reporter device ID.

  1. Variable type is a Constant
  2. use ReporterDeviceID for the Name
  3. Fill in the Value with your Reporter device ID acquired from the configure page
  4. Navigate Back to list of variables
variables reporter device id

5. Click on New variable to add a second variable for the Sensor device ID

  1. We will use a Queryvariable type to get dynamic sensor info from our API
  2. use SensorDeviceID for the Name
  3. set Label to Sensor DeviceID
  4. Fill in the Query options
  • Select your data source, for this purpose we created 'Crodeon-API-Demo-Infinity-datasource' in our previous blog
  • set the Query Type to Infinity
  • Change the Parser to UQL
  • Update the URL to https://api.crodeon.com/api/v2/reporters/${ReporterDeviceID}/sensorsNotice we are using the previously created variable in the url.
  • Expand the UQL settings and copy paste the following UQL query:
parse-json
| scope "sensors"
| project "__value"="device_id.id", "__text"=strcat('[',"device_id.id",'] ',"label")
  • Verify if the Preview of values shows your sensors
5. Navigate Back to list of variables

    6. Click on New variable to add a third variable for the Channel index

    1. We will use a Query as variable type to get dynamic channel info from our API
    2. use ChannelIndex for the Name
    3. set Label to Channel
    4. Fill in the Query options
      1. Select your data source, for this purpose we created 'Crodeon-API-Demo-Infinity-datasource' in our previous blog
      2. set the Query Type to Infinity
      3. Change the Parser to UQL
      4. Update the URL to https://api.crodeon.com/api/v2/reporters/${ReporterDeviceID}/sensors/${SensorDeviceID}Notice we are using both previously created variables in the url.
      5. Expand the UQL settings and copy paste the following UQL query:
    parse-json
    | scope "channels"
    | project "__value"="index", "__text"="label"

    6. Verify if the Preview of values shows your sensor channels

    5. Navigate Back to list of variables

      Step 4: Create variables for graph visualisation

      To be able to have better graph visualisation, we will add three more variables which can be used in the graphs. These variables will use the API to get details for the channel selected.

      The following variables should be added:

      Grafana dashboard variable UQL query
      ChannelLabel parse-json
      |scope "channels"
      |where "index" == ${ChannelIndex}
      |project "label"
      ChannelValueMultiplier parse-json
      |scope "channels"
      |where "index" == ${ChannelIndex}
      |project "exponent"=pow(10,"display_unit.exponent")
      DisplayUnit parse-json
      |scope "channels"
      |where "index" == ${ChannelIndex}
      |project "short-unit"="display_unit.short_unit"

      Repeat the following steps for all the variables in the table above

      1. Navigate to the Settings of the dashboard.
      2. Go to the Variables tab.
      3. Now click Add Variable (Note: you can also duplicate a variable and edit it)
        1. We will use a Query as variable type to get dynamic channel info from our API
        2. use the variable name in the table for the Name (eg: ChannelLabel)
        3. Change Shown on dashboard to Nothing
        4. Fill in the Query options
          1. Select your data source, for this purpose we created 'Crodeon-API-Demo-Infinity-datasource' in our previous blog
          2. set the Query Type to Infinity
          3. Change the Parser to UQL
          4. Update the URL to https://api.crodeon.com/api/v2/reporters/${ReporterDeviceID}/sensors/${SensorDeviceID}
          5. Expand the UQL settings and set the script to the script from the table
          6. Verify if the Preview of values shows something meaningful

      Step 5: Add a graph visualisation

      Now all the information is available in the dashboard via the variables, we can start using them to create a graph

      1. Exit the Settings and go Back to dashboard
      2. Select Add visualisation
      3. Select your data source, for this purpose we created 'Crodeon-API-Demo-Infinity-datasource' in our previous blog
      4. Modify the Data source settings in the new panel configuration
        1. Change the Parser to UQL
        2. Modify Format to Time Series
        3. Update the URL to https://api.crodeon.com/api/v2/reporters/${ReporterDeviceID}/sensors/${SensorDeviceID}/channels/${ChannelIndex}/measurements?page_size=100000&start_time=${__from:date:iso}&end_time=${__to:date:iso}
        4. Note: we added three request parameters to have the time range picker of Grafana working. See grafana.com for more info.
      5. Expand the UQL settings and copy-paste the following UQL query:
      parse-json
      |scope "items"
      |project "timestamp"=todatetime("timestamp"), "value"=mul("value",$ChannelValueMultiplier)
      6. Verify that your graph is now showing data (if there is data in the given time range)

        Step 6: Update graph labels

        At this point, the data is now visible within the graph, but the legend is not yet showing anything meaningful. Therefore we can use the variables created in step 4 to gloss over our graph.

        At the right side of the edit panel view, you can set some info like:

        • change Title to ${ChannelLabel}
        • At the bottom, use Add field override
          • Select Fields with name and choose the value item in the dropdown list
          • Add override property
            • Property: Axis > Label
            • Value: ${DisplayUnit}
          • Add override property
            • Property: Standard options > Display name
            • Value: ${ChannelLabel}

        Step 7: Finish

        Go Back to dashboard and don't forget to Save dashboard. After saving, you can Exit edit mode, and start using your new dashboard.

        The dashboard has now 3 selectors:

        • Changing the sensor connected to Reporter
        • Changing the channel of the sensor
        • Changing the time range you want to see the data from

        There is limit of maximum 100000 data points set. The maximum data range depends on the measurement interval of your Reporter.

        Grafana data visualisation
        Back to blog

        Any questions?

        Call us at +32474097705 Or use the contact form

        1 of 4
        • Demo laptop

          Live online demo

          Sign up for a free account on the Crodeon Dashboard a watch a real live working demo.

          Watch the demo 
        • person

          Talk to sales

          Schedule an appointment with Jonathan, our Sales Manager, for more information about this solution.

          Schedule a call 
        • phone email

          Contact us

          For partnerships, distribution, or any other question, don't hesistate to contact us!

          Contact us