Display count of rows on y-axis in time-series graph

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

  • What are you trying to achieve?
    I’m using MySQL data source with the following query

  u.date_joined,    # date-time field
  u.is_shared,        # tinyint field (0 for false, 1 for true)
  sa.provider,        # string
  u.last_login.        # date-time field
FROM authentication_user u
LEFT JOIN socialaccount_socialaccount sa on sa.user_id = u.id
  AND u.email not like "%@example.io"
ORDER BY $__timeGroup(u.date_joined,${interval})

I have added multiple columns because I want to use this data in other panels as well without making additional queries on the database.

But I want to display the first panel as a time-series graph, where date_joined is used on the x-axis and the count of rows on the y-axis.

The data in the tabular form is like

  • How are you trying to achieve it?

  • What happened?
    It displays the value of the is_shared field on the y-axis.

  • What did you expect to happen?
    Option to configure y-axis as what field to display and the option to aggregate results.

  • Can you copy/paste the configuration(s) that you are having problems with?

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

  • Did you follow any online instructions? If so, what is the URL?

How are you getting the row count in order to display it on y axis

There are no columns for row count. The table contains all data. What I mean to say if the time range is 30 days and the interval is 1 day, the row count will contain all data on a specific date, for each day of the month.

Basically instead of aggregating the count on MySQL, I want to aggregate in Grafana by the selected time range and interval.

1 Like