dashboard

package
v0.0.0-testrgm3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2023 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const HandoffSchemaVersion = 36

HandoffSchemaVersion is the minimum schemaVersion for dashboards at which the Thema-based dashboard schema is possibly valid

schemaVersion is the original version numbering system for dashboards. If a dashboard is below this schemaVersion, it is necessary for the frontend typescript dashboard migration logic to first run and get it past this number, after which Thema can take over.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnnotationContainer

type AnnotationContainer struct {
	// List of annotations
	List []AnnotationQuery `json:"list,omitempty"`
}

Contains the list of annotations that are associated with the dashboard. Annotations are used to overlay event markers and overlay event tags on graphs. Grafana comes with a native annotation store and the ability to add annotation events directly from the graph panel or via the HTTP API. See https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/annotate-visualizations/

type AnnotationPanelFilter

type AnnotationPanelFilter struct {
	// Should the specified panels be included or excluded
	Exclude *bool `json:"exclude,omitempty"`

	// Panel IDs that should be included or excluded
	Ids []int `json:"ids"`
}

AnnotationPanelFilter defines model for AnnotationPanelFilter.

type AnnotationQuery

type AnnotationQuery struct {
	// Ref to a DataSource instance
	Datasource DataSourceRef `json:"datasource"`

	// When enabled the annotation query is issued with every dashboard refresh
	Enable bool                   `json:"enable"`
	Filter *AnnotationPanelFilter `json:"filter,omitempty"`

	// Annotation queries can be toggled on or off at the top of the dashboard.
	// When hide is true, the toggle is not shown in the dashboard.
	Hide *bool `json:"hide,omitempty"`

	// Color to use for the annotation event markers
	IconColor string `json:"iconColor"`

	// Name of annotation.
	Name string `json:"name"`

	// TODO: this should be a regular DataQuery that depends on the selected dashboard
	// these match the properties of the "grafana" datasouce that is default in most dashboards
	Target *AnnotationTarget `json:"target,omitempty"`

	// TODO -- this should not exist here, it is based on the --grafana-- datasource
	Type *string `json:"type,omitempty"`
}

TODO docs FROM: AnnotationQuery in grafana-data/src/types/annotations.ts

type AnnotationTarget

type AnnotationTarget struct {
	// Only required/valid for the grafana datasource...
	// but code+tests is already depending on it so hard to change
	Limit int64 `json:"limit"`

	// Only required/valid for the grafana datasource...
	// but code+tests is already depending on it so hard to change
	MatchAny bool `json:"matchAny"`

	// Only required/valid for the grafana datasource...
	// but code+tests is already depending on it so hard to change
	Tags []string `json:"tags"`

	// Only required/valid for the grafana datasource...
	// but code+tests is already depending on it so hard to change
	Type string `json:"type"`
}

TODO: this should be a regular DataQuery that depends on the selected dashboard these match the properties of the "grafana" datasouce that is default in most dashboards

type CursorSync

type CursorSync int

0 for no shared crosshair or tooltip (default). 1 for shared crosshair. 2 for shared crosshair AND shared tooltip.

const (
	CursorSyncN0 CursorSync = 0
	CursorSyncN1 CursorSync = 1
	CursorSyncN2 CursorSync = 2
)

Defines values for CursorSync.

type DataSourceRef

type DataSourceRef struct {
	// The plugin type-id
	Type *string `json:"type,omitempty"`

	// Specific datasource instance
	Uid *string `json:"uid,omitempty"`
}

Ref to a DataSource instance

type DataTransformerConfig

type DataTransformerConfig struct {
	// Disabled transformations are skipped
	Disabled *bool `json:"disabled,omitempty"`

	// Matcher is a predicate configuration. Based on the config a set of field(s) or values is filtered in order to apply override / transformation.
	// It comes with in id ( to resolve implementation from registry) and a configuration that’s specific to a particular matcher type.
	Filter *MatcherConfig `json:"filter,omitempty"`

	// Unique identifier of transformer
	Id string `json:"id"`

	// Options to be passed to the transformer
	// Valid options depend on the transformer id
	Options any `json:"options"`
}

Transformations allow to manipulate data returned by a query before the system applies a visualization. Using transformations you can: rename fields, join time series data, perform mathematical operations across queries, use the output of one transformation as the input to another transformation, etc.

type DynamicConfigValue

type DynamicConfigValue struct {
	Id    string `json:"id"`
	Value *any   `json:"value,omitempty"`
}

DynamicConfigValue defines model for DynamicConfigValue.

type FieldColor

type FieldColor struct {
	// The fixed color value for fixed or shades color modes.
	FixedColor *string `json:"fixedColor,omitempty"`

	// Color mode for a field. You can specify a single color, or select a continuous (gradient) color schemes, based on a value.
	// Continuous color interpolates a color using the percentage of a value relative to min and max.
	// Accepted values are:
	// `thresholds`: From thresholds. Informs Grafana to take the color from the matching threshold
	// `palette-classic`: Classic palette. Grafana will assign color by looking up a color in a palette by series index. Useful for Graphs and pie charts and other categorical data visualizations
	// `palette-classic-by-name`: Classic palette (by name). Grafana will assign color by looking up a color in a palette by series name. Useful for Graphs and pie charts and other categorical data visualizations
	// `continuous-GrYlRd`: ontinuous Green-Yellow-Red palette mode
	// `continuous-RdYlGr`: Continuous Red-Yellow-Green palette mode
	// `continuous-BlYlRd`: Continuous Blue-Yellow-Red palette mode
	// `continuous-YlRd`: Continuous Yellow-Red palette mode
	// `continuous-BlPu`: Continuous Blue-Purple palette mode
	// `continuous-YlBl`: Continuous Yellow-Blue palette mode
	// `continuous-blues`: Continuous Blue palette mode
	// `continuous-reds`: Continuous Red palette mode
	// `continuous-greens`: Continuous Green palette mode
	// `continuous-purples`: Continuous Purple palette mode
	// `shades`: Shades of a single color. Specify a single color, useful in an override rule.
	// `fixed`: Fixed color mode. Specify a single color, useful in an override rule.
	Mode FieldColorModeId `json:"mode"`

	// Defines how to assign a series color from "by value" color schemes. For example for an aggregated data points like a timeseries, the color can be assigned by the min, max or last value.
	SeriesBy *FieldColorSeriesByMode `json:"seriesBy,omitempty"`
}

