@grafana/data package

A library containing most of the core functionality and data types used in Grafana.

Classes

ClassDescription
AppendedVectorsThis may be more trouble than it is worth. This trades some computation time for RAM – rather than allocate a new array the size of all previous arrays, this just points the correct index to their original array values
AppPlugin
ArrayVector
AsNumberVectorThis will force all values to be numbers
BinaryOperationVector
CircularDataFrameThis dataframe can have values constantly added, and will never exceed the given capacity
CircularVectorCircular vector uses a single buffer to capture a stream of values overwriting the oldest value on add.This supports adding to the ‘head’ or ’tail’ and will grow the buffer to match a configured capacity.
ConstantVector
CSVReader
DataFrameView(BETA) This abstraction will present the contents of a DataFrame as if it were a well typed javascript object Vector.
DataSourceApiThe main data source abstraction interface, represents an instance of a data sourceAlthough this is a class, datasource implementations do not yet need to extend it. As such, we can not yet add functions with default implementations.
DataSourcePlugin
FieldCache
FieldConfigEditorBuilderFluent API for declarative creation of field config option editors
FieldConfigOptionsRegistry
FormattedVector
GrafanaPlugin
IndexVectorIndexVector is a simple vector implementation that returns the index value for each element in the vector. It is functionally equivolant a vector backed by an array with values: [0,1,2,…,length-1]
LanguageProvider
MutableDataFrame
PanelOptionsEditorBuilderFluent API for declarative creation of panel options
PanelPlugin
Registry
SortedVectorValues are returned in the order defined by the input parameter
SystemDateFormatsState

Enumerations

EnumerationDescription
BinaryOperationID
ByNamesMatcherModeMode to be able to toggle if the names matcher should match fields in provided list or all except provided names.
CoreAppThe app container that is loading another plugin (panel or query editor)
CSVHeaderStyle
DashboardCursorSync
DataFrameTypeSee also: https://github.com/grafana/grafana-plugin-sdk-go/blob/main/data/frame_type.go
DataQueryErrorType
DataTopicAttached to query results (not persisted)
DataTransformerID
ExploreMode
FieldColorModeId
FieldConfigProperty
FieldMatcherID
FieldType
FrameMatcherIDField name matchers
GrafanaThemeType
InternalTimeZones
LayoutModes
LiveChannelConnectionState
LiveChannelEventType
LoadingStateRepresent panel data loading state.
LogLevelMapping of log level abbreviation to canonical log level. Supported levels are reduce to limit color variation.
LogsDedupDescription
LogsDedupStrategy
LogsMetaKind
LogsSortOrder
MatcherID
NavMenuItemType
NavSection
NodeGraphDataFrameFieldNames
NullValueMode
OrgRole
PluginErrorCodeDescribes error code returned from Grafana plugins API call
PluginIncludeType
PluginSignatureStatusDescribes status of plugin signature
PluginSignatureTypeDescribes level of plugin signature level
PluginStateDescribes plugins life cycle status
PluginTypeDescribes type of plugin
ReducerID
ThresholdsModeDisplay mode
ValueMatcherID
VariableOrigin
VariableSuggestionsScope
VizOrientation

Functions

