How to use the @grafana/runtime.getBackendSrv function in @grafana/runtime

To help you get started, we’ve selected a few @grafana/runtime examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sbueringer / grafana-consul-datasource / src / DataSource.ts View on Github external
metricFindQuery(query: string): Promise {
    return getBackendSrv()
      .fetch({
        url: '/api/tsdb/query',
        method: 'POST',
        data: {
          queries: [
            {
              target: query,
              format: 'timeseries',
              type: 'keys',
              refId: 'keys',
              datasourceId: this.id,
            },
          ],
        },
      })
      .toPromise()
github grafana / grafana / public / app / features / plugins / state / actions.ts View on Github external
return async (dispatch, getStore) => {
    dispatch(pluginDashboardsLoad());
    const dataSourceType = getStore().dataSources.dataSource.type;
    const response = await getBackendSrv().get(`api/plugins/${dataSourceType}/dashboards`);
    dispatch(pluginDashboardsLoaded(response));
  };
}
github grafana / grafana / public / app / core / components / UserEdit / UserSessions.tsx View on Github external
async revokeAllUserSessions() {
    const { userId } = this.props;
    await getBackendSrv().post('/api/admin/users/' + userId + '/logout', {});
    this.setState({ sessions: [] });
  }
github grafana / grafana / public / app / features / teams / state / actions.ts View on Github external
return async dispatch => {
    const response = await getBackendSrv().get(`/api/teams/${id}`);
    dispatch(teamLoaded(response));
    dispatch(updateNavIndex(buildNavModel(response)));
  };
}
github grafana / grafana / public / app / core / components / UserEdit / state / actions.ts View on Github external
return async dispatch => {
    await getBackendSrv().put('/api/admin/users/' + id + '/permissions', permissions);
  };
}
github grafana / grafana / public / app / features / alerting / TestRuleResult.tsx View on Github external
constructor(props: Props) {
    super(props);
    this.backendSrv = getBackendSrv();
  }
github grafana / grafana / public / app / core / components / UserEdit / UserProfile.tsx View on Github external
async onCreateUser() {
    const { name, email, login, password } = this.state;

    await getBackendSrv().post('/api/admin/users', {
      name,
      email,
      login,
      password,
    });
  }
github GridProtectionAlliance / openHistorian / Source / Applications / openHistorian / openHistorian / Grafana / public / app / features / teams / state / actions.ts View on Github external
return async (dispatch, getStore) => {
    const team = getStore().team.team;
    await getBackendSrv().post(`/api/teams/${team.id}/groups`, { groupId: groupId });
    dispatch(loadTeamGroups());
  };
}
github GridProtectionAlliance / openHistorian / Source / Applications / openHistorian / openHistorian / Grafana / public / app / features / alerting / StateHistory.tsx View on Github external
componentDidMount(): void {
    const { dashboard, panelId } = this.props;

    getBackendSrv()
      .get(`/api/annotations?dashboardId=${dashboard.id}&panelId=${panelId}&limit=50&type=alert`)
      .then((res: any[]) => {
        const items = res.map((item: any) => {
          return {
            stateModel: alertDef.getStateDisplayModel(item.newState),
            time: dashboard.formatDate(item.time, 'MMM D, YYYY HH:mm:ss'),
            info: alertDef.getAlertAnnotationInfo(item),
          };
        });

        this.setState({
          stateHistoryItems: items,
        });
      });
  }
github grafana / grafana / public / app / features / admin / state / apis.ts View on Github external
export const getServerStats = async (): Promise => {
  try {
    const res = await getBackendSrv().get('api/admin/stats');
    return [
      { name: 'Total users', value: res.users },
      { name: 'Total admins', value: res.admins },
      { name: 'Total editors', value: res.editors },
      { name: 'Total viewers', value: res.viewers },
      { name: 'Active users (seen last 30 days)', value: res.activeUsers },
      { name: 'Active admins (seen last 30 days)', value: res.activeAdmins },
      { name: 'Active editors (seen last 30 days)', value: res.activeEditors },
      { name: 'Active viewers (seen last 30 days)', value: res.activeViewers },
      { name: 'Active sessions', value: res.activeSessions },
      { name: 'Total dashboards', value: res.dashboards },
      { name: 'Total orgs', value: res.orgs },
      { name: 'Total playlists', value: res.playlists },
      { name: 'Total snapshots', value: res.snapshots },
      { name: 'Total dashboard tags', value: res.tags },
      { name: 'Total starred dashboards', value: res.stars },