grafana / sqlds

A package that assists writing SQL-driven datasources
Apache License 2.0
17 stars 12 forks source link

Logs format #39

Closed yesoreyeram closed 3 years ago

yesoreyeram commented 3 years ago

Support for logs format

Really a coincidence to @andresmgot 's PR #38 . In addition to #38, this PR also checks if the frame has at least one Time field and one string field as in other cases, it wont render properly in Explorer

andresmgot commented 3 years ago

Nice! I wonder though, if you've selected result format Logs in the query editor, wouldn't you expect the Logs visualization to be shown in all scenarios? Even if that includes showing an empty logs visualization because no time and string field were found.

I agree with this, is the new code really necessary? AFAICT the behavior is the same in the panel without the check (you simply get an empty response). One thing that confused me when checking this was that if the columns are not right, it fails silently. Maybe we can return an error here if the frame is not right for logs? (or maybe that's work of the visualization panel).

If you use the explore view, it's helpful to set the preferred visualization even if the required columns are missing because you get the logs view with the proper error (better than showing the table with just some column):

Screenshot from 2021-09-09 09-24-44

yesoreyeram commented 3 years ago

Based on the convo above, I agree that this fallback for logs can be better handled in explore view/logs visualization itself. Thank you for the feedback.

yesoreyeram commented 3 years ago

If the data is not in logs format, then either we need to fall back to table view and/or show notice to the user about it aleast.

kminehart commented 3 years ago

I think an error makes sense, though to me that almost sounds like a Grafana feature rather than a sqlds one. If a panel receives data that doesn't match what's expected, the panel ought to return the error.