Documentation
¶
Index ¶
Constants ¶
const ( Group = "grafctl.foyle.io" Version = "v1alpha1" )
Variables ¶
var (
LinkGVK = schema.FromAPIVersionAndKind(Group+"/"+Version, "GrafanaLink")
)
var (
PanePatchGVK = schema.FromAPIVersionAndKind(Group+"/"+Version, "PanePatch")
)
Functions ¶
This section is empty.
Types ¶
type BuilderOptions ¶
type BuilderOptions struct {
Database string `json:"database,omitempty" yaml:"database,omitempty"`
Table string `json:"table,omitempty" yaml:"table,omitempty"`
QueryType string `json:"queryType,omitempty" yaml:"queryType,omitempty"`
Mode string `json:"mode,omitempty" yaml:"mode,omitempty"`
Columns []Column `json:"columns,omitempty" yaml:"columns,omitempty"`
Meta Meta `json:"meta,omitempty" yaml:"meta,omitempty"`
Limit int `json:"limit,omitempty" yaml:"limit,omitempty"`
SimplelogQuery string `json:"simplelogQuery,omitempty" yaml:"simplelogQuery,omitempty"`
}
BuilderOptions is the options for the builderOptions panel. TODO(jeremy): Should we add support for additionalFields as in Query with custom unmarshal and marshal functions So that we properly handle additional fields that could be added later?
type Datasource ¶
type GrafanaLink ¶
type GrafanaLink struct {
APIVersion string `json:"apiVersion" yaml:"apiVersion"`
Kind string `json:"kind" yaml:"kind"`
Metadata Metadata `json:"metadata" yaml:"metadata"`
// BaseURL is the base URL for links generated from this template
BaseURL string `json:"baseURL" yaml:"baseURL"`
// Panes is a map from the ID of the pane to the body of the pane
Panes Panes `json:"panes" yaml:"panes"`
}
GrafanaLink represents a link to a Grafana dashboard
type Meta ¶
type Meta struct {
OtelEnabled bool `json:"otelEnabled,omitempty" yaml:"otelEnabled,omitempty"`
}
type Metadata ¶
type Metadata struct {
Name string `yaml:"name,omitempty"`
Namespace string `yaml:"namespace,omitempty"`
Labels map[string]string `yaml:"labels"`
Annotations map[string]string `yaml:"annotations,omitempty"`
}
Metadata holds an optional name of the project.
type PaneBody ¶
type PaneBody struct {
Datasource string `json:"datasource,omitempty" yaml:"datasource,omitempty"`
Queries []*Query `json:"queries,omitempty" yaml:"queries,omitempty"`
Range TimeRange `json:"range,omitempty" yaml:"range,omitempty"`
PanelsState PanelsState `json:"panelsState,omitempty" yaml:"panelsState,omitempty"`
}
PaneBody represents a pane in the log explorer viewer: https://grafana.com/docs/grafana/latest/explore/get-started-with-explore/#generate-explore-urls-from-external-tools
type PanePatch ¶
type PanePatch struct {
APIVersion string `json:"apiVersion" yaml:"apiVersion"`
Kind string `json:"kind" yaml:"kind"`
Metadata Metadata `json:"metadata" yaml:"metadata"`
// Template is the name of the template to apply the patch to
Template string `json:"template" yaml:"template"`
// Query is a patch to be applied to the first query in the pane.
Query map[string]interface{} `json:"query,omitempty" yaml:"query,omitempty"`
// Range is the time range for the query.
// Uses the syntax supported by grafana for relative times and units
// https://grafana.com/docs/grafana/latest/dashboards/use-dashboards/#time-units-and-relative-ranges
Range TimeRange `json:"range,omitempty" yaml:"range,omitempty"`
// FixTime is a flag to indicate whether to fix the time range to absolute time or use relative time
// in the link. Default is true.
FixTime *bool `json:"fixTime,omitempty" yaml:"fixTime,omitempty"`
}
PanePatch represents the patch to be applied to one of your pane templates. This corresponds to the YAML that is passed on the command line
type PanelsState ¶
type PanelsState struct {
Logs LogsState `json:"logs,omitempty" yaml:"logs,omitempty"`
}
type Query ¶
type Query struct {
RefID string `json:"refId,omitempty" yaml:"refId,omitempty"`
Datasource Datasource `json:"datasource,omitempty" yaml:"datasource,omitempty"`
EditorType string `json:"editorType,omitempty" yaml:"editorType,omitempty"`
RawSQL string `json:"rawSql,omitempty" yaml:"rawSql,omitempty"`
// TODO(jeremy): BuilderOptions is not a standard field in Grafana. Should we treat it as an AdditionalField?
BuilderOptions BuilderOptions `json:"builderOptions,omitempty" yaml:"builderOptions,omitempty"`
PluginVersion string `json:"pluginVersion,omitempty" yaml:"pluginVersion,omitempty"`
Format int `json:"format,omitempty" yaml:"format,omitempty"`
QueryType string `json:"queryType,omitempty" yaml:"queryType,omitempty"`
AdditionalFields map[string]interface{} `json:"-" yaml:"-"`
}
Query represents a query in the log explorer https://grafana.com/docs/grafana/latest/explore/get-started-with-explore/#generate-explore-urls-from-external-tools Most of these fields are not required by Grafana but our fields used by the logs datasource.
func (Query) MarshalJSON ¶
func (Query) MarshalYAML ¶
MarshalYAML custom marshall function N.B. The linter complains about having methods on value and pointer reciever types. However, if we use a pointer reciever type here then MarshalYAML will not be called when marshalling a value type which is not what we desire.
func (*Query) UnmarshalJSON ¶
UnmarshalJSON method custom unmarshal function to deal with additional fields