api

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Group   = "grafctl.foyle.io"
	Version = "v1alpha1"
)

Variables

View Source
var (
	LinkGVK = schema.FromAPIVersionAndKind(Group+"/"+Version, "GrafanaLink")
)
View Source
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 Column

type Column struct {
	Name string `json:"name,omitempty" yaml:"name,omitempty"`
	Hint string `json:"hint,omitempty" yaml:"hint,omitempty"`
}

type Datasource

type Datasource struct {
	Type string `json:"type,omitempty" yaml:"type,omitempty"`
	UID  string `json:"uid,omitempty" yaml:"uid,omitempty"`
}
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 LogsState

type LogsState struct {
	Columns           map[string]string `json:"columns,omitempty" yaml:"columns,omitempty"`
	VisualisationType string            `json:"visualisationType,omitempty" yaml:"visualisationType,omitempty"`
}

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 Panes

type Panes map[string]PaneBody

Panes is a map from the ID of the pane to the body of the pane.

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 (c Query) MarshalJSON() ([]byte, error)

func (Query) MarshalYAML

func (c Query) MarshalYAML() (interface{}, error)

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

func (q *Query) UnmarshalJSON(data []byte) error

UnmarshalJSON method custom unmarshal function to deal with additional fields

func (*Query) UnmarshalYAML

func (q *Query) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML method custom unmarshal function to deal with additional fields func (q *Query) UnmarshalYAML(value *yaml.Node) error {

type TimeRange

type TimeRange struct {
	From string `json:"from,omitempty" yaml:"from,omitempty"`
	To   string `json:"to,omitempty" yaml:"to,omitempty"`
}

Jump to

Keyboard shortcuts

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