time-seriesmariadbgrafanadate-formattimefield

How do I get a weekly time series on Grafana?


I am using MariaDB and Grafana to keep track of weekly consumption totals, but Grafana does not recognize this date format "DATE_FORMAT(`Timestamp`, '%Y-%u') AS Week" as a time field.

Any suggestions? The query is successful on MariaDB.

Other failed SQL alternatives

Other failed Grafana alternatives

![image|690x237](upload://xafbdIHmwTCVlqe5ATRIan7GRAU.png)

Thank you in advance.


Solution

  • I got the answer on my crosspost on Grafana Forums.

    STR_TO_DATE(CONCAT(YEAR(`Timestamp`),' ', WEEK(`Timestamp`, 3),'1'), '%X %V %w') AS Week
    

    This did the trick. It is a compromise that works.

    Unfortunatelly, it is not ideal, because the format of the original query would be way better for visualization, but I guess that is where Grafana is as of today.

    Also, the fact that the error message goes “Data is missing a time field” instead of “Incorrect time field format” is confusing.