Skip to main content
Skip table of contents

Grafana Integration

How to create OEE dashboard for a device

Introduction

This document provides a step-by-step guide for integrating Grafana with your SICON.OS devices for real-time data visualization. By leveraging the power of Grafana, you can transform your device data into more meaningful insights as per your requirements.

This integration involves three main parts:

  1. Setting up InfluxDB with your SICON.OS data

  2. Setting up Grafana with InfluxDB

  3. Grafana Visualization by creating different panels

Flow diagram:

image-20241015-101427.png

Follow the instructions carefully to ensure a smooth and efficient setup.

Part 1 : Setting up InfluxDB with your SICON.OS data

Following are the steps to setup the InfluxDB with your SICON.OS data:

  1. Go to your SICON.OS and navigate to the App Store. Now install the Data Relay App.

image-20241015-122156.png

  1. Once the app is installed, navigate to the side panel “Data Relay“ and then click on ADD DATA RELAY

    image-20241015-123226.png

  2. Select InfluxDB and click on CREATE.

image-20240628-103850.png

4. In order to create a connection with InfluxDB, you will need the following details to fill in:

  • Endpoint

  • Bucket Name

  • API Tokens

  • Organisation detail

4.1 Endpoint: It will be your InfluxDB URL.

Ensure you have it ready for the configuration.

4.2 Bucket Name: You must create a bucket where data will be pushed to.

i) Login to the InfluxDB server with your Username and Password.

image-20240627-074734.png

ii) Go to Buckets.

image-20240628-110438.png

iii) Click on “Create Bucket

image-20240627-074357.png

iv) Give the bucket a name and click on “save”. For example - “my.cloud-bucket

image-20240627-074438.png

Keep the same bucket name with you for later configuration.

For example - “my.cloud-bucket .

4.3. For API tokens :

i) Go to InfluxDB. Navigate to the Side menu. Click on “API tokens”

image-20240628-105327.png

ii) Click on “Generate API token” > “Custom API Token

image-20240627-094334.png
image-20240628-105555.png

iii) Give it a suitable token name in description, select your bucket from the bucket list and tick ☑️ the write checkbox and click on “Generate”.

image-20240628-105741.png

iv) Token will be generated, copy it and store it for configuration later.

4.4. For Organisation : Check the Organisation by clicking on the left side icon.

For example - here we see the organisation is “admin“. Keep it with you for configuration later.

image-20240628-110123.png
  1. Now go to your SICON.OS > Data relay > Click on the “setting icon” ⚙️ and go to Settings page and fill the input from the above steps.

image-20240628-104012.png
image-20241029-112059.png

  1. Click SAVE Icon to save the above settings.

image-20240627-075138.png

[Note: You can create only 1 Data Relay per InfluxDB]

  1. Now go to SICON.OS > data relay > devices and it will show all available devices.

image-20240628-112045.png

  1. Tick the checkbox ☑️ for the device you want to connect and click on CONNECT SELECTED

image-20240628-112234.png
  1. Now, the device should show “Connected“ in Data Relay column.

  2. Verify if the connection was successful by going to InfluxDB Dashboard and click on “buckets”

example: my.cloud-bucket

image-20240628-110438.png
image-20240627-075308.png
  1. Now you can see the data for example - Reports or Events in our case.

  2. Select custom and untick the mean option.

Note:- On bottom right side, we have aggregation function activated by default which should be modified to custom and untick mean (if it was selected previously).

image-20240628-110833.png
  1. On top right side, you can select “Simple Table“ from the dropdown options of visualization and click “submit” and now you see the data values.

image-20240627-075731.png

If we see data in the above step, it means our connection was successful.


Part 2: Setting up Grafana with InfluxDB and Visualization

  1. Login to “Grafana”.

image-20240627-074555.png
  1. Go to Connections > Add new connection

image-20240627-080514.png
  1. Search for “InfluxDB”.

image-20240627-080600.png
  1. Click on “Add new data source

image-20240627-081128.png
  1. Give a suitable name for InfluxDB connection.

image-20240627-095950.png
  1. In Query Language, select “Flux” from the dropdown list.

image-20240627-100011.png
  1. Enter the InfluxDB URL -

image-20240627-100049.png
  1. In Auth, select “Basic auth” and enter the username and password for InfluxDB.

image-20240627-100126.png
  1. In InfluxDB details -

    1. Organisation - Use this Organisation name same as we used in Part 1 - Step 4.

      image-20241029-113459.png

    2. Token -

      1. Go to InfluxDB > API Tokens > Generate new token.

        image-20240628-105352.png
      2. Click on “All Access API Token” and give it a suitable name, copy it and “save” it.

        image-20240627-094334.png
        image-20240627-094937.png

