03 Downtime Reporting
Downtime reporting in Grafana with the ENLYZE API.
In this tutorial you build a dashboard for analyzing machine downtimes with a pie chart, timeline, and detail table:

What you will learn
Query the downtimes API endpoint
Calculate downtime duration with transformations
Visualize downtimes with pie chart, bar gauge, and state timeline
Set up value mappings for downtime categories
Prerequisites
Query the ENLYZE API and Variables completed
Understanding of Infinity queries and transformations
Query downtimes
Type
JSON
Parser
Backend
Method
GET
URL
downtimes?machine=${machine}&start=${__from:date:iso}&end=${__to:date:iso}
Root selector
see JSONata
The API returns downtimes with nested reason information. Use JSONata to extract the fields and fill in missing end times:
When end is null, the downtime is still active. $now() replaces missing end times with the current time.

Calculate downtime duration
You can calculate the duration from start and end times using transformations:
Convert field type: start and end to Time
Add field from calculation: Mode Binary, end - start to
duration_msAdd field from calculation: duration_ms / 1000 to
duration
Set the unit of the duration field to Duration (d hh:mm:ss) (dtdhms).

Pie chart by category
Visualize the distribution of downtime categories:
Use the base query with the duration calculation transformations
Add a Group by transformation: Group by
category, Aggregatedurationto SumSelect the Pie Chart visualization
Set up Value Mappings to make the API values more readable:
PLANNED
Planned downtime
Blue
UNPLANNED
Unplanned (manual)
Orange
NOT_SCHEDULED
Not scheduled
Gray
UNKNOWN
No reason
Yellow

Bar gauge by category
Show the duration per category as horizontal bars:
Visualization
Bar Gauge
Orientation
Horizontal
Display mode
Basic
Unit
Duration (d hh:mm:ss)
Use the same query and transformations as the pie chart.

State timeline
Show when downtimes occurred over time:
Visualization
State timeline
Merge values
On
Use the same value mappings as the pie chart so that the categories are color-coded consistently.

Detail table
Show individual downtime events with all details:
start
Timestamp
dateTimeAsIso
end
Timestamp
dateTimeAsIso
duration
Number
Unit: dtdhms
category
String
Value Mappings
reason
String
-

Tips
Downtime categories:
PLANNED(scheduled maintenance, changeovers),UNPLANNED(manually reported),NOT_SCHEDULED(no production scheduled). Use consistent colors across all panels.Ongoing downtimes: Replace
nullend times with$now()in JSONata so that the duration calculation works.Empty data: Check the time range. Downtimes are only available for periods when the machine was active.
Pareto analysis: Filter for
UNPLANNED, group byreason, and sort descending bydurationto identify the most common downtime reasons.
Next steps
Shopfloor monitoring -- Build dashboards for large screens and mobile devices
Last updated