Start date for Monthly line chart

  • What Grafana version and what operating system are you using?
    v8.5.4

  • What are you trying to achieve?
    Create a in Time Series chart for data grouped over Months

SELECT
  $__timeGroupAlias(time,1M),
  count(number) AS "number"
FROM incident
WHERE
  $__timeFilter(time)
GROUP BY 1
ORDER BY $__timeGroup(time,1M)
  • How are you trying to achieve it?
    My data is in MYSQL and I am creating line chart using MySQL query

  • What happened?
    Start of the month is shown as some Random date rather than 1st of month in Time Series chart.

  • What did you expect to happen?
    Start of the month should be 1st of month

  • Help I need?
    Is there way I can have Start of the Month in Time Series chart?

Here is snapshot where it shows 14th as start of month rather than 1st.

Hi @kapilkathuria,

Welcome to the :grafana: community forum !!

It seems to be more related to the SQL query which needs to be defined correctly so that it can show the months in the correct sequence.

Please follow the following reference links as it might be helpful to get your desired result.

https://dev.mysql.com/doc/refman/5.6/en/date-and-time-functions.html

and

https://www.codegrepper.com/code-examples/sql/how+to+select+last+one+month+data+from+today's+date+in+mysql

The best way will be to first execute your query inside the MySQL shell to see if it gives you the desired result and then use the Grafana->Exploer and there build your query by using the “Edit SQL” and then put the values there (either in the template or your own custom way),

Hope it helps