06 Downtime Reporting

Downtime reporting in Grafana with the ENLYZE API.

What You'll Learn

  • Query the downtimes API endpoint

  • Handle ongoing downtimes (no end time)

  • Calculate downtime duration with transformations

  • Visualise downtimes with pie charts and bar gauges

  • Create a state timeline for time-based analysis

  • Build summary statistics for downtime reports

Prerequisites

  • Completed Tutorials 4.1-4.3

  • Understanding of Infinity queries and transformations

  • Familiarity with dashboard variables


Overview

Downtime analysis helps identify:

  • How much time is lost to stoppages

  • What categories of downtime occur (planned, unplanned, not scheduled)

  • Which reasons are most common

  • When downtimes occur (patterns over time)

Downtime Categories

Category
Description
Color (Convention)

PLANNED

Scheduled maintenance, changeovers

Blue

UNPLANNED

Manual operator-reported stoppages

Orange

NOT_SCHEDULED

No production scheduled

Gray

(none)

Downtime without assigned reason

Yellow


Downtimes API Endpoint

The downtimes endpoint returns machine stoppages:

URL:

Query Parameters:

Parameter
Description

machine

Filter by machine UUID(s)

start

Filter downtimes starting from (ISO 8601)

end

Filter downtimes up to (ISO 8601)

Response Structure

Important: If end is null, the downtime is still ongoing.


Basic Downtime Query

Step 1: Create the Query

Infinity Configuration:

Setting
Value

Type

JSON

Parser

Backend

Source

URL

URL

downtimes?machine=${machine}&start=${__from:date:iso}&end=${__to:date:iso}

Root selector

$.data

Step 2: Extract Fields with Columns

Add columns to flatten the nested structure:

Selector
Title
Type

uuid

uuid

String

machine

machine

String

start

start

Timestamp

end

end

Timestamp

reason.category

category

String

reason.name

reason

String

[SCREENSHOT: Basic downtime query configuration]


Handling Ongoing Downtimes

Downtimes without an end time are still in progress. Handle them with JSONata:

JSONata to Fill Missing End Times

This replaces null end times with the current time for calculations.

Alternative: Use Query Time Range End

This uses the dashboard's time range end instead of current time.


Calculating Downtime Duration

Grafana transformations can calculate duration from start/end times.

Step 1: Convert Field Types

Add transformation -> Convert field type:

Field
Type

start

Time

end

Time

Step 2: Calculate Duration

Add transformation -> Add field from calculation:

Setting
Value

Mode

Binary operation

Operation

end - start

Alias

duration_ms

This gives duration in milliseconds.

Step 3: Convert to Seconds

Add another calculation:

Setting
Value

Mode

Binary operation

Operation

duration_ms / 1000

Alias

duration

Now duration is in seconds, which works with the dtdhms unit (days, hours, minutes, seconds).

[SCREENSHOT: Duration calculation transformations]


Downtime Pie Chart by Category

Visualise the distribution of downtime categories.

Query Configuration

Use the basic downtime query with JSONata:

Transformations

  1. Convert field type -> start, end to Time

  2. Add field from calculation -> duration_ms = end - start

  3. Add field from calculation -> duration = duration_ms / 1000

  4. Group by:

    • Group by: category

    • Aggregate: duration -> Sum

Panel Settings

Setting
Value

Visualization

Pie Chart

Reduce

Fields -> duration (sum)

Legend

Table, show percent

Value Mappings

Map category values to readable names:

Value
Display

PLANNED

Planned Downtime

UNPLANNED

Unplanned (Manual)

NOT_SCHEDULED

Not Scheduled

UNKNOWN

No Reason

Color Overrides

Add field overrides for each category:

Category
Color

Planned Downtime

dark-blue

Unplanned (Manual)

orange

Not Scheduled

gray

No Reason

yellow

[SCREENSHOT: Downtime pie chart by category]


Downtime Bar Gauge

Show duration by category as horizontal bars.

Panel Settings

Setting
Value

Visualization

Bar Gauge

Orientation

Horizontal

Display mode

Basic

Show unfilled area

Off

Unit

Duration (d hh:mm:ss)

Use the same query and transformations as the pie chart.

[SCREENSHOT: Downtime bar gauge]


State Timeline

Show when downtimes occurred over time.

Query Configuration

Panel Settings

Setting
Value

Visualization

State timeline

Merge values

On

Show value

Auto

Value Mappings with Colors

Value
Display
Color

PLANNED

Planned

dark-blue

UNPLANNED

