I am using some custom MySQL functions in my Query. The query is working fine in MySQL client, but getting error through Grafana. Can anyone help me with this, please?
First of all, please tell us the error you get in Grafana.
Probably I had the same problem here. I created a function in my database, and it works via cli.
But when I tried to call it inside a table panel query statement in grafana, I got NO DATA.
The problem here was that the user which Grafana did the queries hadn’t the permissions to execute commands.
Check grafana server log (maybe /var/log/grafana/grafana.log) for something like this:
logger=tsdb.mysql t=2022-06-29T13:58:25.73682069-03:00 level=error msg=“query error” err=“Error 1370: execute command denied to user ‘grafUser’@‘%’ for routine 'mydb.my_function’”
grant execute on function my_function to ‘grafUser’;
Check new permission:
show grants for ‘grafUser’;
Please adapt it to your environment.