I'm trying to configure a Grafana dashboard for multiple Prometheus datasources. These two datasources are present in two different servers.
Prometheus scrape the metrics from three jobs, prometheus itself, node-exporter for host metrics, advisor for docker containers metrics.
This is what prometheus.yaml
looks like:
global:
scrape_interval: 5s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'node-exporter'
static_configs:
- targets: ['node-exporter:9100']
- job_name: 'cadvisor'
static_configs:
- targets: ['cadvisor:8080']
The same yaml configuration is being used in both the servers.
I created two datasources in Grafana UI and their respective names are Prometheus
, and Prometheus-Certify
. The first datasource is the default one. I'm using Grafana v7.1.0.
This is what my dashboard looks like for the datasource Prometheus
:
There are other panels as well, but showing these panels would be enough to explain the issue.
If I click on the Host
dropdown option, then I can see the hosts cadvisor:8080
, localhost:9090
, and node-exporter:9100
.
Requirement:
What I'm trying to achieve is to configure this dashboard for both the data sources. I can see all the options in the datasource
dropdown menu default
, Prometheus
, Prometheus-Certify
. I want the dashboard to show me the data from a particular source when I select that particular datasource. And this is where I'm getting stuck.
I did my research on this and found that we can show data from two different sources at the same time in a panel. I saw this option in the Grafana documentation and also this thread which actually gets me closer to what I'm trying to achieve.
So I followed this approach and configured --Mixed--
datasources for a panel.
It worked flawlessly and performing the same operation on different panels resulted in this:
Though it worked but, this is not what I was trying to do. The problems here are:
- I'll have to do this for every panel in order to see data from both the sources.
- It shows data from both sources at the same time. I want to see data from the selected datasource only, not both.
- If I add another datasource in the future, I'll have to perform all the operations all over again.
I saw [templates and variables][6] being suggested in many places. I gave it a shot but it didn't do anything.
If changing variables is the way to go then please provide suggestions specific to this issue only as I've already gone through that section and couldn't find anything specific to this.
I hope I was able to explain my problem to you people. I just want to see the data from the selected datasource without creating a new dashboard. Your help would be very much appreciated. Thank you.