grafana

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package grafana is an http client for api calls authenticated with not supported by github.com/grafana/grafana-api-golang-client TODO: make a PR to gapi and drop this duplicate implementation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	ID        int          `json:"id"`
	OrgID     int          `json:"orgId"`
	Title     string       `json:"title"`
	Condition string       `json:"condition"`
	Data      []AlertQuery `json:"data,omitempty"`
	Updated   time.Time    `json:"updated"`
	// IntervalSeconds is in seconds
	IntervalSeconds int    `json:"intervalSeconds"`
	Version         int    `json:"version"`
	UID             string `json:"uid"`
	NamespaceUID    string `json:"namespace_uid"`
	NamespaceID     int    `json:"namespace_id"`
	RuleGroup       string `json:"rule_group"`
	NoDataState     string `json:"no_data_state"`
	ExecErrState    string `json:"exec_err_state"`
}

Alert contains a Grafana alert data

type AlertQuery

type AlertQuery struct {
	RefID             string `json:"refId"`
	QueryType         string `json:"queryType"`
	RelativeTimeRange struct {
		From time.Duration `json:"from"`
		To   time.Duration `json:"to"`
	}
	DatasourceUID string      `json:"datasourceUid"`
	Model         interface{} `json:"model"`
}

AlertQuery contains Grafana alert model

type AlertRule

type AlertRule struct {
	Expr string `json:"expr"`
	For  string `json:"for"`
	// Annotations is a map of key/value pairs
	Annotations map[string]string `json:"annotations"`
	// GrafanaAlert is a struct
	Alert Alert `json:"grafana_alert"`
}

AlertRule contains Grafana alert rule

type Client

type Client struct {
	APIKey string
	// contains filtered or unexported fields
}

Client is a Grafana API client.

func New

func New(baseURL, apiKey string) (*Client, error)

New creates a new Grafana client.

func (*Client) AllRuleGroups

func (c *Client) AllRuleGroups() (RuleGroupsByFolder, error)

AllRuleGroups fetches all rules group names in folders

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient is an interface to go http package

type RuleGroup

type RuleGroup struct {
	Name     string      `json:"name"`
	Interval string      `json:"interval"`
	Rules    []AlertRule `json:"rules,omitempty"`
}

RuleGroup contains alert rules in a group for a folder

type RuleGroupsByFolder

type RuleGroupsByFolder map[string][]RuleGroup

RuleGroupsByFolder contains Grafana rule groups for a Folder type RuleGroupsByFolder map[string][]RuleGroupName

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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