1

I am trying to create a bar chart on grafana in which it shows latency for two categories from a field which I query from the db. There are total three fields an hour field, category and an aggregate calculation. Basically I want hour field on X-axis and two bars to show aggregation for each category and aggregate field on Y-axis.

Currently it looks like this:

In the image below those marked in Red are the two categories. Lets say A,B. The latency is my aggregation marked in blue and the green mark is hour.

enter image description here

Basically, I want to achieve something like below image: Category A,B on x-axis wrt hour, and latency on y-axis.

enter image description here

This is my query:

select * from (
  select   extract(hour from event_datetime) Hour, category, (source_timedelta_s_ + pipeline_timedelta_s_) Latency from <table>
  where extract(date from event_datetime) = '2022-12-13' and  extract(hour from event_datetime) > 12
)
PIVOT (
   avg(Latency)
   FOR category IN ('A','B')
) t
order by t.Hour

Your help will be appreciated thanks. Sorry If my explanation is confusing.

Zuffido
  • 104
  • 1
  • 11

0 Answers0