Map a field to a color.

type FieldColorModeId

type FieldColorModeId string

Color mode for a field. You can specify a single color, or select a continuous (gradient) color schemes, based on a value. Continuous color interpolates a color using the percentage of a value relative to min and max. Accepted values are: `thresholds`: From thresholds. Informs Grafana to take the color from the matching threshold `palette-classic`: Classic palette. Grafana will assign color by looking up a color in a palette by series index. Useful for Graphs and pie charts and other categorical data visualizations `palette-classic-by-name`: Classic palette (by name). Grafana will assign color by looking up a color in a palette by series name. Useful for Graphs and pie charts and other categorical data visualizations `continuous-GrYlRd`: ontinuous Green-Yellow-Red palette mode `continuous-RdYlGr`: Continuous Red-Yellow-Green palette mode `continuous-BlYlRd`: Continuous Blue-Yellow-Red palette mode `continuous-YlRd`: Continuous Yellow-Red palette mode `continuous-BlPu`: Continuous Blue-Purple palette mode `continuous-YlBl`: Continuous Yellow-Blue palette mode `continuous-blues`: Continuous Blue palette mode `continuous-reds`: Continuous Red palette mode `continuous-greens`: Continuous Green palette mode `continuous-purples`: Continuous Purple palette mode `shades`: Shades of a single color. Specify a single color, useful in an override rule. `fixed`: Fixed color mode. Specify a single color, useful in an override rule.

const (
	FieldColorModeIdContinuousBlPu       FieldColorModeId = "continuous-BlPu"
	FieldColorModeIdContinuousBlYlRd     FieldColorModeId = "continuous-BlYlRd"
	FieldColorModeIdContinuousBlues      FieldColorModeId = "continuous-blues"
	FieldColorModeIdContinuousGrYlRd     FieldColorModeId = "continuous-GrYlRd"
	FieldColorModeIdContinuousGreens     FieldColorModeId = "continuous-greens"
	FieldColorModeIdContinuousPurples    FieldColorModeId = "continuous-purples"
	FieldColorModeIdContinuousRdYlGr     FieldColorModeId = "continuous-RdYlGr"
	FieldColorModeIdContinuousReds       FieldColorModeId = "continuous-reds"
	FieldColorModeIdContinuousYlBl       FieldColorModeId = "continuous-YlBl"
	FieldColorModeIdContinuousYlRd       FieldColorModeId = "continuous-YlRd"
	FieldColorModeIdFixed                FieldColorModeId = "fixed"
	FieldColorModeIdPaletteClassic       FieldColorModeId = "palette-classic"
	FieldColorModeIdPaletteClassicByName FieldColorModeId = "palette-classic-by-name"
	FieldColorModeIdShades               FieldColorModeId = "shades"
	FieldColorModeIdThresholds           FieldColorModeId = "thresholds"
)

Defines values for FieldColorModeId.

type FieldColorSeriesByMode

type FieldColorSeriesByMode string

Defines how to assign a series color from "by value" color schemes. For example for an aggregated data points like a timeseries, the color can be assigned by the min, max or last value.

const (
	FieldColorSeriesByModeLast FieldColorSeriesByMode = "last"
	FieldColorSeriesByModeMax  FieldColorSeriesByMode = "max"
	FieldColorSeriesByModeMin  FieldColorSeriesByMode = "min"
)

Defines values for FieldColorSeriesByMode.

type FieldConfig

type FieldConfig struct {
	// Map a field to a color.
	Color *FieldColor `json:"color,omitempty"`

	// custom is specified by the FieldConfig field
	// in panel plugin schemas.
	Custom map[string]any `json:"custom,omitempty"`

	// Specify the number of decimals Grafana includes in the rendered value.
	// If you leave this field blank, Grafana automatically truncates the number of decimals based on the value.
	// For example 1.1234 will display as 1.12 and 100.456 will display as 100.
	// To display all decimals, set the unit to `String`.
	Decimals *float32 `json:"decimals,omitempty"`

	// Human readable field metadata
	Description *string `json:"description,omitempty"`

	// The display value for this field.  This supports template variables blank is auto
	DisplayName *string `json:"displayName,omitempty"`

	// This can be used by data sources that return and explicit naming structure for values and labels
	// When this property is configured, this value is used rather than the default naming strategy.
	DisplayNameFromDS *string `json:"displayNameFromDS,omitempty"`

	// True if data source field supports ad-hoc filters
	Filterable *bool `json:"filterable,omitempty"`

	// The behavior when clicking on a result
	Links []any `json:"links,omitempty"`

	// Convert input values into a display string
	Mappings []any `json:"mappings,omitempty"`

	// The maximum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields.
	Max *float32 `json:"max,omitempty"`

	// The minimum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields.
	Min *float32 `json:"min,omitempty"`

	// Alternative to empty string
	NoValue *string `json:"noValue,omitempty"`

	// An explicit path to the field in the datasource.  When the frame meta includes a path,
	// This will default to `${frame.meta.path}/${field.name}
	//
	// When defined, this value can be used as an identifier within the datasource scope, and
	// may be used to update the results
	Path *string `json:"path,omitempty"`

	// Thresholds configuration for the panel
	Thresholds *ThresholdsConfig `json:"thresholds,omitempty"`

	// Unit a field should use. The unit you select is applied to all fields except time.
	// You can use the units ID availables in Grafana or a custom unit.
	// Available units in Grafana: https://github.com/grafana/grafana/blob/main/packages/grafana-data/src/valueFormats/categories.ts
	// As custom unit, you can use the following formats:
	// `suffix:<suffix>` for custom unit that should go after value.
	// `prefix:<prefix>` for custom unit that should go before value.
	// `time:<format>` For custom date time formats type for example `time:YYYY-MM-DD`.
	// `si:<base scale><unit characters>` for custom SI units. For example: `si: mF`. This one is a bit more advanced as you can specify both a unit and the source data scale. So if your source data is represented as milli (thousands of) something prefix the unit with that SI scale character.
	// `count:<unit>` for a custom count unit.
	// `currency:<unit>` for custom a currency unit.
	Unit *string `json:"unit,omitempty"`

	// True if data source can write a value to the path. Auth/authz are supported separately
	Writeable *bool `json:"writeable,omitempty"`
}

