@grafana/runtime package

A library containing services, configurations etc. used to interact with the Grafana engine.

Classes

ClassDescription
CopyPanelEventCalled to copy a panel JSON into local storage
DataSourceWithBackendExtend this class to implement a data source plugin that is depending on the Grafana backend API.
GrafanaBootConfig
RefreshEventCalled when a dashboard is refreshed
ThemeChangedEventCalled when the theme settings change
TimeRangeUpdatedEventCalled when time range is updated

Enumerations

EnumerationDescription
EchoEventTypeSupported echo event types that can be sent via the EchoSrv.
HealthStatusDescribes the current health status of a data source plugin.
MetaAnalyticsEventNameThe meta analytics events that can be added to the echo service.

Functions

FunctionDescription
frameToMetricFindValue(frame)(BETA) Return the first string or non-time field as the value
getAngularLoader()Used to retrieve the AngularLoader that enables the use of Angular components within a React component.Please see the AngularComponent for a proper example.
getAppEvents()Used to retrieve an event bus that manages application level events
getDataSourceSrv()Used to retrieve the DataSourceSrv that is the entry point for communicating with a datasource that is added as a plugin (both external and internal).
getEchoSrv()Used to retrieve the EchoSrv that can be used to report events to registered echo backends.
getLocationSrv()Used to retrieve the LocationSrv that can be used to automatically navigate the user to a new place in Grafana.
loadPluginCss(options)Use this to load css for a Grafana plugin by specifying a PluginCssOptions containing styling for the dark and the light theme.
locationSearchToObject(search)Parses a location search string to an object
logDebug(message, contexts)Log a message at DEBUG level. Depending on configuration might be forwarded to backend and logged to stdout or sent to Sentry
logError(err, contexts)Log an error. Depending on configuration might be forwarded to backend and logged to stdout or sent to Sentry
logInfo(message, contexts)Log a message at INFO level. Depending on configuration might be forwarded to backend and logged to stdout or sent to Sentry
logWarning(message, contexts)Log a message at WARNING level. Depending on configuration might be forwarded to backend and logged to stdout or sent to Sentry
toDataQueryError(err)Convert an object into a DataQueryError – if this is an HTTP response, it will put the correct values in the error field
toDataQueryResponse(res, queries)Parse the results from /api/ds/query into a DataQueryResponse

Interfaces

InterfaceDescription
AngularComponentUsed to enable rendering of Angular components within a React component without losing proper typings.
AngularLoaderUsed to load an Angular component from the context of a React component. Please see the AngularComponent for a proper example.
AzureSettings
BackendSrvUsed to communicate via http(s) to a remote backend such as the Grafana backend, a datasource etc. The BackendSrv is using the Fetch API under the hood to handle all the communication.The request function can be used to perform a remote call by specifying a BackendSrvRequest. To make the BackendSrv a bit easier to use we have added a couple of shorthand functions that will use default values executing the request.
DashboardInfoDescribes the basic dashboard information that can be passed as the meta analytics payload.
DashboardViewEventPayloadDescribes the payload of a dashboard view event.
DataRequestEventPayloadDescribes the payload of a data request event.
DataRequestInfoDescribes the data request information passed as the meta analytics payload.
DataSourceSrvThis is the entry point for communicating with a datasource that is added as a plugin (both external and internal). Via this service you will get access to the DataSourceApi that have a rich API for communicating with the datasource.
EchoBackendDescribes echo backends that can be registered to receive of events.
EchoEventDescribes an echo event.
EchoMetaDescribes the meta information that are sent together with each event.
EchoSrvUsed to send events to all the registered backends. This should be accessed via the getEchoSrv() function. Will, by default, flush events to the backends every 10s or when the flush function is triggered.
ExperimentViewEchoEventPayloadDescribes the payload of an experimentview event.
FetchErrorError type for fetch function in BackendSrv
FetchErrorDataPropsError type for fetch function in BackendSrv
FetchResponseResponse for fetch function in BackendSrv
GetDataSourceListFilters
HealthCheckResultDescribes the payload returned when checking the health of a data source plugin.
InteractionEchoEventPayloadDescribes the payload of a user interaction event.
LocationServiceA wrapper to help work with browser location and history
LocationSrvIf you need to automatically navigate the user to a new place in the application this should be done via the LocationSrv and it will make sure to update the application state accordingly.
LocationUpdate
MetaAnalyticsEventDescribes meta analytics event with predefined type.
PageviewEchoEventPayloadDescribes the payload of a pageview event.
PluginCssOptionsOption to specify a plugin css that should be applied for the dark and the light theme.
SizeMetaDescribes a size with width/height
TemplateSrvVia the TemplateSrv consumers get access to all the available template variables that can be used within the current active dashboard.For a more in-depth description visit: https://grafana.com/docs/grafana/v8.4/reference/templating

Variables

VariableDescription
configUse this to access the GrafanaBootConfig for the current running Grafana instance.
featureEnabled
getBackendSrvUsed to retrieve the BackendSrv that can be used to communicate via http(s) to a remote backend such as the Grafana backend, a datasource etc.
getLegacyAngularInjector(BETA) WARNING: this function provides a temporary way for plugins to access anything in the angular injector. While the migration from angular to react continues, there are a few options that do not yet have good alternatives. Note that use of this function will be removed in the future.
getTemplateSrvUsed to retrieve the TemplateSrv that can be used to fetch available template variables.
isExperimentViewEventExperimentview event typeguard.
isInteractionEventInteraction event typeguard.
isPageviewEventPageview event typeguard.
locationService
registerEchoBackendUsed to register echo backends that will receive Grafana echo events during application runtime.
reportExperimentViewHelper function to report experimentview events to the EchoSrv.
reportInteractionHelper function to report interaction events to the EchoSrv.
reportMetaAnalyticsHelper function to report meta analytics to the EchoSrv.
reportPageviewHelper function to report pageview events to the EchoSrv.

Type Aliases

Type AliasDescription
BackendSrvRequestUsed to initiate a remote call via the BackendSrv
ExperimentViewEchoEventDescribes experimentview event with predefined type.
HealthCheckResultDetailsDescribes the details in the payload returned when checking the health of a data source plugin.If the ‘message’ key exists, this will be displayed in the error message in DataSourceSettingsPage If the ‘verboseMessage’ key exists, this will be displayed in the expandable details in the error message in DataSourceSettingsPage
InteractionEchoEventDescribes interaction event with predefined type.
MetaAnalyticsEventPayloadDescribes the meta analytics payload passed with the MetaAnalyticsEvent
PageviewEchoEventDescribes pageview event with predefined type.
StreamOptionsProviderThis allows data sources to customize the streaming connection query