Unplanned

orange

NOT_SCHEDULED

Not Scheduled

gray

UNKNOWN

No Reason

yellow

The state timeline shows colored bands for each downtime period.

[SCREENSHOT: State timeline panel]


Downtime Details Table

Show individual downtime events with full details.

Query Configuration

Use the basic query with all fields:

Join with Machine Names

Add a second query for machine names:

Query B:

Transformations:

  1. Merge

  2. Organize fields -> Reorder and hide machine UUID

Column Configuration

Column
Type
Special

start

Timestamp

dateTimeAsIso

end

Timestamp

dateTimeAsIso

duration_display

String

-

category

String

Value mappings

reason

String

-

machine_name

String

-

[SCREENSHOT: Downtime details table]


Summary Statistics

Add stat panels for quick KPIs.

Total Downtime Duration

Setting
Value

Visualization

Stat

Reduce

Sum

Field

duration

Unit

Duration (d hh:mm:ss)

Downtime Count

Add transformation -> Group by:

  • Group by: (none)

  • Aggregate: uuid -> Count

Setting
Value

Visualization

Stat

Field

uuid (count)

Title

Downtime Events

Unplanned Downtime Only

Add transformation -> Filter by value:

  • Field: category

  • Condition: equals "UNPLANNED"

Then calculate sum of duration.

[SCREENSHOT: Summary stat panels]


Multi-Machine Comparison

Compare downtime across machines.

Query with Machine Names

Join downtimes with machines query:

Query A (Downtimes):

Query B (Machines):

Transformations

  1. Merge (join on machine field)

  2. Calculate duration

  3. Group by: machine_name, Aggregate: duration -> Sum

  4. Sort by: duration (descending)

Visualization

Use a Bar Chart with:

  • X axis: machine_name

  • Value: duration (sum)

  • Unit: Duration (d hh:mm:ss)

[SCREENSHOT: Multi-machine downtime comparison]


Downtime Pareto Analysis

Identify the top reasons for downtime.

Transformations

  1. Calculate duration

  2. Filter by value -> category = "UNPLANNED" (focus on actionable downtimes)

  3. Group by: reason, Aggregate: duration -> Sum

  4. Sort by: duration (descending)

Visualization

Use a Bar Chart or Bar Gauge:

  • Sorted by duration (descending)

  • Top 10 reasons

This creates a Pareto-style view of the biggest downtime contributors.

[SCREENSHOT: Downtime Pareto analysis]


Complete Dashboard Layout

Row 1: Overview

  • Pie chart by category (6 units)

  • Total duration stat (6 units)

  • Downtime count stat (6 units)

  • Unplanned duration stat (6 units)

Row 2: Timeline

  • State timeline (24 units)

Row 3: Analysis

  • Duration by category bar gauge (12 units)

  • Top reasons bar chart (12 units)

Row 4: Details

  • Downtime details table (24 units)


Practical Exercise

Build a downtime reporting dashboard with:

  1. Variables:

    • Site dropdown (filter machines)

    • Machine dropdown (multi-select)

  2. Overview Section:

    • Pie chart by category

    • Three stat panels (total, count, unplanned)

  3. Timeline:

    • State timeline showing all downtimes

  4. Analysis:

    • Bar gauge by category

    • Top 10 reasons Pareto chart

  5. Details:

    • Full downtime table with machine names


Summary

You've learned to build downtime reports:

  • Query the downtimes endpoint with time filters

  • Handle ongoing downtimes (null end times)

  • Calculate duration using transformations

  • Visualise with pie charts, bar gauges, and state timelines

  • Create summary statistics

  • Perform multi-machine comparison and Pareto analysis


What's Next?

Part 4 Complete! Continue with:


Quick Reference

Downtimes Query URL

JSONata for Handling Null End Times

Duration Calculation Transformations

  1. Convert field type: start, end -> Time

  2. Add field: duration_ms = end - start

  3. Add field: duration = duration_ms / 1000

Category Value Mappings

API Value
Display
Color

PLANNED

Planned Downtime

dark-blue

UNPLANNED

Unplanned (Manual)

orange

NOT_SCHEDULED

Not Scheduled

#b0b7af (gray)

(empty)

No Reason

yellow

Duration Unit

Use dtdhms (Duration: days, hours, minutes, seconds) for downtime durations.

Group By for Aggregation

Purpose
Group By
Aggregate

Total by category

category

duration -> Sum

Total by reason

reason

duration -> Sum

Count by category

category

uuid -> Count

Last updated