How-To

Grafana Open-Source Data Viz Solution, Part 2: CSV Support

In a previous article, I looked at Grafana, a free, open-source data visualization tool. In the past, I tried (and failed) to use it to create a simple graph using CSV files, which is a bit of an underuse of Grafana as its true strength lies in visualizing real-time data with its dynamic dashboards. However, I recently discovered a plugin that has CSV support, so I will use it to create my bar chart in this article.

Obviously, writing a few articles on how to create a bar chart would not be a good way to demonstrate Grafana's power. So, in other articles, I will explore its true power and why market-leading companies like eBay and NVIDIA use it.

Grafana Data Sources
Once I had Grafana installed, I needed data to visualize on its dashboard. Grafana uses data sources that contain the raw information necessary to create the visualizations.

Grafana has dozens of data source connectors, including many popular databases, cloud sources, and monitoring solutions. Some are listed as "core" and preinstalled, while others use Enterprise plugins requiring the enterprise version of Grafana.

[Click on image for larger view.]

In my case, I just wanted to use a CSV file. Unfortunately, Grafana does not include CSV as a default data source, so I needed to scroll down to the bottom of the Data Source screen, click Find more data source plugins, and search for CSV. Two plugins were displayed: CSV and Infinity. I have tried and failed to use the CSV plugin in the past, so I installed the Infinity plugin, which supports JSON API, TSV, XML, GraphQL, HTML, Google Sheets, and HTTP/REST API, as well as CSV data sources.

[Click on image for larger view.]

Using CSV with Grafana
To test it, I created a CSV file (TJF-Temp_Hum) with a few rows of data.

After installing the Infinity plugin, I returned to the Home page and selected Add your first data source.

[Click on image for larger view.]

I then entered Infinity in the search text box.

I gave the data source a new name (TJF-Temp_Hum) and clicked Save and Test. It said no issues were found, so I clicked Explore View. I set the Type to CSV, the Parser to Backend, and the Source to Inline. I then selected and clicked Upload file and selected the file with my CSV data. The CSV data from the file was shown in the upper pane.

[Click on image for larger view.]

I then needed to define my data type, so I expanded the Parsing options and Result pane. In the Column Name and Title text boxes, I entered Timestamp, and in the format drop-down menu, I selected Time. I selected Add Columns and completed the same process for the Temp and Hum columns but gave them a value of number.

[Click on image for larger view.]

From the graph type drop-down menu, I selected Suggestions and then selected Time series.

I selected Apply in the upper right and saw a bar graph of the data.

[Click on image for larger view.]

NOTE: To get the data to work, I needed to label the CSV data for each of the columns that I used (Create, Temp, Hum) and reformat the data in the date column to one that was recognized by the Infinity plugin.

NOTE: Make sure you use the Time Range drop-down menu to select a time for your data or you will not see anything.

To title and save the dashboard, I clicked the Settings icon, gave it a name, and clicked Save Dashboard.

To see this graph, I went to the navigation menu, selected Dashboards, and selected the dashboard I just created.

Creating such a simple graph Using Grafana may seem overly complicated. I could have made an Excel spreadsheet to display the same information in a minute or two. The real power of Grafana is that you can easily create dashboards with multiple visualization panels that update dynamically using various data sources.

For example, it took me less than two minutes to create and add gauges to this dashboard to show the maximum and minimum temperature and humidity values.

[Click on image for larger view.]

A Bigger Cloud-Based Data Set
In my last example, I demonstrated Grafana using a local CSV data set with less than a dozen rows of data. In this example, I will use three months of data stored in a spreadsheet in the cloud. Specifically, I will use temperature and humidity data collected every 15 minutes from my server room and stored in Google Sheets.

From this data, I will create a dashboard that looks like this.

[Click on image for larger view.]

I used the Google Spreadsheet plugin to connect to the spreadsheet. I followed the plugin's documentation to set up the credentials for the Google Sheets API without any issues.

[Click on image for larger view.]

I then supplied the connector with the spreadsheet ID (the number after the "/d/" in the URL of the Google Sheet) and set the time, temperature, and humidity fields like I did when I created a dashboard using the Infinity plugin in my previous example.

[Click on image for larger view.]

I followed the same techniques as in my previous example to create a time graph panel and gauge panels to show the entire data set's maximum and minimum temperature and humidity. Using the time range drop-down menu, I selected the time range to be displayed.

[Click on image for larger view.]

By default, the gauge wizard uses the entire data range, so you must click Use Time Filter when configuring the gauges to show the maximum from the displayed time range rather than the whole dataset.

[Click on image for larger view.]

I created this dashboard in less than five minutes using a cloud-based (Google Sheets) data source. I was now starting to use Grafana's power and flexibility.

I was glad I discovered the Infinity data source plugin and found Grafana easy to install to create a dashboard displaying the temperature and humidity values. However, I also realized that using Grafana for this task was a bit overkill for what I wanted to do. Grafana's real power is using dynamic data to display real-time information, making it easy to visualize and consume. In my next article, I will use it for purposes that align with what it was developed for: real-time monitoring of my laptop.

About the Author

Tom Fenton has a wealth of hands-on IT experience gained over the past 30 years in a variety of technologies, with the past 20 years focusing on virtualization and storage. He previously worked as a Technical Marketing Manager for ControlUp. He also previously worked at VMware in Staff and Senior level positions. He has also worked as a Senior Validation Engineer with The Taneja Group, where he headed the Validation Service Lab and was instrumental in starting up its vSphere Virtual Volumes practice. He's on X @vDoppler.

Featured

Subscribe on YouTube