Documentation
¶
Index ¶
- func ExecutePanelScript(cueScript *build.Instance, grafanaPanelData []byte) (*plugin.Plugin, bool, error)
- func ExecuteQueryScript(cueScript *build.Instance, grafanaQueryData []byte) (*plugin.Plugin, bool, error)
- func ExecuteVariableScript(cueScript *build.Instance, grafanaVariableData []byte) (*plugin.Plugin, bool, error)
- func GetPluginKind(migrateFile string) (plugin.Kind, error)
- func Load(pluginPath string, moduleSpec v1.ModuleSpec) ([]schema.LoadSchema, error)
- func LoadMigrateSchema(schemaPath string) (*build.Instance, error)
- func ReplaceInputValue(input map[string]string, grafanaDashboard string) string
- type CurrentValue
- type GrafanaLink
- type GrafanaTimeRange
- type GridPosition
- type LenientString
- type Migration
- type Panel
- type SimplifiedDashboard
- type TemplateVar
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecutePanelScript ¶ added in v0.52.0
func ExecuteQueryScript ¶ added in v0.52.0
func ExecuteVariableScript ¶ added in v0.52.0
func GetPluginKind ¶ added in v0.52.0
GetPluginKind guesses the plugin kind from a migration file based on expected patterns
func Load ¶
func Load(pluginPath string, moduleSpec v1.ModuleSpec) ([]schema.LoadSchema, error)
Types ¶
type CurrentValue ¶
type CurrentValue struct {
Value *variable.DefaultValue `json:"value,omitempty"`
}
type GrafanaLink ¶ added in v0.52.0
type GrafanaTimeRange ¶ added in v0.55.0
GrafanaTimeRange is the default time range of a Grafana dashboard, e.g. {"from": "now-6h", "to": "now"}.
func (*GrafanaTimeRange) UnmarshalJSON ¶ added in v0.55.0
func (t *GrafanaTimeRange) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes the time range best-effort: a value that is not an object of strings leaves the time range empty (the migration then uses the default duration of Perses), instead of making the whole migration fail.
type GridPosition ¶
type LenientString ¶ added in v0.55.0
type LenientString string
LenientString is a string field of a Grafana dashboard that is decoded best-effort: a JSON value that is not a string (e.g. `"refresh": false`, written by older Grafana versions when auto-refresh is off) is decoded as an empty string, instead of making the whole migration fail.
func (*LenientString) UnmarshalJSON ¶ added in v0.55.0
func (s *LenientString) UnmarshalJSON(data []byte) error
type Migration ¶
type Migration interface {
Load(pluginPath string, module v1.PluginModule) error
LoadDevPlugin(pluginPath string, module v1.PluginModule) error
UnLoadDevPlugin(module v1.PluginModule)
Migrate(grafanaDashboard *SimplifiedDashboard, useDefaultDatasource bool) (*v1.Dashboard, error)
}
type Panel ¶
type Panel struct {
Type string `json:"type"`
Title string `json:"title"`
Description string `json:"description"`
Repeat string `json:"repeat"`
RepeatDirection string `json:"repeatDirection"`
MaxPerRow *int `json:"maxPerRow"`
Collapsed bool `json:"collapsed"`
Panels []Panel `json:"panels"`
GridPosition GridPosition `json:"gridPos"`
Targets []json.RawMessage `json:"targets"`
Links []GrafanaLink `json:"links"`
json.RawMessage
}
func (*Panel) UnmarshalJSON ¶
Custom unmarshal to both store fields and keep raw data (used by the CUE-based migration logic). Checks unmarshalling errors only when unmarshaling complex structs.
type SimplifiedDashboard ¶
type SimplifiedDashboard struct {
UID string `json:"uid,omitempty"`
Title string `json:"title"`
Tags []string `json:"tags"`
Panels []Panel `json:"panels"`
Links []GrafanaLink `json:"links"`
Templating struct {
List []TemplateVar `json:"list"`
} `json:"templating"`
// Time is the default time range of the dashboard. It is nil when the dashboard has none.
Time *GrafanaTimeRange `json:"time"`
// Refresh is the default auto-refresh interval of the dashboard, e.g. "1m". It is empty when auto-refresh is off.
Refresh LenientString `json:"refresh"`
// Timezone is the timezone of the dashboard: "browser", "utc", an IANA timezone name, or empty.
Timezone LenientString `json:"timezone"`
}
func (*SimplifiedDashboard) UnmarshalJSON ¶
func (d *SimplifiedDashboard) UnmarshalJSON(data []byte) error
type TemplateVar ¶
type TemplateVar struct {
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description"`
Label string `json:"label"`
Hide int `json:"hide"`
Sort *int `json:"sort,omitempty"`
IncludeAll bool `json:"includeAll"`
AllValue string `json:"allValue"`
Multi bool `json:"multi"`
Current *CurrentValue `json:"current,omitempty"`
Query json.RawMessage `json:"query"`
json.RawMessage
}
func (*TemplateVar) UnmarshalJSON ¶
func (v *TemplateVar) UnmarshalJSON(data []byte) error