How to aggregate on dimensions with the same name across different data sources?

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

    • i don’t know…how to get version by frontend?

Due to some historical reasons, my time series data is scattered across different InfluxDB databases.

For example, database A (dbA) contains time series data with the following dimensions:

domainA, path1
domainA, path2
domainB, path3

And database B (dbB) contains data with these dimensions:

domainA, path5
domainB, path6
domainB, path7

What I want to do is calculate the total global traffic for domainA and domainB. In other words, I want to aggregate and get the combined traffic like this:

domainA: path1, path2, path5
domainB: path3, path6, path7

My current idea is to first group data by domain separately in each database to get these intermediate groups:

-- from dbA
domainA: path1, path2      labeled as dbA, domainA
domainB: path3             labeled as dbA, domainB

-- from dbB
domainA: path5             labeled as dbB, domainA
domainB: path6, path7      labeled as dbB, domainB

I can achieve this step with InfluxDB queries and plot four separate lines (one per each combination above).

The challenging part is: how can I further group by domain across these two data sources? That is, how to aggregate:

sum of [dbA, domainA] + [dbB, domainA] as domainA
sum of [dbA, domainB] + [dbB, domainB] as domainB

and then only display two lines (one per domain)?

I believe this can probably be done using transformations in Grafana, but I’m not sure exactly how to configure it. I have tried using join and merge but it doesn’t produce the desired results. Grafana seems unable to recognize the same dimension (domain) across different data sources as a single dimension and aggregate them together.

i would look into the new SQL Expression feature in grafana. you can use basic SQL query language to join these 2 datasources and get what you need using SQL syntax