0

Grafana 6.x/7.x versions, especially version 7.x

If I have the following data in an Elasticsearch Index (<--Grafana: which it refers) or flat file (csv)

Sprint Velocity:    10  20  15  35  22
--------------------------------------
Sprint Name:        S1  S2  S3  S4  S5
Sprint Number:      1   2   3   4   5

Then, in Grafana, is it possible to show Velocity field on Y axis and either Sprint Name/Number on X axis (which are non-date-time based fields).

In ELK (Kibana GUI), I have a visualization which points to an Elasticsearch Index via Index-Pattern (for the above data) and I can easily render/show a LINE visualization having X axis (Terms: using Sprint Name or Sprint Number).

I'm trying to achieve the same in Grafana but having hard time. https://grafana.com/grafana/plugins/natel-plotly-panel didn't help either as it's supported only up to version Grafana 6.

Also, if I use the "series" option, it doesn't allow the points to be connected in the graph since Grafana thinks they all separate series. For ex: If I use this approach: https://github.com/gipong/grafana-groupedbarchart-panel I can't get one metric (Velocity) on Y axis as LINE chart and another metric (TotalSprintPoints) on Y axis as a BAR chart.

AKS
  • 16,482
  • 43
  • 166
  • 258
  • Grafana is for time series data primarily and you will have a hard time if you don't have time dimension. – Jan Garaj Nov 04 '20 at 08:42
  • A user can try setting the x-axis value to display the `series` instead of time. In Grafana v6.7.x, you can find that option in the Visualization tab (under X-axis, select `mode` as `Series`) – AKS Nov 16 '20 at 18:55
  • **One other way** is mentioned here for grouped charts: https://github.com/gipong/grafana-groupedbarchart-panel – AKS Nov 16 '20 at 22:39

2 Answers2

0

@AKS your example is really information did you tired with line chart ? I can follow your steps for bar chart etc when I move to line its not working. Also I like to show 4 different line in the chart but I am getting only one.

Rajmahendra
  • 3,092
  • 3
  • 31
  • 42
  • Welcome to Grafana. That's why I selected ELK Kibana. What exactly happens when you change from bar to line, it should actually show line, unless you have 4 Y axis lines and Grafana version you are using may not support that. – AKS Nov 03 '21 at 20:00
-1

In Grafana, there are few possibilities (but it requires some leg work). A user can use MySQL (as the data source) to visualize non-time series data on X axis. One can use PostgreSQL as well. For more info, read the blog below. Thanks for Sean Bradley.

https://medium.com/grafana-tutorials/graphing-non-time-series-sql-data-in-grafana-8a0ea8c55ee3

Grafana can graph Time Series data from many different types of data sources extremely well. But sometimes you just want to graph, simple non time series data. i.e. Data without timestamps, flat tables with regularly updated statistics or just simple lookup tables.

Example Non Time Series data as a flat table.

enter image description here

And you want to see this simple data, as graphs similar to below. enter image description here

Grafana needs Time Series data to create graphs, so this is not immediately possible from Non Time Series data, but there is a way, and it's shown below, how you can do it.

To test this yourself, you should have a MySQL database and create a Data Source connection to it in Grafana. If you don’t have a MySQL database, but you do have a Grafana Server, then you can follow the instructions at https://sbcode.net/grafana/create-mysql-data-source/ to quickly install yourself a MySQL server and configure a MySQL data source inside Grafana.

Now to organize a simple flat table with some non time series data it.

On my MySQL server, we can have a schema named exampledb. In it let's create a table called flat_table_example

Open a MySQL prompt on your server, and create a table with this script

CREATE TABLE `exampledb`.`flat_table_example` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(45) DEFAULT NULL,
  `total` decimal(10,0) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;

Now, let's insert some data:

INSERT INTO `exampledb`.`flat_table_example`
(`username`,
`total`)
VALUES
('Cat',56),
('Dog',5),
('Lizard',4),
('Crocodile',2),
('Koala',50),
('Cassowary',2),
('Peacock',1),
('Emu',1),
('Kangaroo',1);

To check if the data exists, run the following:

SELECT * FROM ``exampledb`.`flat_table_example`;

**Now**, Open up your **Grafana UI**, **ensure** your **MySQL Data Source** has been **configured and connects**, then go to the Explore Tab.

Choose your MySQL data source, press the Edit SQL button enter image description here

Replace the default SQL with this below,

SELECT username AS metric, total as value FROM flat_table_example ORDER BY id

And select Format As = Table to see your data as a table inside Grafana. enter image description here

Now, this data is not Time Series data, it has no timestamp columns, so Grafana will not know how to graph it. So here is the trick,

Modify the SQL statement to be,

SELECT NOW() AS "time", username AS metric, total as value FROM flat_table_example ORDER BY id

And now the data has been converted to Time Series. Now, all rows have time stamps, are identical and update to show now every time the query is executed. You may think this is wrong, but it’s not, it’s perfect. enter image description here

Grafana can now graph this data as a pretty graph.

Leave the Explore page now, go to Manage Dashboards, create a New Dashboard and Add Query

Select your MySQL data source, press the Edit SQL button just like before, paste the new SQL script into the text area. But this time, leave Format As = Time Series instead of Table enter image description here

Now go to visualisation, select Bar Gauge. Straight away, you have this below. enter image description here

You can select Orientation = Horizontal, and Field Unit = Percent (0-100) enter image description here

You can select the basic Gauge visualisation to get this result below, and add yourself an extra Threshold enter image description here

And even select the default Graph visualisation, but ensure you also select X-Axis Mode = Series enter image description here

Video Tutorial To see this video tutorial on Viewing Non Time Series Data in Grafana then visit, https://youtu.be/Q6aw9oInsyw

Special Thanks to Sean B.

One other way is mentioned here for grouped charts: https://github.com/gipong/grafana-groupedbarchart-panel

AKS
  • 16,482
  • 43
  • 166
  • 258
  • 1
    The question was to have a line graph with Non Time series X Axis. – Shyam V Aug 12 '22 at 07:55
  • yes, and I tried both, both tools worked but we went with Kibana, easy to implement when it comes to non tsdb entries X axis especially when dealing with multiple Y axis projections on widgets/visualizations/dashboards charts. Last chart shows non-timeseries X axis in Grafana, you can change the type from Bar to Line easily but if you have Y1 as bar and Y2 as a line or Y3 as bar, that's when magical errors showed up. – AKS Oct 26 '22 at 23:53