FunctionDescription
addDurationToDate(date, duration)addDurationToDate adds given duration to given date and returns a new Date object
addLogLevelToSeries(series, lineIndex)
anySeriesWithTimeField(data)Indicates if there is any time field in the array of data frames
applyFieldOverrides(options)Return a copy of the DataFrame with all rules applied
applyRawFieldOverrides(data)Return a copy of the DataFrame with raw data
booleanValueFormatter(t, f)
calculateFieldStats(rows, extractor)
calculateLogsLabelStats(rows, label)
calculateStats(values)
compareArrayValues(a, b, cmp)(BETA) Check if all values in two arrays match the compare funciton
compareDataFrameStructures(a, b, skipConfig)(BETA) Returns true if both frames have the same name, fields, labels and configs.
doStandardCalcs(field, ignoreNulls, nullAsZero)
durationToMilliseconds(duration)durationToMilliseconds convert a duration object to milliseconds
ensureTimeField(field, dateFormat)Checks the first value. Assumes any number should be time fieldtype. Otherwise attempts to make the fieldtype time.
eventFactory(name)
findCommonLabels(labelsSets)Returns a map labels that are common to the given label sets.
findHighlightChunksInText({ searchWords, textToHighlight, })Adapt findMatchesInText for react-highlight-words findChunks handler. See https://github.com/bvaughn/react-highlight-words#props
findMatchesInText(haystack, needle)Returns a list of substring regexp matches.
findUniqueLabels(labels, commonLabels)Returns a map of labels that are in labels, but not in commonLabels.
formatLabels(labels, defaultValue, withoutBraces)Serializes the given labels to a string.
formattedValueToString(val)
getActiveThreshold(value, thresholds)
getColorForTheme(color, theme)
getColorFromHexRgbOrName(color, type)
getDataFrameRow(data, row)Wrapper to get an array from each field value
getDataSourceRef(ds)Convert instance settings to a reference
getDataSourceUID(ref)Get the UID from a string of reference
getDefaultRelativeTimeRange()Returns the default realtive time range.
getDefaultTimeRange()
getDisplayProcessor(options)
getDisplayValueAlignmentFactors(values)
getFieldColorMode(mode)(BETA)
getFieldColorModeForField(field)(BETA)
getFieldDisplayName(field, frame, allFrames)
getFieldMatcher(config)Resolves a field matcher from the registry for given config. Will throw an error if matcher can not be resolved.
getFieldTypeFromValue(v)Check the field type to see what the contents are
getFlotPairs({ xField, yField, nullValueMode })
getFlotPairsConstant(seriesData, range)Returns a constant series based on the first value from the provide series.
getFrameDisplayName(frame, index)Get an appropriate display title
getFrameMatchers(config)Resolves a frame matcher from the registry for given config. Will throw an error if matcher can not be resolved.
getLogLevel(line)Returns the log level of a log line. Parse the line for level words. If no level is found, it returns LogLevel.unknown.Example: getLogLevel(‘WARN 1999-12-31 this is great’) // LogLevel.warn
getLogLevelFromKey(key)
getParser(line)
getRawDisplayProcessor()
getScaleCalculator(field, theme)
getValueFormat(id)
getValueFormats()
getValueFormatterIndex()
getValueMatcher(config)Resolves a value matcher from the registry for given config. Will throw an error if matcher can not be resolved.
guessFieldTypeForField(field)Looks at the data to guess the column type. This ignores any existing setting
guessFieldTypeFromNameAndValue(name, v)Given a name and value, this will pick a reasonable field type
guessFieldTypeFromValue(v)Given a value this will guess the best column typeNOTE: this is will try to see if string values can be mapped to other types (like number)
hasLinks(field)
intervalToAbbreviatedDurationString(interval, includeSeconds)intervalToAbbreviatedDurationString converts interval to readable duration string
isBooleanUnit(unit)
isDataSourceRef(ref)Returns true if the argument is a DataSourceRef
isLiveChannelJoinEvent(evt)
isLiveChannelLeaveEvent(evt)
isLiveChannelMessageEvent(evt)
isLiveChannelStatusEvent(evt)
isValidDate(dateString)isValidDate returns true if given string can be parsed into valid Date object, false otherwise
isValidDuration(durationString)isValidDuration returns true if the given string can be parsed into a valid Duration object, false otherwise
locale(value, decimals)
localTimeFormat(options, locale, fallback)localTimeFormat helps to generate date formats for momentjs based on browser’s locale
makeClassES5Compatible(ES6Class)(BETA) Proxies a ES6 class so that it can be used as a base class for an ES5 class
mapInternalLinkToExplore(options)
matchAllLabels(expect, against)Check that all labels exist in another set of labels
outerJoinDataFrames(options)This will return a single frame joined by the first matching field. When a join field is not specified, the default will use the first time field
parseDuration(durationString)parseDuration parses duration string into datefns Duration object
parseFlags(text)Converts any mode modifiers in the text to the Javascript equivalent flag
parseLabels(labels)Returns a map of label keys to value from an input selector string.Example: parseLabels(’{job=”foo”, instance=”bar”}) // {job: “foo”, instance: “bar”}
readCSV(csv, options)
reduceField(options)
renderMarkdown(str, options)
renderTextPanelMarkdown(str, options)
reverseDataFrame(data)Returns a copy with all values reversed
scaledUnits(factor, extArray)
serializeStateToUrlParam(urlState, compact)Create an string that is used in URL to represent the Explore state. This is basically just a stringified json that is that used as a state of a single Explore pane so it does not represent full Explore URL.
shallowCompare(a, b, cmp)(BETA) Checks if two objects are equal shallowly
simpleCountUnit(symbol)
sortDataFrame(data, sortIndex, reverse)
sortThresholds(thresholds)Sorts the thresholds
stringFormater(value)
stringStartsAsRegEx(str)
stringToJsRegex(str)
stringToMs(str)
toCSV(data, config)
toDataFrame(data)Inspect any object and return the results as a DataFrame
toDataFrameDTO(data)Returns a copy that does not include functions
toFilteredDataFrameDTO(data, fieldPredicate)
toFixed(value, decimals)
toFixedScaled(value, decimals, ext)
toFixedUnit(unit, asPrefix)
toFloatOrUndefined(value)
toIntegerOrUndefined(value)
toNumberString(value)
transformDataFrame(options, data)Apply configured transformations to the input data
updateDatasourcePluginOption(props, key, val)
validateFieldConfig(config)This checks that all options on FieldConfig make sense. It mutates any value that needs fixed. In particular this makes sure that the first threshold value is -Infinity (not valid in JSON)
vectorator(vector)Use functional programming with your vector

