Happening for all type of Datasources like Prometheus, Graphite, CloudWatch
This is the error message in the log file: t=2020-06-17T14:47:30+0000 lvl=eror msg="Failed to add datasource" logger=context userId=1 orgId=1 uname=admin error="UNIQUE constraint failed: data_source.org_id, data_source.uid"
But it’s not letting me even select the name to break any constraints.
I checked my database also.
sqlite> select * from data_source;
12|1|5|prometheus|Thanos|proxy|http://localhost:9091||||0|||0|{}|2020-06-02 20:54:23|2020-06-12 15:36:05|0|{}|0|0
If I am trying to send via HTTP API same message is getting logged.
Instead of deleting the whole grafana.db file, you can also open it with a tool like https://sqlitebrowser.org/. There, you can delete just the one UNIQUE constraint (on table data_source), then save the db file and restart Grafana. This worked for me (I also downgraded from Grafana 7 to 6.7.4 before the error occurred first).
I rolled back to the previous grafana version and took a new db since now much data was present, it worked fine. I think while upgrading and downgrading caused the issue.
Yes, will try the approach with dummy data as told by you.
By using above workaround after rollback we are able to add datasource but it leads to one more issue i.e mentioned below.
Workaround with rollback worked, later we upgraded the grafana chart from 6.6.2 to 7.1.3 we observed that UQE_data_source_org_id_uid unique index was not added back.
If index UQE_data_source_org_id_uid is not added back, will it cause any effects on grafana functionality.
By using above workaround after rollback we are able to add datasource but it leads to one more issue i.e mentioned below.
Workaround with rollback worked, later we upgraded the grafana chart from 6.6.2 to 7.1.3 we observed that UQE_data_source_org_id_uid unique index was not added back.
If index UQE_data_source_org_id_uid is not added back, will it cause any effects on grafana functionality.