Create custom Macros for MySQL datasource

Hi Grafana developer,
I am use of grafana, when i am using the macros of MYSQL in grafana, I found its logic can not meet my requirement. I wonder is there any way to create custom macros for MySQL by myself.

Will be very appreciate if anyone reply me.

Thanks,
Jenny

Please could you give us more details of what your requirement is, and in what
way the logic isn’t sufficient?

Also, please note the documentation at

“We plan to add many more macros. If you have suggestions for what macros you
would like to see, please open an issue in our GitHub repo.”

Antony.

Thanks for your reply.

For example:
1.We want the $__timeGroup( ) supports QUARTER.

2.We hope the $__timeGroup( ) group the time by a whole natural week,month,quarter,year.

If so, the time of X axis will display the end of the natrual week,month,quarter,year.
The last data point will display the current date.

We write complex SQL to implement this kind of requirement, include grouping by time and filling missing value.

Below is the panel we created which group the time by Quarter:
image
image

Now we want to simplify the SQL.I am not sure if any other needs this kind of requirement, and maybe we will have more and more customization demand,so I wonder if there is any way for us to create macros or library for Grafana by ourselves. :grinning:

Thanks,
Jenny

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.