Hoppa till huvudinnehåll

Lesson 3.1 Grafana

Grafana is a popular open-source tool for dashboards, maps and alerts. With the IoT platform's two Grafana data sources you can visualize your devices' live and historical data, build fleet overviews, and get notified when something goes wrong. In this lesson you'll build your first Grafana panels against the IoT platform's data.

For the full reference (every option), see the Grafana user guide.

Before you start

  • Grafana must already be installed and connected to the IoT platform. If it isn't, do the one-time setup first: Grafana Setup.
  • You need a few active devices in your account on the IoT platform (from the earlier lessons) - ideally something reporting temperature, and a tracker with lnglat for the map exercise.

Exercise 1 - Your first time-series graph

  1. In Grafana, go to Dashboards → New → New dashboard, then click Add visualization.
  2. When prompted, pick the JSON data source.
  3. Top-right, set the visualization type to Time series.
  4. In the query editor, open the Metric dropdown and select one of your devices (each device is a metric). Selecting * graphs all your active devices at once.
  5. Set the dashboard time range (top-right) to e.g. Last 24 hours and click Refresh.
  6. Click Apply (top-right) to add the panel to the dashboard.

→ The device's values are plotted over time.

time series

If lat/lng clutter the graph, open Transform data → + Add transformation → Filter fields by name and uncheck lat and lng.

Exercise 2 - Put your devices on a map

  1. On the dashboard, click Add → Visualization and pick the JSON data source again.
  2. Set the visualization type to Geomap.
  3. Select your tracker (or any located device) as the Metric, and make sure lat and lng are included.
  4. For a tracker's route, select the metric <Your Tracker>.lnglat - the track draws automatically. To colour it, add a second query <Your Tracker>.speed and, in the Map layers → Markers options, colour by that value with thresholds.
  5. Click Apply.

→ Your devices show as points; a tracker shows its path.

tracker map

Exercise 3 - A fleet overview table

This uses the Infinity data source, which can call any of the IoT platform's REST endpoints.

  1. Add → Visualization; this time pick the Infinity data source.
  2. Set the visualization type to Table.
  3. In the query, set Type = JSON, Source = URL, Method = GET, and URL = https://staging.yggio.net/api/iotnodes (add ?q=batteryLevel to list only your sensors).
  4. Open Parsing options & Result fields → Columns and add one row each (Selector → as → Format):
    • name → Device → String
    • batteryLevel → Battery % → Number
    • rssi → RSSI → Number
    • snr → SNR → Number
    • reportedAt → Last reported → Time
  5. Colour the battery column: Field → Add field override → Fields with name → Battery %, set Cell display mode = Colored background, then under Thresholds add red <20, amber <50, base green.
  6. Click the Last reported column header to sort, so silent devices rise to the top.
  7. Click Apply.

→ One row per device with battery, signal and last-seen.

fleet table

You now have an at-a-glance health view of every device.

Stretch goal - get alerted

Using the Infinity data source you can have Grafana notify you when a value crosses a threshold (e.g. temperature too high) or when a device stops reporting. Follow the step-by-step in the user guide: Set up a simple alert.

What you learned

  • The IoT platform's two data sources: JSON (quick device graphs & maps) and Infinity (any REST endpoint → tables, charts, maps, alerting).
  • How to build a time-series graph, a Geomap, and a fleet table.
  • Where to go for thresholds, transforms and alerting.

Where next

  • Grafana user guide - panel-choice table, tips & techniques, and more recipes (energy-per-day, occupancy timelines, alerting).
  • Next lesson: Power BI.