The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results. Each column within this structure is called a field. A field can represent a single time series or table column. Field options allow you to change how the data is displayed in your visualizations.

type FieldConfigSource

type FieldConfigSource struct {
	// The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.
	// Each column within this structure is called a field. A field can represent a single time series or table column.
	// Field options allow you to change how the data is displayed in your visualizations.
	Defaults FieldConfig `json:"defaults"`

	// Overrides are the options applied to specific fields overriding the defaults.
	Overrides []struct {
		// Matcher is a predicate configuration. Based on the config a set of field(s) or values is filtered in order to apply override / transformation.
		// It comes with in id ( to resolve implementation from registry) and a configuration that’s specific to a particular matcher type.
		Matcher    MatcherConfig        `json:"matcher"`
		Properties []DynamicConfigValue `json:"properties"`
	} `json:"overrides"`
}

The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results. Each column within this structure is called a field. A field can represent a single time series or table column. Field options allow you to change how the data is displayed in your visualizations.

type GraphPanel

type GraphPanel struct {
	// @deprecated this is part of deprecated graph panel
	Legend *struct {
		Show     bool    `json:"show"`
		Sort     *string `json:"sort,omitempty"`
		SortDesc *bool   `json:"sortDesc,omitempty"`
	} `json:"legend,omitempty"`
	Type GraphPanelType `json:"type"`
}

Support for legacy graph panel. @deprecated this a deprecated panel type

type GraphPanelType

type GraphPanelType string

GraphPanelType defines model for GraphPanel.Type.

const (
	GraphPanelTypeGraph GraphPanelType = "graph"
)

Defines values for GraphPanelType.

type GridPos

type GridPos struct {
	// Panel height. The height is the number of rows from the top edge of the panel.
	H int `json:"h"`

	// Whether the panel is fixed within the grid. If true, the panel will not be affected by other panels' interactions
	Static *bool `json:"static,omitempty"`

	// Panel width. The width is the number of columns from the left edge of the panel.
	W int `json:"w"`

	// Panel x. The x coordinate is the number of columns from the left edge of the grid
	X int `json:"x"`

	// Panel y. The y coordinate is the number of rows from the top edge of the grid
	Y int `json:"y"`
}

Position and dimensions of a panel in the grid

type HeatmapPanel

type HeatmapPanel struct {
	Type HeatmapPanelType `json:"type"`
}

Support for legacy heatmap panel. @deprecated this a deprecated panel type

type HeatmapPanelType

type HeatmapPanelType string

HeatmapPanelType defines model for HeatmapPanel.Type.

const (
	HeatmapPanelTypeHeatmap HeatmapPanelType = "heatmap"
)

Defines values for HeatmapPanelType.

type K8sResource

type K8sResource = kinds.GrafanaResource[Spec, Status]

Resource is the kubernetes style representation of Dashboard. (TODO be better)

func NewK8sResource

func NewK8sResource(name string, s *Spec) K8sResource

NewResource creates a new instance of the resource with a given name (UID)

type Kind

type Kind struct {
	kindsys.Core
	// contains filtered or unexported fields
}

TODO standard generated docs

func NewKind

func NewKind(rt *thema.Runtime, opts ...thema.BindOption) (*Kind, error)

TODO standard generated docs

func (*Kind) ConvergentLineage

func (k *Kind) ConvergentLineage() thema.ConvergentLineage[*Resource]

ConvergentLineage returns the same thema.Lineage as Lineage, but bound (see thema.BindType) to the the Dashboard Resource type generated from the current schema, v0.0.

func (*Kind) JSONValueMux

func (k *Kind) JSONValueMux(b []byte) (*Resource, thema.TranslationLacunas, error)

JSONValueMux is a version multiplexer that maps a []byte containing JSON data at any schematized dashboard version to an instance of Dashboard Resource.

Validation and translation errors emitted from this func will identify the input bytes as "dashboard.json".

This is a thin wrapper around Thema's vmux.ValueMux.

type KubeObjectMetadata

type KubeObjectMetadata struct {
	CreationTimestamp time.Time         `json:"creationTimestamp"`
	DeletionTimestamp *time.Time        `json:"deletionTimestamp,omitempty"`
	Finalizers        []string          `json:"finalizers"`
	Labels            map[string]string `json:"labels"`
	ResourceVersion   string            `json:"resourceVersion"`
	Uid               string            `json:"uid"`
}

