In this post, I am going to explain how to register Data Sources SQL Server in Grafana 7.0.3 with Named Instances. This is a bug that will be solved in version 7.0.4.
Context of the issue.
The problem I had was an invalid URL error when the database server contained a named instance. Grafana interprets the server URL as an HTTP URL. The scenario where I work is as follows:
- Recent migration from Grafana 6.x to version 7.x.
- Grafana running on Windows.
- Grafana’s running with the SQLite internal database.
- Connecting to databases with Named Instances (servername \ SQLEXPRESS).
- I am able to register data sources without named instance using the form.
What causes the bug?.
The problem comes from validation in the data source registration/update form. It is a bug recognized in the official GitHub repository.
How to work around it?.
If you want to add a new SQL Server data source, first, you need to register the server URL omitting the named instance part.
You can update the incorrectly registered data sources without the instance name, directly in the SQLite database located in the path:
You can use an IDE like DataGrip to access the Grafana.db file, within the file by finding the table data_source that contains the list of all data sources. Update the URL field of the data source record.
UPDATE data_source SET url = 'XX.XX.XX.XX\SQLEXPRESS' WHERE name = 'MyDataSource'
Eventually, a fix will be released, in the meantime, you can use this Workaround. This fix could also work in other environments and with other data engines used by Grafana.