Open ghost opened 5 years ago
Note: I am trying to import the json file which is not exists in grafana
same issue i am also getting please help us to come out from this ASPS, need urge tn help
Any feedbacks on this issue ?
So, I managed to get the importer going with a few hacks, I will do a PR once I know of a nicer way to do it. Workaround steps:
Doing both of the above allow me to export/import grafana data from one instance to the other on grafana 7
I had to change the import command to
cat $FILE | jq '. * {overwrite: true }' | curl --fail -k -X$HTTP_VERB \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Basic $KEY" \
-d @- \
$URL
Only to import dashboards is OK, with datasource import the before command is failed...
If try to use the curl command XPUT or XPOST implementation of this repository aswell, but not working when datasource already exist...
So I investigate commands with jq to try solve it without success:
Example manual commands with failed result:
result:
{"message":"Failed to update datasource. Reload new version and try again"}
$ cat "VSPP/datasources/VSPP.json.json" | curl -k -XPUT -H "Content-Type: application/json" -H "Accept: application/json" -H "Authorization: Basic aaaaaaaa" http://localhost:3000/api/datasources/VSPP.json -d @-
result:
{"message":"Failed to update datasource. Reload new version and try again"}
Any idea about how to import datasources ??? I try to import from export json files like (when datasource already exist - I need update the version of datasource or overwrite it )
{
"id": 39,
"orgId": 6,
"name": "VSPP",
"type": "graphite",
"typeLogoUrl": "",
"access": "proxy",
"url": "http://1.1.1.1:8066",
"password": "",
"user": "",
"database": "",
"basicAuth": true,
"basicAuthUser": "***",
"basicAuthPassword": "****",
"withCredentials": false,
"isDefault": true,
"jsonData": {
"graphiteVersion": "",
"keepCookies": []
},
"secureJsonFields": {},
"version": 5,
"readOnly": false
}
I investigate the error ... https://sourcegraph.com/github.com/grafana/grafana@00e7c7c4b725ed7249e15a3eaac3043fda1d9f68/-/blob/pkg/api/datasources.go
err = bus.Dispatch(&cmd)
--
| if err != nil {
| if err == m.ErrDataSourceUpdatingOldVersion {
| return Error(500, "Failed to update datasource. Reload new version and try again", err)
| }
| return Error(500, "Failed to update datasource", err)
| }
So I suspect the version of data source is older in the destination grafana db .. I will try to increase version with a sed command to all datasource json files exported to solve that problem.