grafana

package
v0.0.0-...-1a18185 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegGrafanaRestHandler

func RegGrafanaRestHandler(router *fasthttprouter.Router)

Types

type Annotation

type Annotation struct {
	Time    time.Time `json:"time"`
	TimeEnd time.Time `json:"timeEnd,omitempty"`
	Title   string    `json:"title"`
	Text    string    `json:"text"`
	Tags    []string  `json:"tags"`
}

Annotation represents an annotation that can be displayed on a graph, or in a table.

type AnnotationsArguments

type AnnotationsArguments struct {
	QueryCommonArguments
}

AnnotationsArguments defines the options to a annotations query.

type Annotator

type Annotator interface {
	GrafanaAnnotations(ctx context.Context, query string, args AnnotationsArguments) ([]Annotation, error)
}

An Annotator responds to queries for annotations from Grafana

type AppmeshGrafanaJson

type AppmeshGrafanaJson struct{}

https://grafana.com/grafana/plugins/grafana-simple-json-datasource/

func (AppmeshGrafanaJson) GrafanaAdhocFilterTagValues

func (AppmeshGrafanaJson) GrafanaAdhocFilterTagValues(ctx context.Context, key string) ([]TagValuer, error)

func (AppmeshGrafanaJson) GrafanaAdhocFilterTags

func (AppmeshGrafanaJson) GrafanaAdhocFilterTags(ctx context.Context) ([]TagInfoer, error)

func (AppmeshGrafanaJson) GrafanaAnnotations

func (AppmeshGrafanaJson) GrafanaAnnotations(ctx context.Context, query string, args AnnotationsArguments) ([]Annotation, error)

func (AppmeshGrafanaJson) GrafanaQuery

func (AppmeshGrafanaJson) GrafanaQuery(ctx context.Context, target string, args QueryArguments) ([]DataPoint, error)

GrafanaQuery handles timeserie type queries.

func (AppmeshGrafanaJson) GrafanaQueryTable

func (AppmeshGrafanaJson) GrafanaQueryTable(ctx context.Context, target string, args TableQueryArguments) ([]TableColumn, error)

func (AppmeshGrafanaJson) GrafanaSearch

func (AppmeshGrafanaJson) GrafanaSearch(ctx context.Context, target string) ([]string, error)

type DataPoint

type DataPoint struct {
	Time  time.Time
	Value float64
}

DataPoint represents a single datapoint at a given point in time.

type GrafanaHandler

type GrafanaHandler struct {
	// contains filtered or unexported fields
}

GrafanaHandler Is an opaque type that supports the required HTTP handlers for the Simple JSON plugin

func New

func New(opts ...Opt) *GrafanaHandler

New creates a new http.Handler that will answer to the required endpoint for a SimpleJSON source. You should use WithQuerier, WithTableQuerier, WithAnnotator and WithSearch to set handlers for each of the endpionts.

func (*GrafanaHandler) HandleAnnotations

func (h *GrafanaHandler) HandleAnnotations(ctx *fasthttp.RequestCtx)

HandleAnnotations responds to the /annotation requests.

func (*GrafanaHandler) HandleQuery

func (h *GrafanaHandler) HandleQuery(ctx *fasthttp.RequestCtx)

HandleQuery hands the /query endpoint, calling the appropriate timeserie or table handler.

func (*GrafanaHandler) HandleRoot

func (h *GrafanaHandler) HandleRoot(ctx *fasthttp.RequestCtx)

HandleRoot serves a plain 200 OK for /, required by Grafana

func (*GrafanaHandler) HandleSearch

func (h *GrafanaHandler) HandleSearch(ctx *fasthttp.RequestCtx)

HandleSearch implements the /search endpoint.

func (*GrafanaHandler) HandleTagKeys

func (h *GrafanaHandler) HandleTagKeys(ctx *fasthttp.RequestCtx)

HandleTagKeys implements the /tag-keys endpoint.

func (*GrafanaHandler) HandleTagValues

