What to show when the panel is without data

It could happen that due to the time range control the panel is without any data.
In this case the panel usally is not very pleasant, empty with wrong labels.
Is there a way to show something better instead? Like a string “empty data”?

Thank you.

depends on the panel in question. What visualization panel, with what datasource, and what exactly is the datasource request returning? Undefined, NaN, null, error?

then you can add value mapping for special value like NaN:

It returns an empty SQL Server query, no error, no NaN. Simply one query with Count(*) == 0.
Thanks.

@matteodt please provide the following

version of grafana
what os it is installed on
visualization you are using (is it time series, time line, bar graph)

help us help you. :wink:

1 Like

OS: Windows 10
Grafana 8.0.5
Data source: SQL Server
Visualization: time series (but is a problem occurring with every plot)

More clearly, I have a query that if I do

EXISTS(query)

it results false.

How to make the graph more appealing if I have no rows?

Thanks

what does the visualization look like now that you find not appealing? Can you post a screenshot?

try switching your query to the Table view. It appears that you don’t have a time field, which the time series panel looks for

Yes, I understand this, I have no results from the query. I have an empty recordset. But this happens easily if the time range interval does not have any data in the table for that time.
Is there a way to show something other when I haven’t any results on the query?
Thanks

maybe do a fake union?

--this first query returns no rows
SELECT
  DATEDIFF(second, '1970-01-01', GETDATE()) AS time,
  population as value,
  city as metric
 FROM [dbo].[uscities]
  where city = 'fake'
union 
--this next one returns something so that the timeseries does not say
--Data does not have a time field.
SELECT DATEDIFF(second, '1970-01-01', GETDATE())  as time,
       0 value,
	   '' metric
ORDER BY 1 ASC	

1 Like

Yes this could be a solution, but I should add some clutter to just under a hundred of queries.
I was wondering myself if Grafana has some way to handle automatically queries that results in an empty dataset, I think this is a fairly common scenario.
Thanks.

1 Like

Agreed, does not scale well. I think you should submit a feature request. Also inline sql is a nono in my book for exactly this reason. Use stored procedures or views even better. Then you can make wholesale changes to these view with minimal impact on dashboards. Also remember a dashboard is just json and you could inject the union programmatically . But the better option is if grafana handled nobdata more gracefully

1 Like