mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Azure: Fixes merging of requests with different Azure sources (#28221)
* Azure: Fixes merging of requests with different Azure sources * Refactor: Changes return type
This commit is contained in:
parent
4cbc1565de
commit
39d06f2625
@ -4,17 +4,19 @@ import AppInsightsDatasource from './app_insights/app_insights_datasource';
|
||||
import AzureLogAnalyticsDatasource from './azure_log_analytics/azure_log_analytics_datasource';
|
||||
import { AzureDataSourceJsonData, AzureMonitorQuery, AzureQueryType, InsightsAnalyticsQuery } from './types';
|
||||
import {
|
||||
DataFrame,
|
||||
DataQueryRequest,
|
||||
DataQueryResponseData,
|
||||
DataQueryResponse,
|
||||
DataSourceApi,
|
||||
DataSourceInstanceSettings,
|
||||
LoadingState,
|
||||
ScopedVars,
|
||||
} from '@grafana/data';
|
||||
import { from, Observable, of } from 'rxjs';
|
||||
import { forkJoin, Observable, of } from 'rxjs';
|
||||
import { DataSourceWithBackend } from '@grafana/runtime';
|
||||
import InsightsAnalyticsDatasource from './insights_analytics/insights_analytics_datasource';
|
||||
import { migrateMetricsDimensionFilters } from './query_ctrl';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
export default class Datasource extends DataSourceApi<AzureMonitorQuery, AzureDataSourceJsonData> {
|
||||
azureMonitorDatasource: AzureMonitorDatasource;
|
||||
@ -47,7 +49,7 @@ export default class Datasource extends DataSourceApi<AzureMonitorQuery, AzureDa
|
||||
this.optionsKey = optionsKey;
|
||||
}
|
||||
|
||||
query(options: DataQueryRequest<AzureMonitorQuery>): Observable<DataQueryResponseData> {
|
||||
query(options: DataQueryRequest<AzureMonitorQuery>): Observable<DataQueryResponse> {
|
||||
const byType: Record<AzureQueryType, DataQueryRequest<AzureMonitorQuery>> = ({} as unknown) as Record<
|
||||
AzureQueryType,
|
||||
DataQueryRequest<AzureMonitorQuery>
|
||||
@ -98,17 +100,23 @@ export default class Datasource extends DataSourceApi<AzureMonitorQuery, AzureDa
|
||||
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) };
|
||||
return forkJoin(obs).pipe(
|
||||
map((results: DataQueryResponse[]) => {
|
||||
const data: DataFrame[] = [];
|
||||
for (const result of results) {
|
||||
for (const frame of result.data) {
|
||||
data.push(frame);
|
||||
}
|
||||
}
|
||||
|
||||
return { state: LoadingState.Done, data };
|
||||
})
|
||||
);
|
||||
}
|
||||
return of({ state: LoadingState.Done });
|
||||
|
||||
return of({ state: LoadingState.Done, data: [] });
|
||||
}
|
||||
|
||||
async annotationQuery(options: any) {
|
||||
|
Loading…
Reference in New Issue
Block a user