_kubeObjectMetadata is metadata found in a kubernetes object's metadata field. It is not exhaustive and only includes fields which may be relevant to a kind's implementation, As it is also intended to be generic enough to function with any API Server.

type LibraryPanelRef

type LibraryPanelRef struct {
	// Library panel name
	Name string `json:"name"`

	// Library panel uid
	Uid string `json:"uid"`
}

A library panel is a reusable panel that you can use in any dashboard. When you make a change to a library panel, that change propagates to all instances of where the panel is used. Library panels streamline reuse of panels across multiple dashboards.

type Link struct {
	// If true, all dashboards links will be displayed in a dropdown. If false, all dashboards links will be displayed side by side. Only valid if the type is dashboards
	AsDropdown bool `json:"asDropdown"`

	// Icon name to be displayed with the link
	Icon string `json:"icon"`

	// If true, includes current template variables values in the link as query params
	IncludeVars bool `json:"includeVars"`

	// If true, includes current time range in the link as query params
	KeepTime bool `json:"keepTime"`

	// List of tags to limit the linked dashboards. If empty, all dashboards will be displayed. Only valid if the type is dashboards
	Tags []string `json:"tags"`

	// If true, the link will be opened in a new tab
	TargetBlank bool `json:"targetBlank"`

	// Title to display with the link
	Title string `json:"title"`

	// Tooltip to display when the user hovers their mouse over it
	Tooltip string `json:"tooltip"`

	// Dashboard Link type. Accepted values are dashboards (to refer to another dashboard) and link (to refer to an external resource)
	Type LinkType `json:"type"`

	// Link URL. Only required/valid if the type is link
	Url string `json:"url"`
}

Links with references to other dashboards or external resources

type LinkType

type LinkType string

Dashboard Link type. Accepted values are dashboards (to refer to another dashboard) and link (to refer to an external resource)

const (
	LinkTypeDashboards LinkType = "dashboards"
	LinkTypeLink       LinkType = "link"
)

Defines values for LinkType.

type MappingType

type MappingType string

Supported value mapping types `value`: Maps text values to a color or different display text and color. For example, you can configure a value mapping so that all instances of the value 10 appear as Perfection! rather than the number. `range`: Maps numerical ranges to a display text and color. For example, if a value is within a certain range, you can configure a range value mapping to display Low or High rather than the number. `regex`: Maps regular expressions to replacement text and a color. For example, if a value is www.example.com, you can configure a regex value mapping so that Grafana displays www and truncates the domain. `special`: Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text and color. See SpecialValueMatch to see the list of special values. For example, you can configure a special value mapping so that null values appear as N/A.

const (
	MappingTypeRange   MappingType = "range"
	MappingTypeRegex   MappingType = "regex"
	MappingTypeSpecial MappingType = "special"
	MappingTypeValue   MappingType = "value"
)

Defines values for MappingType.

type MatcherConfig

type MatcherConfig struct {
	// The matcher id. This is used to find the matcher implementation from registry.
	Id string `json:"id"`

	// The matcher options. This is specific to the matcher implementation.
	Options *any `json:"options,omitempty"`
}

Matcher is a predicate configuration. Based on the config a set of field(s) or values is filtered in order to apply override / transformation. It comes with in id ( to resolve implementation from registry) and a configuration that’s specific to a particular matcher type.

type Metadata

type Metadata struct {
	CreatedBy         string     `json:"createdBy"`
	CreationTimestamp time.Time  `json:"creationTimestamp"`
	DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"`

	// extraFields is reserved for any fields that are pulled from the API server metadata but do not have concrete fields in the CUE metadata
	ExtraFields     map[string]any    `json:"extraFields"`
	Finalizers      []string          `json:"finalizers"`
	Labels          map[string]string `json:"labels"`
	ResourceVersion string            `json:"resourceVersion"`
	Uid             string            `json:"uid"`
	UpdateTimestamp time.Time         `json:"updateTimestamp"`
	UpdatedBy       string            `json:"updatedBy"`
}

Metadata defines model for Metadata.

type OperatorState

type OperatorState struct {
	// descriptiveState is an optional more descriptive state field which has no requirements on format
	DescriptiveState *string `json:"descriptiveState,omitempty"`

	// details contains any extra information that is operator-specific
	Details map[string]any `json:"details,omitempty"`

	// lastEvaluation is the ResourceVersion last evaluated
	LastEvaluation string `json:"lastEvaluation"`

	// state describes the state of the lastEvaluation.
	// It is limited to three possible states for machine evaluation.
	State OperatorStateState `json:"state"`
}

OperatorState defines model for OperatorState.

type OperatorStateState

type OperatorStateState string

OperatorStateState state describes the state of the lastEvaluation. It is limited to three possible states for machine evaluation.

const (
	OperatorStateStateFailed     OperatorStateState = "failed"
	OperatorStateStateInProgress OperatorStateState = "in_progress"
	OperatorStateStateSuccess    OperatorStateState = "success"
)

Defines values for OperatorStateState.

type Panel

