Grafana+Zabbix: Visualizing the Operation of the Production Line

In this article, I want to share my experience using the open-source systems Zabbix and Grafana for visualizing the operations of production lines. This information may be useful for those seeking a quick way to visually display or analyze collected data in industrial automation or IoT projects. The article is not a detailed guide; rather, it provides a conceptual overview of a monitoring system based on open-source software for manufacturing enterprises.

Toolset

Zabbix – we have been using this for monitoring the IT infrastructure of the factory for a long time. The system turned out to be so convenient and versatile that we started inputting data from production lines, sensors, and controllers into it. This allowed us to consolidate all metric data in one place, create simple graphs of resource consumption and equipment performance, but we really missed analytics and attractive graphs.

Grafana – this is a powerful tool for data analytics and visualization. A large number of plugins allow you to pull data from various sources (Zabbix, Clickhouse, InfluxDB), process it on the fly (calculate averages, totals, differences, etc.), and produce a variety of graphs (from simple lines, speedometers, tables to complex diagrams).

Draw.io – a service that allows you to create anything from a simple flowchart to a floor plan in an online editor. There are many ready-made templates and drawn objects. You can export data in all major graphic formats or XML.

Bringing it all together

Many articles on how to install and configure Grafana and Zabbix have been written; I will cover the main configuration points.

In Zabbix server a 'network node' (host) is created, which will have 'data items' (item) containing metrics from our sensors. It is advisable to carefully plan the names of nodes and data items to make them as structured as possible, as we will reference them from Grafana using regular expressions. This approach is convenient because it allows us to retrieve data from a group of items with a single query.

To configure Grafana, it will be necessary to install additional plugins:

  • Zabbix by Alexander Zobnin (alexanderzobnin-zabbix-app) – integration with Zabbix
  • natel-discrete-panel – a plugin for discrete visualization on a horizontal graph
  • pierosavi-imageit-panel – a plugin for displaying data over your image
  • agenty-flowcharting-panel – a plugin for dynamic visualization of diagrams from draw.io

The integration with Zabbix is configured in Grafana under the menu item ConfigurationData sourcesZabbix. You need to specify the address of the Zabbix server API, which for me is http://zabbix.local/zabbix/api_jsonrpc.php, and the username and password for access. If everything is done correctly, when saving the settings there will be a message with the API version number: zabbix API version: 5.0.1

Creating a Dashboard

This is where the real magic of Grafana and its plugins begins.

Plugin natel-discrete-panel
We have data about the engine statuses on the lines (running = 1, not running = 0). With the discrete chart, we can create a scale that shows: engine status, how long it has run in minutes/hours or %, and how often it has been started.

Grafana+Zabbix: Visualizing the Operation of the Production Line
Visualization of engine statuses

In my opinion, this is one of the best charts for visualizing equipment performance. You can immediately see how much downtime there is, and in which modes it operates more frequently. There can be a lot of data, and it is possible to aggregate them by ranges, transforming values (if the value is '1', display as 'ON')

Plugin pierosavi-imageit-panel

Imageit is convenient to use when you already have a drawn diagram or layout of a room onto which you want to overlay data from sensors. In the visualization settings, you need to specify the URL address to the image and add the necessary sensor elements. The element appears on the image, and you can place it where you need using the mouse.

Grafana+Zabbix: Visualizing the Operation of the Production Line
Diagram of the furnace with temperature and pressure metrics

Plugin agenty-flowcharting-panel

I would like to talk more about creating FlowCharting visualizations, as it is an incredibly functional tool. It allows you to create a dynamic mnemonic scheme, the elements of which will react to metric values (changing color, position, name, etc.).

Retrieving data

Creating any visualization element in Grafana starts with querying data from a source, in this case, Zabbix. Using queries, we need to retrieve all the metrics that we want to use in the diagram. The credentials for the metrics are the names of the data items in Zabbix. You can specify either a single metric or multiple ones filtered through a regular expression. In my example, the Item field contains the expression: "\/(^line 1)|(availability)|(zucchini)\/" — this means to select all metrics whose names strictly start with "line 1" or contain the word "availability" or the word "zucchini".