func (h *GrafanaHandler) HandleTagValues(ctx *fasthttp.RequestCtx)

HandleTagValues implements the /tag-values endpoint.

type Opt

type Opt func(*GrafanaHandler) error

Opt provides configurable options for the Handler

func WithAnnotator

func WithAnnotator(a Annotator) Opt

WithAnnotator adds an annoations handler.

func WithQuerier

func WithQuerier(q Querier) Opt

WithQuerier adds a timeserie query handler.

func WithSearcher

func WithSearcher(s Searcher) Opt

WithSearcher adds a search handlers.

func WithSource

func WithSource(src interface{}) Opt

WithSource will attempt to use the datasource provided as a Querier, TableQuerier, Annotator, Searcher and TagSearch if it supports the required interface.

func WithTableQuerier

func WithTableQuerier(q TableQuerier) Opt

WithTableQuerier adds a table query handler.

func WithTagSearcher

func WithTagSearcher(s TagSearcher) Opt

WithTagSearcher adds adhoc filter tag search handlers.

type Querier

type Querier interface {
	GrafanaQuery(ctx context.Context, target string, args QueryArguments) ([]DataPoint, error)
}

A Querier responds to timeseri queries from Grafana

type QueryAdhocFilter

type QueryAdhocFilter struct {
	Key      string `json:"key"`
	Operator string `json:"operator"`
	Value    string `json:"value"`
}

QueryAdhocFilter describes a user supplied filter to be added to each query target.

type QueryArguments

type QueryArguments struct {
	QueryCommonArguments
	Interval time.Duration
	MaxDPs   int
}

QueryArguments defines the options to a timeserie query.

type QueryCommonArguments

type QueryCommonArguments struct {
	From, To time.Time
	Filters  []QueryAdhocFilter
}

QueryCommonArguments describes the arguments common to timeserie and table queries.

type Searcher

type Searcher interface {
	GrafanaSearch(ctx context.Context, target string) ([]string, error)
}

A Searcher responds to search queries from Grafana

type TableColumn

type TableColumn struct {
	Text string
	Data TableColumnData
}

TableColumn represents a single table column. Data should be one the TableNumberColumn, TableStringColumn or TableTimeColumn types.

type TableColumnData

type TableColumnData interface {
	// contains filtered or unexported methods
}

TableColumnData is a private interface to this package, you should use one of TableStringColumn, TableNumberColumn, or TableTimeColumn

type TableNumberColumn

type TableNumberColumn []float64

A TableNumberColumn holds values for a "number" column in a table.

type TableQuerier

type TableQuerier interface {
	GrafanaQueryTable(ctx context.Context, target string, args TableQueryArguments) ([]TableColumn, error)
}

A TableQuerier responds to table queries from Grafana

type TableQueryArguments

type TableQueryArguments struct {
	QueryCommonArguments
}

TableQueryArguments defines the options to a table query.

type TableStringColumn

type TableStringColumn []string

A TableStringColumn holds values for a "string" column in a table.

type TableTimeColumn

type TableTimeColumn []time.Time

A TableTimeColumn holds values for a "time" column in a table.

type TagInfoer

type TagInfoer interface {
	// contains filtered or unexported methods
}

TagInfoer is an internal interface to describe difference types of tag.

type TagSearcher

type TagSearcher interface {
	GrafanaAdhocFilterTags(ctx context.Context) ([]TagInfoer, error)
	GrafanaAdhocFilterTagValues(ctx context.Context, key string) ([]TagValuer, error)
}

A TagSearcher allows the querying of tag keys and values for adhoc filters.

type TagStringKey

type TagStringKey string

TagStringKey represent an adhoc query string key.

type TagStringValue

type TagStringValue string

TagStringValue represent an adhoc query string key.

type TagValuer

type TagValuer interface {
	// contains filtered or unexported methods
}

TagValuer is in an internal interface used to describe tag Values.

Jump to

Keyboard shortcuts

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