The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
grafana/public/app/features/live/index.ts

41 lines
1.3 KiB

import { config, getBackendSrv, getGrafanaLiveSrv, setGrafanaLiveSrv } from '@grafana/runtime';
import { CentrifugeSrv } from './centrifuge/service';
import { registerLiveFeatures } from './features';
import { GrafanaLiveService } from './live';
import { GrafanaLiveChannelConfigService } from './channel-config';
import { GrafanaLiveChannelConfigSrv } from './channel-config/types';
import { contextSrv } from '../../core/services/context_srv';
const grafanaLiveScopesSingleton = new GrafanaLiveChannelConfigService();
export const getGrafanaLiveScopes = (): GrafanaLiveChannelConfigSrv => grafanaLiveScopesSingleton;
export const sessionId =
(window as any)?.grafanaBootData?.user?.id +
'/' +
Date.now().toString(16) +
'/' +
Math.random().toString(36).substring(2, 15);
export function initGrafanaLive() {
const centrifugeSrv = new CentrifugeSrv({
appUrl: `${window.location.origin}${config.appSubUrl}`,
orgId: contextSrv.user.orgId,
orgRole: contextSrv.user.orgRole,
liveEnabled: config.liveEnabled,
sessionId,
});
setGrafanaLiveSrv(
new GrafanaLiveService({
scopes: getGrafanaLiveScopes(),
centrifugeSrv,
backendSrv: getBackendSrv(),
})
);
registerLiveFeatures();
}
export function getGrafanaLiveCentrifugeSrv() {
return getGrafanaLiveSrv() as GrafanaLiveService;
}