Grafana+Zabbix: Visualizing the Operation of the Production Line
An example of setting up a data query for the first line engines and the availability of raw materials.

Data Transformation

The input data may not always be in the format we need to display. For example, we have minute-by-minute data on the weight of a product in a container (kg), and we need to display the filling rate in t/h. I do this as follows: I take the weight data and transform it using Grafana's delta function, which calculates the difference between the metric values. Thus, the current weight is converted to kg/min. Then, I multiply by 0.06 to convert the result to tons/hour. Since the weight metric is used in multiple queries, I specify a new alias for it (setAlias) and will use it in the visualization rule.

Grafana+Zabbix: Visualizing the Operation of the Production Line
An example of using the delta parameter, multiplier, and renaming the metric in the query.

Here's another example of data transformation: I needed to count the number of cycles (cycle start = engine start). The metric is calculated based on the status of the engine "line 1 — pump draining from tank 1 (status)". The transformation: we change the original metric data using the delta function (difference of values), thus the metric will have a value of "+1" for engine start, "-1" for stop, and "0" when the engine does not change its status. Then, I remove all values less than 1 and sum them. As a result, we get the number of engine starts.

Grafana+Zabbix: Visualizing the Operation of the Production Line
An example of transforming data from the current status into the number of starts.

Now about the visualization itself.

In the display settings, there is an "Edit Draw" button, which launches the editor where you can draw the diagram. Each object in the diagram has its own parameters. For example, if you specify font settings in the editor, they will be applied to the data visualization in Grafana.

Grafana+Zabbix: Visualizing the Operation of the Production Line
This is what the editor looks like in Draw.io

After saving the diagram, it will appear in Grafana, and you can start creating rules for changing elements.

In the parameters () we specify:

  • Options — sets the rule name, the name or alias of the metric whose data will be used (Apply to metrics). The type of data aggregation (Aggregation) affects the final result of the metric; for example, Last means the last value will be selected, avg means the average value over the period selected in the top right corner.
  • Thresholds — a parameter for threshold values that describes the logic of color application, meaning the selected color will be applied to elements in the diagram based on the metric data. In my example, when the metric value is "0" — the status "Ok" will be green, and when the value is ">1" the status will be Critical and the color will be red.
  • "Color/Tooltip Mappings" and "Label/Text Mappings" — choosing the diagram element and its behavior scenario. In the first scenario, the object will be filled with color, while in the second, it will have text with data from the metric. To select an object in the diagram, you need to click the chain icon and then click on the diagram.

Grafana+Zabbix: Visualizing the Operation of the Production Line
In this example, I'm coloring the pump and its arrow red if it’s running and green if it’s not.

Using the flowcharting plugin, I was able to draw a diagram of the entire line, which includes:

  1. the color changes of the aggregates according to their status
  2. an alert for the absence of product in the tanks
  3. displaying the setup of engine frequencies
  4. the filling/dumping speed of the first tank
  5. counting the number of cycles of the line's operation (mixtures)

Grafana+Zabbix: Visualizing the Operation of the Production Line
Visualization of the production line operation

Result

The most challenging part for me was getting data from the controllers. Thanks to the versatility of Zabbix in terms of data retrieval and Grafana's flexibility with plugins, it took just a couple of days to create a comprehensive monitoring screen for the production line. The visualization provided the ability to view graphs and status statistics, plus easy web access for all interested parties — all of which allowed for quick identification of bottlenecks and inefficient use of aggregates.

Conclusion

I really liked the combination of Zabbix and Grafana, and I recommend considering it if you need to quickly process data from controllers or sensors without programming or implementing complex commercial products. Certainly, it won't replace professional SCADA systems, but it will be sufficient as a tool for centralized monitoring of the entire production process.

Source: habr.com

Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster