Grafana and MS SQL database monitoring

Hi team, I have grafana setup and would like to monitor an sql server health.
I have added MSSql as datasource and created a dashboard but I’m getting the error : Network error , bad gateway (502)
Anyone can help ?

Please tell us precisely what you entered for the MsSQL data source (I don’t
mean passwords, but specifically the server name / URL).


In the host fileld , I put the sql server FQDN.
I have attached datasource configuration, as you can see database connection is ok .
But when I open the dashboard , I got the error message "Bad Gateway , error 502).
Also , I think what is missing is the instance field , I don’t know what to put in their.
Sorry I have just started working on grafana .


Any help community will be appreciated. Thanks

What is your variable config?
I saw that the variable is empty.
Perhaps you need to check the variable first…

Hi, what you mean by variables , Instance ?
I have added the server\instance and still having the same issue.

If the server/instance is shown up, I think you need to check the panel query of the variable.
What is the variable name?
Is it possible to show the one of the panel query? Just to make sure the query was correct.

Thanks ,
I found that I have a default sql query.
I’m not an sql DB expert, is there a way to monitor a SQL server without Sql query skills. ?
as value,
as metric

WHERE $__timeFilter(time_column) ORDER BY ASC

In this query, you didn’t put the variable, so, even you have the variable and not put into the Panel Query, it mean the query will get all the data as in the query and time range.
I suggest you put the variable in the WHERE clause with this format

some_field IN $<variable_name>
AND $__timeFilter(time_column) ORDER BY ASC

Why with IN, it will cover if you use ALL or multiple values in the variable.
Just try in one panel one at a time.
The bad gateway shown because the database is too long to response because no limitation in WHERE clause in the query, I assume…

I have an issue with the script can’t get it working.
Did you know what is the best way to monitor an SQL server using grafana without having to Query a database directly.

No direct answer, I’m affraid…

As my experience, I just use Metricbeat and send it to Elasticsearch cluster, then monitor it with Grafana without problem. Not just the Database metrics it self, also the metrics of the server and availability.
This environment need not just metricbeat, also heartbeat to have availability, auditbeat to have security audit.