PSQL query works but time series doesn't properly show

Hi i recently moved from Metabase to Grafana and started to import all my PSQL queries accordingly. I have a simple query that show the count of active services in a time range. The query inspector tells me the query works

SELECT
DATE_TRUNC(‘day’, account.created_shot) AS time,
service.name,
COUNT(*) as service_on
FROM
account
LEFT JOIN
customer c ON c.id_account = account.id
RIGHT JOIN
property p ON p.id_customer = c.id
RIGHT JOIN
service ON service.id_property = p.id
WHERE
service.category = ‘test’
AND service.name IN ($pacchettotest)
AND account.created_shot BETWEEN ‘2023-11-19’ AND ‘2023-11-21’
GROUP BY
time, service.name
ORDER BY
time, service.name;

My issue is that when i go into a time series the graph (which is supposed to have 3 lines , one for each service.name) is very wonky

I cannot find the solution anywhere it just seems that Grafana doesn’t like to use service_name and just uses service_on for data (moreover even when using service_on it seems that for each day it just selects the last service.name in alphabethical order and pushes a line from his value to the highest one and resets each day.)

Can anyone help me? To specify i want my graph to show each service.name as a separate line and each line to follow the trend of the query.

Format it as timeseries, not table:
image

1 Like

Sorry for the late reply but currently canno’t check if it worked. Will update and close the topic as soon as i can

Ok i finally had the time to check if it worked and indeed it did. Now the graph properly shows all the packages and their “trend” (i added more into pacchettotest variable)

I do now have another issue. I cannot seem to find a way to make the line be more spread from each other to make visualization easier on the eyes (sorry if it seems a dumb question but as i said i am new)

Would appreciate if you guys can help me on this

You may try logarithmic scale to the Y-axis, but generally there is not much what you can do. How can you spread values, when they are close to each other?

Ye i saw the log scale but they are still too close to each other. Anyway ty for the big help have a nice day