iii. Paste it in the token field in the configuration.

image-20240627-100211.png
  1. Click on Save and Test. It should show connection successful.

image-20240627-095901.png

Now, we are ready to create visualizations on Grafana

=====================================================================

Part 3: Grafana visualization by creating different panels

  1. Go to Dashboard and click new Dashboard

image-20240627-101403.png
  1. Click on save icon on top and give it a suitable name and click on save

image-20241029-114003.png
image-20241029-113907.png

We will see two examples on how to create visualization on Grafana.

Example 1 - Number of cycles

image-20240904-104642.png

i) Go to InfluxDB, and click on “Buckets”, select the bucket you have created and then select the data for Visualization with the help of checkbox

image-20240628-110438.png
image-20240904-104924.png

ii) Click on Script Editor and copy the query

image-20240904-105006.png

iii) Go to Grafana Dashboard and on top you will find “Add“ dropdown and then select Visualization.

image-20240627-102556.png

iv) Paste the query

image-20240904-120225.png

v) On top right, choose the type of visualization you want - (Table, Stat, Gauge, etc)

(For example - choose Stat to show the number of cycles)

image-20240904-122910.png

vi) Give it a suitable name and save it

image-20240904-123730.png

Example 2 - Running Time visualization

image-20240904-130812.png

i) Go to Grafana Dashboard and on top you will find “Add“ dropdown and then select Visulaization.

image-20240627-102556.png

ii) In the query section, paste the below flux query

Remember to change the bucket name in the query below -

JS
import "strings"
 
statuses = ["running", "off", "idle", "changeover", "maintenance", "defect/fault"]
 
data = from(bucket: "bucket.my.cloud")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "4C11AEE15B5C-events")
  |> drop(columns: ["code"])
  |> filter(fn: (r) => r["_field"] == "message")
  |> filter(fn: (r) => strings.containsStr(v: r._value, substr: "running")
      or strings.containsStr(v: r._value, substr: "off")
      or strings.containsStr(v: r._value, substr: "idle")
      or strings.containsStr(v: r._value, substr: "changeover")
      or strings.containsStr(v: r._value, substr: "maintenance")
      or strings.containsStr(v: r._value, substr: "defect/fault"))
  |> map(fn: (r) => ({r with _status: if strings.containsStr(v: r._value, substr: "running") then "running"
                        else if strings.containsStr(v: r._value, substr: "off") then "off"
                        else if strings.containsStr(v: r._value, substr: "idle") then "idle"
                        else if strings.containsStr(v: r._value, substr: "changeover") then "changeover"
                        else if strings.containsStr(v: r._value, substr: "maintenance") then "maintenance"
                        else "defect/fault"}))
  |> sort(columns: ["_time"])
  |> elapsed(unit: 1s, timeColumn: "_time")
  |> group(columns: ["_status"])
  |> sum(column: "elapsed")
  |> map(fn: (r) => ({r with total_duration_seconds: r.elapsed}))
  |> drop(columns: ["elapsed"])
 
data
  |> pivot(rowKey:[], columnKey:["_status"], valueColumn: "total_duration_seconds")
  |> map(fn: (r) => ({
      running: if exists r.running then r.running else 0,
      off: if exists r.off then r.off else 0,
      idle: if exists r.idle then r.idle else 0,
      changeover: if exists r.changeover then r.changeover else 0,
      maintenance: if exists r.maintenance then r.maintenance else 0,
      defect_fault: if exists r.defect_fault then r.defect_fault else 0
  }))

and it looks like this -

image-20240904-131552.png

iii) Select the Gauge visualization for this from the right side

image-20240904-131232.png

iv) Scroll down to “Standard options” and then “in the unit dropdown menu - select the appropriate unit

image-20240904-124208.png

And as this query is returning multiple values -

Total time of ["running", "off", "idle", "changeover", "maintenance", "defect/fault"]

We can select the time we want to visualize. Here we need to select running time.

v) In the right side option, scroll down to Value Options

In the field section, select - running

image-20240904-131949.png

vi) Now, you are getting the total running time of the device. Click on Save

image-20240904-132113.png

And the output will look like this -

image-20240904-130812.png

===============================================================

Similarly, other panels for visualization can be added in a similar way and after adding all the visualization you want - the complete dashboard will look like this -

image-20241028-135755.png

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.