Getting “failed to save annotation” when adding annotation.
In server logs error is : “Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘key=? AND value=? LIMIT 1’ at line 1”
what version of Grafana are you running?
I am using 4.6.0-beta1
Is it possible to upgrade to the stable version? (Latest stable is 4.6.2)
Im running grafana 4.6.2 as a container, have this error while trying to add annotation:
t=2017-12-05T14:15:31+0000 lvl=eror msg="Failed to save annotation" logger=context userId=0 orgId=1 uname= error="text field should not be empty" t=2017-12-05T14:15:31+0000 lvl=eror msg="Request Completed" logger=context userId=0 orgId=1 uname= method=POST path=/api/annotations status=500 remote_addr=1.1.1.1
My payload looks like this:
{
“DashboardId”:1,
“time”:1512482868,
“Tags”:[“tag1”,“tag2”],
“Text”:“Annotation Description”,
}
I just tested this out on the 4.6.2 docker image and cannot reproduce your error. What annotation source are you using?
Your payload looks strange - no panelId
and not using camel case for the JSON field names. Are you doing this via the API or via the UI?
{
"dashboardId":1,
"panelId":1,
"time":1512548301314,
"isRegion":true,
"timeEnd":1512548308333,
"tags":[]
}
curl -s -H "Authorization: Bearer eyJrIjoibWRNaE5rdzhYYk40Z1FNaTF0OTMiLCJuIjoiYWRtaW4iLCJpZCI6MX0=" http://1.1.1.1:3000/api/annotations -X POST -d a.json
I read panelId is optional, understand if not panelId annotations is made for all panels.
Thou, i made json look like yours and still have issue with saving.
{
“dashboardId”:1,
“panelId”:1,
“time”:1512482868,
“isRegion”:true,
“timeEnd”:1512482878,
“tags”:[],
“text”: “test annotation”
}
Anyway, its good it works at your side, means there is some issue at my side. Thank you.
This worked for me (without panelId worked as well):
curl -X POST http://admin:admin@localhost:3000/api/annotations -H "Content-Type: application/json" -d '{"dashboardId":1,"panelId":1,"time":1512548401207,"isRegion":true,"timeEnd":1512548410517,"tags":["test"],"text":"test"}'
Maybe you are missing the Content-Type header?
Good point, however i think i had Content-Type option as well during some tests.
Hm, i have done grafana container without any persistent storage, maybe this is my issue. But i thought internal sqllite is enough.
Do you have any storage (persistent) or just simple container?
You were right, header missing and wrong option for ‘-d’:
curl -s -X POST http://admin:admin@localhost:3000/api/annotations -H “Content-Type: application/json” -d @a.json
{“message”:“Annotation added”}
curl -s -X POST http://admin:admin@localhost:3000/api/annotations -d a.json
{“message”:“Failed to save annotation”}
curl -H “Content-Type: application/json” -X POST
-d ‘{“tags”:[“deployment”,“Environment”]}’
-H “Content-Type:application/json”
-H “Authorization:Bearer XXXX”
-d ‘username=admin&password=XXXX’ http://Host:3000/api/annotations
i have replaced XXXX and Host that i need to… am executing from jenkins.
below is the o/p i get in jenkins:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0
0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0
100 113 100 39 100 74 49 94 --:–:-- --:–:-- --:–:-- 94
{“message”:“Failed to save annotation”}Finished: SUCCESS
Help needed on this plz