type Panel struct {
	// Ref to a DataSource instance
	Datasource *DataSourceRef `json:"datasource,omitempty"`

	// Panel description.
	Description *string `json:"description,omitempty"`

	// The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.
	// Each column within this structure is called a field. A field can represent a single time series or table column.
	// Field options allow you to change how the data is displayed in your visualizations.
	FieldConfig FieldConfigSource `json:"fieldConfig"`

	// Position and dimensions of a panel in the grid
	GridPos *GridPos `json:"gridPos,omitempty"`

	// Unique identifier of the panel. Generated by Grafana when creating a new panel. It must be unique within a dashboard, but not globally.
	Id *int `json:"id,omitempty"`

	// The min time interval setting defines a lower limit for the $__interval and $__interval_ms variables.
	// This value must be formatted as a number followed by a valid time
	// identifier like: "40s", "3d", etc.
	// See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options
	Interval *string `json:"interval,omitempty"`

	// A library panel is a reusable panel that you can use in any dashboard.
	// When you make a change to a library panel, that change propagates to all instances of where the panel is used.
	// Library panels streamline reuse of panels across multiple dashboards.
	LibraryPanel *LibraryPanelRef `json:"libraryPanel,omitempty"`

	// Panel links.
	Links []Link `json:"links,omitempty"`

	// The maximum number of data points that the panel queries are retrieving.
	MaxDataPoints *float32 `json:"maxDataPoints,omitempty"`

	// It depends on the panel plugin. They are specified by the Options field in panel plugin schemas.
	Options map[string]any `json:"options"`

	// The version of the plugin that is used for this panel. This is used to find the plugin to display the panel and to migrate old panel configs.
	PluginVersion *string `json:"pluginVersion,omitempty"`

	// Name of template variable to repeat for.
	Repeat *string `json:"repeat,omitempty"`

	// Direction to repeat in if 'repeat' is set.
	// `h` for horizontal, `v` for vertical.
	RepeatDirection *PanelRepeatDirection `json:"repeatDirection,omitempty"`

	// Id of the repeating panel.
	RepeatPanelId *int64 `json:"repeatPanelId,omitempty"`

	// Tags for the panel.
	Tags []string `json:"tags,omitempty"`

	// Depends on the panel plugin. See the plugin documentation for details.
	Targets []Target `json:"targets,omitempty"`

	// Overrides the relative time range for individual panels,
	// which causes them to be different than what is selected in
	// the dashboard time picker in the top-right corner of the dashboard. You can use this to show metrics from different
	// time periods or days on the same dashboard.
	// The value is formatted as time operation like: `now-5m` (Last 5 minutes), `now/d` (the day so far),
	// `now-5d/d`(Last 5 days), `now/w` (This week so far), `now-2y/y` (Last 2 years).
	// Note: Panel time overrides have no effect when the dashboard’s time range is absolute.
	// See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options
	TimeFrom *string `json:"timeFrom,omitempty"`

	// Overrides the time range for individual panels by shifting its start and end relative to the time picker.
	// For example, you can shift the time range for the panel to be two hours earlier than the dashboard time picker setting `2h`.
	// Note: Panel time overrides have no effect when the dashboard’s time range is absolute.
	// See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options
	TimeShift *string `json:"timeShift,omitempty"`

	// Panel title.
	Title *string `json:"title,omitempty"`

	// List of transformations that are applied to the panel data before rendering.
	// When there are multiple transformations, Grafana applies them in the order they are listed.
	// Each transformation creates a result set that then passes on to the next transformation in the processing pipeline.
	Transformations []DataTransformerConfig `json:"transformations"`

	// Whether to display the panel without a background.
	Transparent bool `json:"transparent"`

	// The panel plugin type id. This is used to find the plugin to display the panel.
	Type string `json:"type"`
}

Dashboard panels are the basic visualization building blocks.

type PanelRepeatDirection

type PanelRepeatDirection string

Direction to repeat in if 'repeat' is set. `h` for horizontal, `v` for vertical.

const (
	PanelRepeatDirectionH PanelRepeatDirection = "h"
	PanelRepeatDirectionV PanelRepeatDirection = "v"
)

Defines values for PanelRepeatDirection.

type RangeMap

type RangeMap struct {
	// Range to match against and the result to apply when the value is within the range
	Options struct {
		// Min value of the range. It can be null which means -Infinity
		From *float64 `json:"from"`

		// Result used as replacement with text and color when the value matches
		Result ValueMappingResult `json:"result"`

		// Max value of the range. It can be null which means +Infinity
		To *float64 `json:"to"`
	} `json:"options"`
	Type RangeMapType `json:"type"`
}

Maps numerical ranges to a display text and color. For example, if a value is within a certain range, you can configure a range value mapping to display Low or High rather than the number.

type RangeMapType

type RangeMapType string

RangeMapType defines model for RangeMap.Type.

const (
	RangeMapTypeRange   RangeMapType = "range"
	RangeMapTypeRegex   RangeMapType = "regex"
	RangeMapTypeSpecial RangeMapType = "special"
	RangeMapTypeValue   RangeMapType = "value"
)

Defines values for RangeMapType.

type RegexMap

type RegexMap struct {
	// Regular expression to match against and the result to apply when the value matches the regex
	Options struct {
		// Regular expression to match against
		Pattern string `json:"pattern"`

		// Result used as replacement with text and color when the value matches
		Result ValueMappingResult `json:"result"`
	} `json:"options"`
	Type RegexMapType `json:"type"`
}

Maps regular expressions to replacement text and a color. For example, if a value is www.example.com, you can configure a regex value mapping so that Grafana displays www and truncates the domain.

type RegexMapType

type RegexMapType string

RegexMapType defines model for RegexMap.Type.

const (
	RegexMapTypeRange   RegexMapType = "range"
	RegexMapTypeRegex   RegexMapType = "regex"
	RegexMapTypeSpecial RegexMapType = "special"
	RegexMapTypeValue   RegexMapType = "value"
)

Defines values for RegexMapType.

type Resource

type Resource struct {
	Metadata Metadata `json:"metadata"`
	Spec     Spec     `json:"spec"`
	Status   Status   `json:"status"`
}

