Wrong calculation of data (query help)

Hello,
i am new in grafana and i have some problems.

  • What Grafana version and what operating system are you using?
  • linux, Grafana 9.1.8.1, data source Loki
  • What are you trying to achieve?
  • It is about logs that I want to count
    I have several instances that log events every day. An event can occur several times on one instance.
    Now I want to build a dashboard:
    I want to count the events for the current day, the previous day and the last 7Days.
    I want to sort everything by instances. It doesn’t matter how many times the event occurs per instance.
    Example:
    Instance 1 logs 10x the event
    Instance 2 logs 1x the event
    Instance 3 logs 7x the event
    At the end there should be a 3. This means that the event has occurred on 3 instances.
    And I want to display this for: today, yesterday, last 7 days.
  • How are you trying to achieve it?
    My queries:
    today
    count(sum by (instance) (count_over_time({event=~“.+”}[24h])))
    and in the panel option "Qeuery Options
    Relative time: now-1d/d+24h
    Time shift:

yesterday
count(sum by (instance) (count_over_time({event=~“.+”}[24h])))
and in the panel option "Qeuery Options
Relative time: now-1d/d+0h
Time shift: 1d/1d+0h

last 7 days
count(sum by (instance) (count_over_time({event=~“.+”}[24h])))
and in the panel option "Qeuery Options
Relative time: now-7d
Time shift:

  • What happened?
    The 7 Days query has the same result as the today query. The number should be higher.
    And the yesterday panel has the last 2 days, i think…

  • What did you expect to happen?
    I thought that if the relative time settings were different, the queries would produce different results.
    What did I do wrong? I’ve been sitting on it forever and can’t figure it out.