Best way to get data from SQL server to Grafana


#1

I have data from SQL server that needs to be queried from multiple tables and display that data in a graph in grafana. What is the best way to do this? Build a RESTful service in visual studio that gets data and put it to grafana? If so I don’t see any grafana nuget package for grafana. Any suggestions would be much appreciated.


#2

Ether build a REST interface that is compatible with one of the supported Grafana datasources (for example Graphite API compatible).

Or store your data in InfluxDB then have grafana query influxdb.,


#3

Or build a simple backend for the Simple JSON datasource:

Here is an example of a backend built in node and it should be fairly easy to do it in C#/.NET:


#4

Hey,

I’m fairly new to this. I couldn’t find any example that use fake-simple-json-datasource in C#/.NET. Do you think you can point me in the right direction as how to implement this? Thank you.


#5

EDIT- Nevermind, I had to reinstall the service and SimpleJson shows as the data source. However, my above question still remains.

/Also, I extracted the simple json datasource into /data/plugins and I see that in the plugins when I go to the server but not as a data source? I’m using these instruction. Also, this “grafana-cli plugins install grafana-simple-json-datasource” command wouldn’t work which is why I extracted the files into the plugin folder/


#6

There is no example in C#/.NET that I know of. But this would be a really simple MVC app. It needs 4 routes (or 3 routes if you skip annotations).

/ should return 200 ok. Used for “Test connection” on the datasource config page.
/search used by the find metric options on the query tab in panels.
/query should return metrics based on input.
/annotations should return annotations.

The json that the query, search and annotations route should return is documented in the readme.

Did you get stuck on anything in particular?


#7

Нашел несколько способов, 1 способ написать скрипт на .net который исполняет скрипты sql и отправляет по http в influxdb. 2 способ через телеграф. Он может исполнять . bat который запускает sqlcmd с параметрами. Если надо могу дать примеры.