utils.ts 403 B

12345678910111213141516
  1. import { DataSourceApi } from '@grafana/data';
  2. import { getDataSourceSrv } from '@grafana/runtime';
  3. export async function getDS(uid?: string): Promise<DataSourceApi | undefined> {
  4. if (!uid) {
  5. return undefined;
  6. }
  7. const dsSrv = getDataSourceSrv();
  8. try {
  9. return await dsSrv.get(uid);
  10. } catch (error) {
  11. console.error('Failed to load data source', error);
  12. return undefined;
  13. }
  14. }