Resource is the wire representation of Dashboard. It currently will soon be merged into the k8s flavor (TODO be better)

type RowPanel

type RowPanel struct {
	// Whether this row should be collapsed or not.
	Collapsed bool `json:"collapsed"`

	// Ref to a DataSource instance
	Datasource *DataSourceRef `json:"datasource,omitempty"`

	// Position and dimensions of a panel in the grid
	GridPos *GridPos `json:"gridPos,omitempty"`

	// Unique identifier of the panel. Generated by Grafana when creating a new panel. It must be unique within a dashboard, but not globally.
	Id int `json:"id"`

	// List of panels in the row
	Panels []any `json:"panels"`

	// Name of template variable to repeat for.
	Repeat *string `json:"repeat,omitempty"`

	// Row title
	Title *string `json:"title,omitempty"`

	// The panel type
	Type RowPanelType `json:"type"`
}

Row panel

type RowPanelType

type RowPanelType string

The panel type

const (
	RowPanelTypeRow RowPanelType = "row"
)

Defines values for RowPanelType.

type Snapshot

type Snapshot struct {
	// Time when the snapshot was created
	Created time.Time `json:"created"`

	// Time when the snapshot expires, default is never to expire
	Expires string `json:"expires"`

	// Is the snapshot saved in an external grafana instance
	External bool `json:"external"`

	// ExternalUrl external url, if snapshot was shared in external grafana instance
	ExternalUrl string `json:"externalUrl"`

	// Unique identifier of the snapshot
	Id int `json:"id"`

	// Optional, defined the unique key of the snapshot, required if external is true
	Key string `json:"key"`

	// Optional, name of the snapshot
	Name string `json:"name"`

	// OrgId org id of the snapshot
	OrgId int `json:"orgId"`

	// Updated last time when the snapshot was updated
	Updated time.Time `json:"updated"`

	// url of the snapshot, if snapshot was shared internally
	Url *string `json:"url,omitempty"`

	// UserId user id of the snapshot creator
	UserId int `json:"userId"`
}

A dashboard snapshot shares an interactive dashboard publicly. It is a read-only version of a dashboard, and is not editable. It is possible to create a snapshot of a snapshot. Grafana strips away all sensitive information from the dashboard. Sensitive information stripped: queries (metric, template,annotation) and panel links.

type Spec

type Spec struct {
	// Contains the list of annotations that are associated with the dashboard.
	// Annotations are used to overlay event markers and overlay event tags on graphs.
	// Grafana comes with a native annotation store and the ability to add annotation events directly from the graph panel or via the HTTP API.
	// See https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/annotate-visualizations/
	Annotations *AnnotationContainer `json:"annotations,omitempty"`

	// Description of dashboard.
	Description *string `json:"description,omitempty"`

	// Whether a dashboard is editable or not.
	Editable bool `json:"editable"`

	// The month that the fiscal year starts on.  0 = January, 11 = December
	FiscalYearStartMonth *int `json:"fiscalYearStartMonth,omitempty"`

	// ID of a dashboard imported from the https://grafana.com/grafana/dashboards/ portal
	GnetId *string `json:"gnetId,omitempty"`

	// 0 for no shared crosshair or tooltip (default).
	// 1 for shared crosshair.
	// 2 for shared crosshair AND shared tooltip.
	GraphTooltip CursorSync `json:"graphTooltip"`

	// Unique numeric identifier for the dashboard.
	// `id` is internal to a specific Grafana instance. `uid` should be used to identify a dashboard across Grafana instances.
	Id *int64 `json:"id"`

	// Links with references to other dashboards or external websites.
	Links []Link `json:"links,omitempty"`

	// When set to true, the dashboard will redraw panels at an interval matching the pixel width.
	// This will keep data "moving left" regardless of the query refresh rate. This setting helps
	// avoid dashboards presenting stale live data
	LiveNow *bool `json:"liveNow,omitempty"`

	// List of dashboard panels
	Panels []any `json:"panels,omitempty"`

	// Refresh rate of dashboard. Represented via interval string, e.g. "5s", "1m", "1h", "1d".
	Refresh *any `json:"refresh,omitempty"`

	// This property should only be used in dashboards defined by plugins.  It is a quick check
	// to see if the version has changed since the last time.
	Revision *int64 `json:"revision,omitempty"`

	// Version of the JSON schema, incremented each time a Grafana update brings
	// changes to said schema.
	SchemaVersion int `json:"schemaVersion"`

	// A dashboard snapshot shares an interactive dashboard publicly.
	// It is a read-only version of a dashboard, and is not editable.
	// It is possible to create a snapshot of a snapshot.
	// Grafana strips away all sensitive information from the dashboard.
	// Sensitive information stripped: queries (metric, template,annotation) and panel links.
	Snapshot *Snapshot `json:"snapshot,omitempty"`

	// Theme of dashboard.
	// Default value: dark.
	Style SpecStyle `json:"style"`

	// Tags associated with dashboard.
	Tags []string `json:"tags,omitempty"`

	// Configured template variables
	Templating *struct {
		// List of configured template variables with their saved values along with some other metadata
		List []VariableModel `json:"list,omitempty"`
	} `json:"templating,omitempty"`

	// Time range for dashboard.
	// Accepted values are relative time strings like {from: 'now-6h', to: 'now'} or absolute time strings like {from: '2020-07-10T08:00:00.000Z', to: '2020-07-10T14:00:00.000Z'}.
	Time *struct {
		From string `json:"from"`
		To   string `json:"to"`
	} `json:"time,omitempty"`

	// Configuration of the time picker shown at the top of a dashboard.
	Timepicker *struct {
		// Whether timepicker is collapsed or not. Has no effect on provisioned dashboard.
		Collapse bool `json:"collapse"`

		// Whether timepicker is enabled or not. Has no effect on provisioned dashboard.
		Enable bool `json:"enable"`

		// Whether timepicker is visible or not.
		Hidden bool `json:"hidden"`

		// Interval options available in the refresh picker dropdown.
		RefreshIntervals []string `json:"refresh_intervals"`

		// Selectable options available in the time picker dropdown. Has no effect on provisioned dashboard.
		TimeOptions []string `json:"time_options"`
	} `json:"timepicker,omitempty"`

	// Timezone of dashboard. Accepted values are IANA TZDB zone ID or "browser" or "utc".
	Timezone *string `json:"timezone,omitempty"`

	// Title of dashboard.
	Title *string `json:"title,omitempty"`

	// Unique dashboard identifier that can be generated by anyone. string (8-40)
	Uid *string `json:"uid,omitempty"`

	// Version of the dashboard, incremented each time the dashboard is updated.
	Version *int `json:"version,omitempty"`

	// Day when the week starts. Expressed by the name of the day in lowercase, e.g. "monday".
	WeekStart *string `json:"weekStart,omitempty"`
}