Interfaces

InterfaceDescription
AbsoluteTimeRange
AnnotationEvent
AnnotationEventFieldMapping
AnnotationEventUIModel
AnnotationQueryThis JSON object is stored in the dashboard json model.
AnnotationQueryRequestOptions passed to the datasource.annotationQuery method. See docs/plugins/developing/datasource.md
AnnotationSupportSince Grafana 7.2This offers a generic approach to annotation processing
AppEvent
ApplyFieldOverrideOptions
AppPluginMeta
AppRootProps
BasicValueMatcherOptionsDescribes a basic value matcher option that has a single value.
BuildInfoDescribes the build information that will be available via the Grafana configuration.
BusEventType
ByNamesMatcherOptionsOptions to instruct the by names matcher to either match all fields in given list or all except the fields in the list.
CartesianCoords2DA coordinate on a two dimensional plane.
Column
ConfigOverrideRule
CreatePlotOverlay
CSVConfig
CSVOptions
CSVParseCallbacks
DataConfigSourceDescribes and API for exposing panel specific data configurations.
DataFrame
DataFrameDTOLike a DataFrame, but fields may be a FieldDTO
DataLinkLink configuration. The values may contain variables that need to be processed before showing the link to user.TODO: <T extends DataQuery> is not strictly true for internal links as we do not need refId for example but all data source defined queries extend this so this is more for documentation.
DataLinkClickEventCallback info for DataLink click events
DataLinksFieldConfigSettings
DataQueryThese are the common properties available to all queries in all datasources Specific implementations will extend this interface adding the required properties for the given context
DataQueryError
DataQueryRequest
DataQueryResponse
DataQueryTimings
DataSourceConstructor
DataSourceInstanceSettingsFrontend settings model that is passed to Datasource constructor. This differs a bit from the model above as this data model is available to every user who has access to a data source (Viewers+). This is loaded in bootData (on page load), or from: /api/frontend/settings
DataSourceJsonData
DataSourcePluginComponents
DataSourcePluginMeta
DataSourcePluginOptionsEditorProps
DataSourceRef
DataSourceSelectItem
DataSourceSettingsData Source instance edit model. This is returned from: /api/datasources
DataTransformerConfig
DataTransformerInfoFunction that transform data frames (AKA transformer)
DateTime
DateTimeBuiltinFormat
DateTimeDuration
DateTimeLocale
DateTimeOptionsThe type describing date and time options. Used for all the helper functions available to parse or format date and time values.
DateTimeOptionsWhenParsingThe type that describes options that can be passed when parsing a date and time value.
DateTimeOptionsWithFormatThe type describing the options that can be passed to the dateTimeFormat helper function to control how the date and time value passed to the function is formatted.
DecimalInfo
Dimension
Dimensions2D2d object dimensions.
DisplayValue
DisplayValueAlignmentFactorsThese represents the display value with the longest title and text. Used to align widths and heights when displaying multiple DisplayValues
DynamicConfigValue
ExplorePanelsState
ExploreTracePanelState
FeatureTogglesDescribes available feature toggles in Grafana. These can be configured via conf/custom.ini to enable features under development or not yet available in stable version.Only enabled values will be returned in this interface
Field
FieldCalcs
FieldColor
FieldColorConfigSettings
FieldColorMode(BETA)
FieldConfigEvery property is optionalPlugins may extend this with additional properties. Something like series overrides
FieldConfigEditorConfig
FieldConfigEditorProps
FieldConfigPropertyItem
FieldConfigSource
FieldDisplay
FieldDTOLike a field, but properties are optional and values may be a simple array
FieldMatcherInfo
FieldNamePickerConfigSettings
FieldOverrideContext
FieldOverrideEditorProps
FieldReducerInfo
FieldSparkline
FieldWithIndex
FlotDataPoint
FormattedValue
FrameMatcherInfo
GetFieldDisplayValuesOptions
GrafanaConfigDescribes all the different Grafana configuration values available for an instance.
GrafanaTheme
GrafanaTheme2(BETA) Next gen theme model introduced in Grafana v8.
GrafanaThemeCommons
GraphSeriesXYView model projection of a series
GroupedTimeZones
HistoryItem
IntervalValues
Labels
LegacyEmitter
LegacyEventHandler
LegacyGraphHoverEventPayload
LicenseInfoDescribes the license information about the current running instance of Grafana.
LinkModelProcessed Link Model. The values are ready to use
LinkModelSupplierProvides a way to produce links on demandTODO: ScopedVars in in GrafanaUI package!
LiveChannelJoinEvent
LiveChannelLeaveEvent
LiveChannelMessageEvent
LogLabelStatsModel
LogRowModel
LogSearchMatch
LogsMetaItem
LogsModel
LogsParser
MatcherConfig
MetadataInspectorProps
MetricFindValue
MutableVectorVector with standard manipulation functions
NavModelInterface used to describe different kinds of page titles and page navigation. Navmodels are usually generated in the backend and stored in Redux.
NavModelBreadcrumb
NavModelItem
NumberFieldConfigSettings
NumericRange
PanelData
PanelEditorProps
PanelModel
PanelOptionsEditorConfig
PanelOptionsEditorItem
PanelOptionsEditorProps
PanelPluginDataSupport
PanelPluginMeta
PanelProps
PluginBuildInfo
PluginConfigPage
PluginConfigPageProps
PluginDependencies
PluginErrorDescribes error returned from Grafana plugins API call
PluginInclude
PluginMeta
PluginMetaInfo
QueryEditorHelpProps
QueryEditorProps
QueryFix
QueryFixAction
QueryHint
QueryResultBase
QueryResultMeta
QueryResultMetaNoticeQueryResultMetaNotice is a structure that provides user notices for query result data
QueryResultMetaStat
RangeValueMatcherOptionsDescribes a range value matcher option that has a to and a from value to be able to match a range.
RawTimeRange
ReadWriteVectorApache arrow vectors are Read/Write
ReduceDataOptionsOptions for how to turn DataFrames into an array of display values
RegexpOrNamesMatcherOptions
RegistryItem
RegistryItemWithOptions
RenameByRegexTransformerOptionsOptions for renameByRegexTransformer
RenderMarkdownOptions
ScopedVar
ScopedVars
ScreenshotInfo
SelectableValueUsed in select elements
SelectFieldConfigSettings
SetFieldConfigOptionsArgs(BETA)
SliderFieldConfigSettings
StandardEditorContext
StandardEditorProps
StandardEditorsRegistryItem
StatsPickerConfigSettings
StringFieldConfigSettings
SynchronousDataTransformerInfoMany transformations can be called with a simple synchronous function. When a transformer is defined, it should have identical behavior to using the operator
SystemDateFormatSettings
TableData
TextMatch
ThemeBreakpoints(BETA)
ThemeColors(BETA)
ThemeShadows(BETA)
ThemeShape(BETA)
ThemeSpacing(BETA) The different signatures imply different meaning for their arguments that can’t be expressed structurally. We express the difference with variable names. tslint:disable:unified-signatures
ThemeTypography(BETA)
ThemeTypographyVariant
Threshold
ThresholdsConfigConfig that is passed to the ThresholdsEditor
ThresholdsFieldConfigSettings
TimeOption
TimeOptions
TimeRange
TimeSeries
TimeZoneCountry
TimeZoneInfo
TraceSpanRowThis describes the structure of the dataframe that should be returned from a tracing data source to show trace in a TraceView component.
TransformerRegistryItem
TransformerUIProps
UnitFieldConfigSettings
UserOrgDTO
ValueFormat
ValueFormatCategory
ValueFormatterIndex
ValueLinkConfig
ValueMappingFieldConfigSettings
ValueMatcherInfoRegistry item to represent all the different valu matchers supported in the Grafana platform.
ValueMatcherOptionsDescribes a empty value matcher option.
VariableModel
VariableSuggestion
Vector
WithAccessControlMetadataWith FGAC, the backend will return additional access control metadata to objects. These metadata will contain user permissions associated to a given resource.For example: { accessControl: { “datasources:read”: true, “datasources:write”: true } }
YAxis

