oee.computeAPQ() function

The oee.computeAPQ() function is experimental and subject to change at any time. By using this function, you accept the risks of experimental functions.

The oee.computeAPQ() function computes availability, performance, and quality (APQ) and overall equipment effectiveness (OEE) using two separate input streams—production events and part events. oee.computeAPQ() is an aggregate function.

import "experimental/oee"

    productionEvents: exampleProductionScheme,
    partEvents: examplePartsStream,
    runningState: "running",
    plannedTime: 8h,
    idealCycleTime: 2m,

Output schema

For each input table, the oee.computeAPQ function outputs a table with a single row and the following columns:

  • _time: Timestamp associated with the APQ calculation.
  • availability: Ratio of time production was in a running state.
  • oee: Overall equipment effectiveness.
  • performance: Ratio of production efficiency.
  • quality: Ratio of production quality.
  • runTime: Total nanoseconds spent in the running state.



(Required) Production events stream that contains the production state or start and stop events. Each row must contain the following columns:

  • _stop: Right time boundary timestamp (typically assigned by range() or window()).
  • _time: Timestamp of the production event.
  • state: String that represents start or stop events or the production state. Use runningState to specify which value in the state column represents a running state.


(Required) Part events that contains the running totals of parts produced and parts that do not meet quality standards. Each row must contain the following columns:

  • _stop: Right time boundary timestamp (typically assigned by range() or window()).
  • _time: Timestamp of the parts event.
  • partCount: Cumulative total of parts produced.
  • badCount Cumulative total of parts that do not meet quality standards.


(Required) State value that represents a running state.


(Required) Total time that equipment is expected to produce parts.

Integer values represent nanoseconds.


(Required) Ideal minimum time to produce one part.

Integer values represent nanoseconds.


The following example uses two streams of data (productionData and partsData) and oee.APQ() to calculate the APQ and OEE of an eight hour production window.

Input data

_start _stop _time state
2021-01-01T00:00:00Z 2021-01-01T08:00:01Z 2021-01-01T00:00:00Z running
2021-01-01T00:00:00Z 2021-01-01T08:00:01Z 2021-01-01T04:03:53Z stopped
2021-01-01T00:00:00Z 2021-01-01T08:00:01Z 2021-01-01T04:24:53Z running
2021-01-01T00:00:00Z 2021-01-01T08:00:01Z 2021-01-01T08:00:00Z running
_start _stop _time partCount badCount
2021-01-01T00:00:00Z 2021-01-01T08:00:01Z 2021-01-01T00:00:00Z 0 0
2021-01-01T00:00:00Z 2021-01-01T08:00:01Z 2021-01-01T04:03:53Z 673 5
2021-01-01T00:00:00Z 2021-01-01T08:00:01Z 2021-01-01T04:24:53Z 673 5
2021-01-01T00:00:00Z 2021-01-01T08:00:01Z 2021-01-01T08:00:00Z 1298 13


import "experimental/oee"

productionData = // ...
partsData = // ...

    productionEvents: productionData,
    partEvents: partsData,
    runningState: "running",
    plannedTime: 8h,
    idealCycleTime: 21s,
    |> drop(columns: ["_start", "_stop"])

Output data

_time availability oee performance quality runTime
2021-01-01T08:00:01Z 0.9563 0.9370 0.9897 0.9899 27541000000000

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.