Spec defines model for Spec.

type SpecStyle

type SpecStyle string

Theme of dashboard. Default value: dark.

const (
	SpecStyleDark  SpecStyle = "dark"
	SpecStyleLight SpecStyle = "light"
)

Defines values for SpecStyle.

type SpecialValueMap

type SpecialValueMap struct {
	Options struct {
		// Special value types supported by the `SpecialValueMap`
		Match SpecialValueMatch `json:"match"`

		// Result used as replacement with text and color when the value matches
		Result ValueMappingResult `json:"result"`
	} `json:"options"`
	Type SpecialValueMapType `json:"type"`
}

Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text and color. See SpecialValueMatch to see the list of special values. For example, you can configure a special value mapping so that null values appear as N/A.

type SpecialValueMapType

type SpecialValueMapType string

SpecialValueMapType defines model for SpecialValueMap.Type.

const (
	SpecialValueMapTypeRange   SpecialValueMapType = "range"
	SpecialValueMapTypeRegex   SpecialValueMapType = "regex"
	SpecialValueMapTypeSpecial SpecialValueMapType = "special"
	SpecialValueMapTypeValue   SpecialValueMapType = "value"
)

Defines values for SpecialValueMapType.

type SpecialValueMatch

type SpecialValueMatch string

Special value types supported by the `SpecialValueMap`

const (
	SpecialValueMatchEmpty   SpecialValueMatch = "empty"
	SpecialValueMatchFalse   SpecialValueMatch = "false"
	SpecialValueMatchNan     SpecialValueMatch = "nan"
	SpecialValueMatchNull    SpecialValueMatch = "null"
	SpecialValueMatchNullNan SpecialValueMatch = "null+nan"
	SpecialValueMatchTrue    SpecialValueMatch = "true"
)

Defines values for SpecialValueMatch.

type Status

type Status struct {
	// additionalFields is reserved for future use
	AdditionalFields map[string]any `json:"additionalFields,omitempty"`

	// operatorStates is a map of operator ID to operator state evaluations.
	// Any operator which consumes this kind SHOULD add its state evaluation information to this field.
	OperatorStates map[string]StatusOperatorState `json:"operatorStates,omitempty"`
}

Status defines model for Status.

type StatusOperatorState

type StatusOperatorState struct {
	// descriptiveState is an optional more descriptive state field which has no requirements on format
	DescriptiveState *string `json:"descriptiveState,omitempty"`

	// details contains any extra information that is operator-specific
	Details map[string]any `json:"details,omitempty"`

	// lastEvaluation is the ResourceVersion last evaluated
	LastEvaluation string `json:"lastEvaluation"`

	// state describes the state of the lastEvaluation.
	// It is limited to three possible states for machine evaluation.
	State StatusOperatorStateState `json:"state"`
}

StatusOperatorState defines model for status.#OperatorState.

type StatusOperatorStateState

type StatusOperatorStateState string

StatusOperatorStateState state describes the state of the lastEvaluation. It is limited to three possible states for machine evaluation.

const (
	StatusOperatorStateStateFailed     StatusOperatorStateState = "failed"
	StatusOperatorStateStateInProgress StatusOperatorStateState = "in_progress"
	StatusOperatorStateStateSuccess    StatusOperatorStateState = "success"
)

Defines values for StatusOperatorStateState.

type Target

type Target = map[string]any

Schema for panel targets is specified by datasource plugins. We use a placeholder definition, which the Go schema loader either left open/as-is with the Base variant of the Dashboard and Panel families, or filled with types derived from plugins in the Instance variant. When working directly from CUE, importers can extend this type directly to achieve the same effect.

type Threshold

type Threshold struct {
	// Color represents the color of the visual change that will occur in the dashboard when the threshold value is met or exceeded.
	Color string `json:"color"`

	// Value represents a specified metric for the threshold, which triggers a visual change in the dashboard when this value is met or exceeded.
	// Nulls currently appear here when serializing -Infinity to JSON.
	Value *float32 `json:"value"`
}

User-defined value for a metric that triggers visual changes in a panel when this value is met or exceeded They are used to conditionally style and color visualizations based on query results , and can be applied to most visualizations.

type ThresholdsConfig

type ThresholdsConfig struct {
	// Thresholds can either be `absolute` (specific number) or `percentage` (relative to min or max, it will be values between 0 and 1).
	Mode ThresholdsMode `json:"mode"`

	// Must be sorted by 'value', first value is always -Infinity
	Steps []Threshold `json:"steps"`
}