Namespaces

NamespaceDescription
arrayUtils
colorManipulator
dateMath
rangeUtil

Variables

VariableDescription
AppEvents
binaryOperators
booleanOverrideProcessor
checkLogsError
classicColors
createDimension
DataLinkBuiltInVars
dataLinksOverrideProcessor
dateTime
dateTimeAsMoment
dateTimeFormatHelper function to format date and time according to the specified options. If no options are supplied, then default values are used. For more details, see DateTimeOptionsWithFormat.
dateTimeFormatISOHelper function to format date and time according to the standard ISO format e.g. 2013-02-04T22:44:30.652Z. If no options are supplied, then default values are used. For more details, see DateTimeOptionsWithFormat.
dateTimeFormatTimeAgoHelper function to return elapsed time since passed date. The returned value will be formatted in a human readable format e.g. 4 years ago. If no options are supplied, then default values are used. For more details, see DateTimeOptions.
dateTimeFormatWithAbbrevationHelper function to format date and time according to the Grafana default formatting, but it also appends the time zone abbreviation at the end e.g. 2020-05-20 13:37:00 CET. If no options are supplied, then default values are used. For more details please see DateTimeOptions.
dateTimeForTimeZone
dateTimeParseHelper function to parse a number, text or Date to a DateTime value. If a timeZone is supplied the incoming value is parsed with that timeZone as a base. The only exception to this is if the passed value is in a UTC-based format. Then it will use UTC as the base. If no format is specified the current system format will be assumed.It can also parse the Grafana quick date and time format, e.g. now-6h will be parsed as Date.now() - 6 hours and returned as a valid DateTime value.If no options are supplied, then default values are used. For more details please see DateTimeOptions.
DEFAULT_FIELD_DISPLAY_VALUES_LIMIT
DEFAULT_SAML_NAME
DefaultTimeZone
deprecationWarning
displayNameOverrideProcessor
escapeStringForRegex
escapeUnescapedString
FALLBACK_COLOR
fieldMatchersRegistry that contains all of the built in field matchers.
fieldReducers
frameMatchersRegistry that contains all of the built in frame matchers.
GAUGE_DEFAULT_MAXIMUM
GAUGE_DEFAULT_MINIMUM
getAllValuesFromDimension
getColumnFromDimension
getColumnsFromDimension
getDimensionByName
getFieldDisplayValues
getLocale
getLocaleData
getSeriesTimeStepReturns minimal time step from series time field
getTimeField
getTimeZoneUsed to get the current selected time zone. If a valid time zone is passed in the options it will be returned. If no valid time zone is passed either the time zone configured for the user account will be returned or the default for Grafana.
getTimeZoneGroups
getTimeZoneInfo
getTimeZones
getValueFromDimension
getWeekdayIndex
guessFieldTypes
hasMsResolutionChecks if series time field has ms resolution
identityOverrideProcessor
isDataFrame
isDateTime
ISO_8601
isTableData
locationUtil
LogsParsers
MISSING_VALUE
numberOverrideProcessor
objRemoveUndefined
onUpdateDatasourceJsonDataOption
onUpdateDatasourceJsonDataOptionChecked
onUpdateDatasourceJsonDataOptionSelect
onUpdateDatasourceOption
onUpdateDatasourceResetOption
onUpdateDatasourceSecureJsonDataOption
onUpdateDatasourceSecureJsonDataOptionSelect
PanelEvents
selectOverrideProcessor
setLocale
setWeekStart
sortInAscendingOrder
sortInDescendingOrder
sortLogRows
sortLogsResult
standardEditorsRegistry
standardFieldConfigEditorRegistry
standardTransformers
standardTransformersRegistryRegistry of transformation options that can be driven by stored configuration files.
stringOverrideProcessor
systemDateFormats
textUtil
thresholdsOverrideProcessor
TIME_FORMAT
TIME_SERIES_METRIC_FIELD_NAME
TIME_SERIES_TIME_FIELD_NAME
TIME_SERIES_VALUE_FIELD_NAME
timeZoneAbbrevationHelper function to return only the time zone abbreviation for a given date and time value. If no options are supplied, then default values are used. For more details please see DateTimeOptions.
timeZoneFormatUserFriendly
toDuration
toLegacyResponseData
toOption
toPascalCase
toUtc
unEscapeStringFromRegex
unitOverrideProcessor
updateDatasourcePluginJsonDataOption
updateDatasourcePluginResetOption
updateDatasourcePluginSecureJsonDataOption
urlUtil
valueMappingsOverrideProcessor
valueMatchersRegistry that contains all of the built in value matchers.
VAR_CALC
VAR_CELL_PREFIX
VAR_FIELD_LABELS
VAR_FIELD_NAME
VAR_SERIES_NAME

