Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panel with queries from different sources not working #28114

Closed
priyanr opened this issue Oct 8, 2020 · 8 comments · Fixed by #28180 or #28221
Closed

Panel with queries from different sources not working #28114

priyanr opened this issue Oct 8, 2020 · 8 comments · Fixed by #28180 or #28221
Assignees
Labels

Comments

@priyanr
Copy link

priyanr commented Oct 8, 2020

When a panel configured with query from different source in my case query A is application insights and query B is azure log anlytics. In query inspector no data is returned. It seems for different sources grafana is making two requests to
/api/ds/query one for application insights and one for log anytics i can see in browser one query is getting blocked. Tried in both chrome and firefox same result chrome its showing cancelled. This was working fine before , i am not sure which version was running before as this was in kubernetes and when kubernetes cluster upgraded and restarted i think it downloaded a new container version. Attached the screenshot of network call from browser

Grafana version v7.2.0

grafana

@kylebrandt kylebrandt added datasource/Azure/Monitor needs investigation for unconfirmed bugs. use type/bug for confirmed bugs, even if they "need" more investigating labels Oct 8, 2020
@kylebrandt
Copy link
Contributor

kylebrandt commented Oct 8, 2020

Can replicate on my local instance with currentish master:

image

Same when using mixed datasource.

Looking at the logs, it seems as if both requests are going through to the backend.

@dprokop dprokop removed the needs investigation for unconfirmed bugs. use type/bug for confirmed bugs, even if they "need" more investigating label Oct 9, 2020
@hugohaggmark
Copy link
Contributor

Seems like the requests get the same requestId for some reason so when the second one starts the first request ends up here and cancels:

if (options && options.requestId && options.requestId === requestId) {

I'm not familiar with these data sources so I'm going to need some time to find where the root cause is.

@hugohaggmark
Copy link
Contributor

I will continue this investigation on Monday, lot's of other things have come in between :(

@kylebrandt
Copy link
Contributor

I will continue this investigation on Monday, lot's of other things have come in between :(

Thanks, I think this was different data sources that were brought together, so maybe something there.

The following looks pretty sketchy:

// Initialize the list of queries
let q = byType[target.queryType];
if (!q) {
q = _.cloneDeep(options);
q.targets = [];
byType[target.queryType] = q;
}
q.targets.push(target);
}
// Distinct types are managed by distinct requests
const obs = Object.keys(byType).map((type: AzureQueryType) => {
const req = byType[type];
return this.pseudoDatasource[type].query(req);
});
// Single query can skip merge
if (obs.length === 1) {
return obs[0];
}
if (obs.length > 1) {
// Not accurate, but simple and works
// should likely be more like the mixed data source
const promises = obs.map(o => o.toPromise());
return from(
Promise.all(promises).then(results => {
return { data: _.flatten(results) };
})
);
}

@kylebrandt
Copy link
Contributor

FYI if I do something after the deep clone like:

      // Initialize the list of queries
      let q = byType[target.queryType];
      if (!q) {
        q = _.cloneDeep(options);
        q.requestId += q.requestId + Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
        q.targets = [];
        byType[target.queryType] = q;
      }
      q.targets.push(target);

The request is no longer cancelled.

@kylebrandt
Copy link
Contributor

@hugohaggmark I think this might not have resolved the issue fully. While it is no longer cancelled, it seems like data is lost.

For example with the following there is no data in the fields it seems:

image

However, if I disable one of the two queries, than I get data:

image

image

@hugohaggmark
Copy link
Contributor

@hugohaggmark I think this might not have resolved the issue fully. While it is no longer cancelled, it seems like data is lost.

For example with the following there is no data in the fields it seems:

image

However, if I disable one of the two queries, than I get data:

image

image

Oh noes, I'll look into it ASAP.

@priyanr
Copy link
Author

priyanr commented Nov 8, 2020

I can confirm its working in 7.3.1 release. Thank you guys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants