# Joining queries from multiple data sources

**URL:** <https://community.grafana.com/t/joining-queries-from-multiple-data-sources/31182>\
**Category:** Dashboards\
**Tags:** datasource, transformations, mixed-dbs, azure, query-help\
**Created:** [May 29, 2020, 9:13pm UTC](https://community.grafana.com/t/joining-queries-from-multiple-data-sources/31182 "2020-05-29T21:13:58Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dwightdl](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@dwightdl](https://community.grafana.com/u/dwightdl)\
**Post date:** [May 29, 2020, 9:13pm UTC](https://community.grafana.com/t/joining-queries-from-multiple-data-sources/31182/1 "2020-05-29T21:13:58Z")

</div>

I have consistent logs coming in from Azure Log Analytics, and I have relevant metadata stored in MySQL. I am aware of mixed queries, but these seem to be only for displaying the data alongside eachother, and don’t allow for any interaction.  
Here’s an example scenario:  
Display logs (Azure) only for users that have an email address set (value stored in MySQL). Both datasources contain a relevant UserId, so I’m basically looking to join the MySQL data where email != null on UserId.

Is this possible within the scope for Grafana? I was looking into the “-- Dashboard --” datasource option, which makes me think I could hack something together by creating a Mixed Query panel that projects all the data that I need, and then I could manipulate that data in the Dashboard datasource panel. I’m having trouble finding documentation on both the Dashboard and Mixed Query datasources, and I’m having trouble throwing something together myself.

Thanks for any and all support!  
-David

EDIT:  
I might actually be able to solve this by using a Variable that pulls from the MySQL database. Still open to other ideas, though!

EDIT2:  
Was actually able to solve this using variables. In line with the earlier example, one SQL query variable that returns every not-null email address entry, and then a Kusto panel that references the list returned by that variable. Also learned that you can reference one variable in another variable, which is great for another use-case I had in mind. Anyways someone can close this topic unless there is a better solution that one would like to share.

---

<div class="post-metadata">

**Author:** ![danielgonzalez](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/danielgonzalez/32/7125_2.png) [@danielgonzalez](https://community.grafana.com/u/danielgonzalez)\
**Post date:** [May 31, 2020, 12:50am UTC](https://community.grafana.com/t/joining-queries-from-multiple-data-sources/31182/2 "2020-05-31T00:50:08Z")

</div>

Hi [dwightdl](https://community.grafana.com/u/dwightdl)

I think that a option is a new feature of grafana 7, called Transformations that allows doing outer join of multiples queries based on a field

---

<div class="post-metadata">

**Author:** ![dwightdl](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@dwightdl](https://community.grafana.com/u/dwightdl)\
**Post date:** [May 31, 2020, 1:02am UTC](https://community.grafana.com/t/joining-queries-from-multiple-data-sources/31182/3 "2020-05-31T01:02:25Z")

</div>

Thanks for the response- I haven’t had a change to play around with Transformations but I will certainly look into it! Only recently upgraded to 7 🙂

---

<div class="post-metadata">

**Author:** ![taoyunxing](https://avatars.discourse-cdn.com/v4/letter/t/839c29/32.png) [@taoyunxing](https://community.grafana.com/u/taoyunxing)\
**Post date:** [October 9, 2020, 9:03am UTC](https://community.grafana.com/t/joining-queries-from-multiple-data-sources/31182/4 "2020-10-09T09:03:47Z")

</div>

I use template variables to implement my business requirement too！thanks a lot ^~^

---

<div class="post-metadata">

**Author:** ![ajaykools](https://avatars.discourse-cdn.com/v4/letter/a/4bbf92/32.png) [@ajaykools](https://community.grafana.com/u/ajaykools)\
**Post date:** [October 15, 2020, 5:29pm UTC](https://community.grafana.com/t/joining-queries-from-multiple-data-sources/31182/5 "2020-10-15T17:29:30Z")

</div>

While creating graph you can select “–Mixed–” datasource and add multiple queries. You get option to select different sub-datasource for each query.  
This solution worked for me like a charm. 🙂

---

<div class="post-metadata">

**Author:** ![castillo92](https://avatars.discourse-cdn.com/v4/letter/c/c67d28/32.png) [@castillo92](https://community.grafana.com/u/castillo92)\
**Post date:** [September 8, 2021, 10:16am UTC](https://community.grafana.com/t/joining-queries-from-multiple-data-sources/31182/6 "2021-09-08T10:16:13Z")

</div>

That is the best solution. Grafana allows use two diferent datasources using “Mixed Datasource”

---

<div class="post-metadata">

**Author:** ![mir1198yusuf](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/mir1198yusuf/32/32135_2.png) [@mir1198yusuf](https://community.grafana.com/u/mir1198yusuf)\
**Post date:** [April 22, 2023, 6:01pm UTC](https://community.grafana.com/t/joining-queries-from-multiple-data-sources/31182/7 "2023-04-22T18:01:00Z")

</div>

It does allow many-to-many inner join 😢

---

<div class="post-metadata">

**Author:** ![davidallen5](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/davidallen5/32/32092_2.png) [@davidallen5](https://community.grafana.com/u/davidallen5)\
**Post date:** [November 7, 2024, 4:57pm UTC](https://community.grafana.com/t/joining-queries-from-multiple-data-sources/31182/8 "2024-11-07T16:57:48Z")

</div>

Hi everybody - as an update to this popular thread, we’ve recently written a thorough blog post describing how to use join transformations together with multiple data sources. This gives a tutorial on how to do all aspects in 2024 with modern Grafana.

> **[How to work with multiple data sources in Grafana dashboards: best practices...](https://grafana.com/blog/2024/11/07/how-to-work-with-multiple-data-sources-in-grafana-dashboards-best-practices-to-get-started/)**
>
> In this post, you'll learn how to create Grafana dashboards featuring data from disparate sources, how to incorporate multiple queries from a single source into your visualization, and more.

---

<div class="post-metadata">

**Author:** ![davidallen5](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/davidallen5/32/32092_2.png) [@davidallen5](https://community.grafana.com/u/davidallen5)\
**Post date:** [November 7, 2024, 4:57pm UTC](https://community.grafana.com/t/joining-queries-from-multiple-data-sources/31182/9 "2024-11-07T16:57:52Z")

</div>

Closed on November 7, 2024, 4:57pm UTC