Type Aliases

Type AliasDescription
AlertErrorPayload
AlertPayload
AnnotationEventMappings
BinaryOperation
DataQueryResponseData
DataSourceOptionsType
DataSourceQueryType
DateTimeInput
DecimalCount
Dimensions
DisplayProcessor
DurationInput
DurationUnit
ExploreQueryFieldProps
FieldColorSeriesByMode(BETA)
FieldMatcher
FormatInput
FrameMatcher
GraphSeriesValue
InterpolateFunction
KeyValue
LayoutMode
LegacyResponseDataStarting in v6.2 DataFrame can represent both TimeSeries and TableData
LinkTarget
LiveChannelEvent
MutableField
NavIndex
PanelMigrationHandlerCalled when a panel is first loaded with current panel model
PanelOptionEditorsRegistry
PanelTypeChangedHandlerCalled before a panel is initialized. Allows panel inspection for any updates before changing the panel type.
PreferredVisualisationType
PreloadPluginDescribes the plugins that should be preloaded prior to start Grafana.
SliderMarks
SplitOpenSplitOpen type is used in Explore and related components.
StandardOptionConfig(BETA)
ThemeBreakpointsKey(BETA)
ThemeZIndices(BETA)
TimeFragment
TimeSeriesPoints
TimeSeriesValue
TimeZone
TimeZoneBrowser
TimeZoneResolverThe type to describe the time zone resolver function that will be used to access the default time zone of a user.
TimeZoneUtc
TraceKeyValuePairType representing a tag in a trace span or fields of a log.
TraceLogType representing a log in a span.
UrlQueryMapType to represent the values parsed from the query string.
UrlQueryValueType to represent the value of a single query variable.
ValueConverter
ValueFormatter
ValueMatcherValue matcher type to describe the matcher function
VariableType