---
title: Use the Maintenance and Failure KPI
slug: manufacturing-connect-edge/use-the-maintenance-and-failure-kpi
docTags: 
createdAt: 2024-08-08T22:01:29.858Z
---

The **Maintenance and Failure** KPI mainly deals with the maintenance event and a fault/failure event in a production cycle.

For this KPI, two input definitions are required: `maintenance` and `failure`.

These are event triggers, indicating the event of the maintenance cycle and the discovery of a failure event, respectively.

# User Scenario

Review the following scenario for the maintenance and failure KPI processor. Then, using an input processor, you will simulate PLC data and calculate:

1. Total maintenance events per cycle
2. Total failure events per cycle
3. Time since last maintenance
4. Time since last failure
5. Timestamp of last maintenance
6. Timestamp of last failure

In a manufacturing setting, the maintenance and failure KPI can be used to monitor the performance of production machinery. For example, in a bottling plant, this KPI can track the number of maintenance events and machine failures during the production cycle. By analyzing this data, the plant can determine the average frequency of maintenance, identify any trends in machine failures, and schedule preventive maintenance to reduce downtime. This helps in optimizing production efficiency and minimizing disruptions.

# Step 1: Add a Device

Follow the steps to [Connect a Device](docId\:nm1lQfefyA-DSIfFitIty) and configure the following parameters:

- **Device Type**: Simulator
- **Driver Name**: Generator
- **Enable Alias Topics**: Select the checkbox.&#x20;

# Step 2: Add Tags

After connecting the device, add the following tag. See [Add a Tag](docId\:h5heqIcXrCY3NCH9KBg9I) to learn more.&#x20;

## Tag 1: maintenance

- **Name**: Select **S - Random value generator.**
- **Value Type:** Select **float64.**
- **Polling Interval**: Enter **1.**
- **Tag Name**: Enter **maintenance.**

## Tag 2: failure

- **Name**: Select **S - Random value generator.**
- **Value Type:** Select **float64.**
- **Polling Interval**: Enter **1.**
- **Tag Name**: Enter **failure.**

# Step 3: Create Analytics Flow

You can now create the analytics flows using data from the device and tag you previously created.&#x20;

**To create an analytics flow with the Maintenance and Failure Processor function:**

1. In Manufacturing Connect Edge, navigate to **Analytics**.&#x20;
2. On the analytics canvas, click **Add processor**.
   The *Create a processor* dialog box displays.
   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/jveLq8ibLOFpblEe0a5Rv_image.png" size="80" width="800" height="305" position="center" caption="The Add processor option" showCaption="true"}
3. Select **DataHub Subscribe**.
4. In the *Topic&#x20;*&#x66;ield, click the **Search&#x20;**&#x69;con, select the device you previously created, and then select the alias topic for tag1: **maintenance**.
   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/phqeiM38R27qyIb2vIKhj_image.png" size="80" width="800" height="400" position="center" caption="Create a Processor dialog box" showCaption="true"}
5. Click **Save**.
6. Repeat steps 2-5 to add another *DataHub Subscribe* processor for the **failure&#x20;**&#x74;ag.
   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/mETbXPhDDUjvWHDCeVND7_image.png" size="50" width="382" height="251" position="center" caption="Flows Canvas" showCaption="true"}
7. Click **Add processor** again and select the **Maintenance and Failure** processor.
   The following information defines this function:
   - **Maintenance From & Maintenance To:** If your input changes *Maintenance From* value to *Maintenance To* value, it will trigger a maintenance cycle.
   - **Failure From & Failure To:** If your input changes *Failure From* value to *Failure To* value, it will trigger a failed cycle.
   - **Unit:&#x20;**&#x45;nter the time unit to display time since last maintenance or failure event.
   - **TimeInterval:** If the tag publishes at the expected interval, it is better to disable this timer by entering **0** in the field.
   - Click **Save**.
     ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/sPpTl3NXNtBQWpLTS5ams_image.png" size="80" width="1131" height="747" position="center" caption="Edit a Processor dialog box" showCaption="true"}
8. Connect the *DataHub Subscribe* processor (tag: *maintenance*) to the *Maintenance and Failure* processor with a wire. Use the **Events** connection and enter a definition of **maintenance&#x20;**&#x66;or the connection.
9. Repeat step 8 for tag: *failure&#x20;*&#x61;nd enter a definition of **failure&#x20;**&#x66;or the connection.
10. On the analytics canvas, click **Save**.

The configured analytics flows should look like the following:

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/Lafh87-x06b0xNWRCcyAe_image.png" size="80" width="655" height="275" position="center" caption="Completed flows canvas" showCaption="true"}

# Step 4: View Output of Processor

Click the **View&#x20;**&#x69;con in the *Maintenance and Failure* processor to view the output values.

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/vWuxf7n13nlrZCbkN9sAC_image.png" size="80" width="1323" height="412" position="center" caption="Output of Maintenance and Failure processor" showCaption="true"}

