fetzerch / grafana-sunandmoon-datasource

SunAndMoon is a datasource plugin for Grafana that calculates the position of Sun and Moon as well as the Moon illumination. ☀️🌙🧛‍♂️
MIT License
41 stars 8 forks source link

Convert to backend plugin to support Expressions and Alerting #50

Open soldierkam opened 1 year ago

soldierkam commented 1 year ago

Hi! Grafana fails to load data when I use Sun And Moon datasource and Math expression on single graph. It fails every single time even if the expression do not reference Sun And Moon data. I tried simple expression like "$A" but the server returns 500: Screenshot from 2022-11-03 08-50-00 Not sure what root cause is.

Server log: grafana.log

Grafana version: 8.0.2 Plugin version: 0.2.1

fetzerch commented 1 year ago

Thanks for the bug report. I'm able to reproduce this with Grafana 9.2.3. ~The sheer installation of the plugin seems to be enough to trigger the bug and it happens even if there's no datasource configured.~ Unfortunately I don't have an idea yet what could be causing this.

For reference, the Grafana server log shows:

grafana_1  | logger=context userId=0 orgId=1 uname= t=2022-11-04T22:39:36.289908028Z level=error msg="Query data error" error="expression request error: failed to execute query A: unknown query type" remote_addr=10.0.1.116 traceID=

I tried updating the plugin dependencies to a newer version of the grafana plugin framework, but that doesn't change anything.

fetzerch commented 1 year ago

I guess the problem is simply that server side expressions only work with backend plugins written in Go. The sunandmoon plugin still is a frontend only data source plugin written in TypeScript and executed on the client.

Admittingly, the 500 error message that Grafana throws is not really helpful - but I get a similar message when trying to use an expression with the built-in '-- Grafana --' datasource.

Could you maybe open an issue over at https://github.com/grafana/grafana for improving the message?

I'll rename the title of this issue to make it a feature request. But I have to be honest. It's rather unlikely that I work on this any time soon.

fetzerch commented 1 year ago

One additional remark: It's possible to use the 'Add field from calculation' transformation with the plugin. Depending on what you want to achieve, this could already help.