Thresholds configuration for the panel

type ThresholdsMode

type ThresholdsMode string

Thresholds can either be `absolute` (specific number) or `percentage` (relative to min or max, it will be values between 0 and 1).

const (
	ThresholdsModeAbsolute   ThresholdsMode = "absolute"
	ThresholdsModePercentage ThresholdsMode = "percentage"
)

Defines values for ThresholdsMode.

type ValueMap

type ValueMap struct {
	// Map with <value_to_match>: ValueMappingResult. For example: { "10": { text: "Perfection!", color: "green" } }
	Options map[string]ValueMappingResult `json:"options"`
	Type    ValueMapType                  `json:"type"`
}

Maps text values to a color or different display text and color. For example, you can configure a value mapping so that all instances of the value 10 appear as Perfection! rather than the number.

type ValueMapType

type ValueMapType string

ValueMapType defines model for ValueMap.Type.

const (
	ValueMapTypeRange   ValueMapType = "range"
	ValueMapTypeRegex   ValueMapType = "regex"
	ValueMapTypeSpecial ValueMapType = "special"
	ValueMapTypeValue   ValueMapType = "value"
)

Defines values for ValueMapType.

type ValueMappingResult

type ValueMappingResult struct {
	// Text to use when the value matches
	Color *string `json:"color,omitempty"`

	// Icon to display when the value matches. Only specific visualizations.
	Icon *string `json:"icon,omitempty"`

	// Position in the mapping array. Only used internally.
	Index *int32 `json:"index,omitempty"`

	// Text to display when the value matches
	Text *string `json:"text,omitempty"`
}

Result used as replacement with text and color when the value matches

type VariableHide

type VariableHide int

Determine if the variable shows on dashboard Accepted values are 0 (show label and value), 1 (show value only), 2 (show nothing).

const (
	VariableHideN0 VariableHide = 0
	VariableHideN1 VariableHide = 1
	VariableHideN2 VariableHide = 2
)

Defines values for VariableHide.

type VariableModel

type VariableModel struct {
	// Format to use while fetching all values from data source, eg: wildcard, glob, regex, pipe, etc.
	AllFormat *string `json:"allFormat,omitempty"`

	// Option to be selected in a variable.
	Current *VariableOption `json:"current,omitempty"`

	// Ref to a DataSource instance
	Datasource *DataSourceRef `json:"datasource,omitempty"`

	// Description of variable. It can be defined but `null`.
	Description *string `json:"description,omitempty"`

	// Determine if the variable shows on dashboard
	// Accepted values are 0 (show label and value), 1 (show value only), 2 (show nothing).
	Hide VariableHide `json:"hide"`

	// Unique numeric identifier for the variable.
	Id string `json:"id"`

	// Optional display name
	Label *string `json:"label,omitempty"`

	// Whether multiple values can be selected or not from variable value list
	Multi *bool `json:"multi,omitempty"`

	// Name of variable
	Name string `json:"name"`

	// Options that can be selected for a variable.
	Options []VariableOption `json:"options,omitempty"`

	// Query used to fetch values for a variable
	Query *any `json:"query,omitempty"`

	// Options to config when to refresh a variable
	// `0`: Never refresh the variable
	// `1`: Queries the data source every time the dashboard loads.
	// `2`: Queries the data source when the dashboard time range changes.
	Refresh *VariableRefresh `json:"refresh,omitempty"`

	// Whether the variable value should be managed by URL query params or not
	SkipUrlSync bool `json:"skipUrlSync"`

	// Dashboard variable type
	// `query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on.
	// `adhoc`: Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only).
	// `constant`: 	Define a hidden constant.
	// `datasource`: Quickly change the data source for an entire dashboard.
	// `interval`: Interval variables represent time spans.
	// `textbox`: Display a free text input field with an optional default value.
	// `custom`: Define the variable options manually using a comma-separated list.
	// `system`: Variables defined by Grafana. See: https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#global-variables
	Type VariableType `json:"type"`
}

A variable is a placeholder for a value. You can use variables in metric queries and in panel titles.

type VariableOption

type VariableOption struct {
	// Whether the option is selected or not
	Selected *bool `json:"selected,omitempty"`

	// Text to be displayed for the option
	Text any `json:"text"`

	// Value of the option
	Value any `json:"value"`
}

Option to be selected in a variable.

type VariableRefresh

type VariableRefresh int

Options to config when to refresh a variable `0`: Never refresh the variable `1`: Queries the data source every time the dashboard loads. `2`: Queries the data source when the dashboard time range changes.

const (
	VariableRefreshN0 VariableRefresh = 0
	VariableRefreshN1 VariableRefresh = 1
	VariableRefreshN2 VariableRefresh = 2
)

Defines values for VariableRefresh.

type VariableType

type VariableType string

Dashboard variable type `query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on. `adhoc`: Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only). `constant`: Define a hidden constant. `datasource`: Quickly change the data source for an entire dashboard. `interval`: Interval variables represent time spans. `textbox`: Display a free text input field with an optional default value. `custom`: Define the variable options manually using a comma-separated list. `system`: Variables defined by Grafana. See: https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#global-variables

const (
	VariableTypeAdhoc      VariableType = "adhoc"
	VariableTypeConstant   VariableType = "constant"
	VariableTypeCustom     VariableType = "custom"
	VariableTypeDatasource VariableType = "datasource"
	VariableTypeInterval   VariableType = "interval"
	VariableTypeQuery      VariableType = "query"
	VariableTypeSystem     VariableType = "system"
	VariableTypeTextbox    VariableType = "textbox"
)

Defines values for VariableType.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL