api

package
v0.0.0-...-6ee8545 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: Apache-2.0 Imports: 58 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alerts

func Alerts(conf *Config, updateMetrics updateMetricCallback) http.Handler

func Delete

func Delete(conf *Config, client *pgclient.Client) http.Handler

func GenerateRouter

func GenerateRouter(apiConf *Config, promqlConf *query.Config, client *pgclient.Client, store *jaegerStore.Store, authWrapper mux.MiddlewareFunc, reload func() error) (*mux.Router, error)

TODO: Refactor this function to reduce number of paramaters.

func LabelValues

func LabelValues(conf *Config, queryable promql.Queryable) http.Handler

func Labels

func Labels(conf *Config, queryable promql.Queryable) http.Handler

func MetricMetadata

func MetricMetadata(conf *Config, client *pgclient.Client) http.Handler

func Query

func Query(conf *Config, queryEngine *promql.Engine, queryable promql.Queryable, updateMetrics updateMetricCallback) http.Handler

func QueryExemplar

func QueryExemplar(conf *Config, queryable promql.Queryable, updateMetrics updateMetricCallback) http.Handler

func QueryRange

func QueryRange(conf *Config, promqlConf *query.Config, queryEngine *promql.Engine, queryable promql.Queryable, updateMetrics updateMetricCallback) http.Handler

func Read

func Read(config *Config, reader querier.Reader, metrics *Metrics, updateMetrics updateMetricCallback) http.Handler

func RegisterTelemetryMetrics

func RegisterTelemetryMetrics(t telemetry.Engine) error

func Reload

func Reload(reload func() error, webAdmin bool) http.HandlerFunc

func Rules

func Rules(conf *Config, updateMetrics updateMetricCallback) http.Handler

func Series

func Series(conf *Config, queryable promql.Queryable) http.Handler

func Validate

func Validate(cfg *Config) error

func Write

func Write(
	inserter ingestor.DBInserter,
	dataParser *parser.DefaultParser,
	updateMetrics func(code string, duration, receivedSamples, receivedMetadata float64),
) http.Handler

Write returns an http.Handler that is responsible for data ingest.

Types

type Alert

type Alert struct {
	Labels      labels.Labels `json:"labels"`
	Annotations labels.Labels `json:"annotations"`
	State       string        `json:"state"`
	ActiveAt    *time.Time    `json:"activeAt,omitempty"`
	Value       string        `json:"value"`
}

Alert has info for an alert.

type AlertDiscovery

type AlertDiscovery struct {
	Alerts []*Alert `json:"alerts"`
}

AlertDiscovery has info for all active alerts.

type AlertingRule

type AlertingRule struct {
	// State can be "pending", "firing", "inactive".
	State          string                `json:"state"`
	Name           string                `json:"name"`
	Query          string                `json:"query"`
	Duration       float64               `json:"duration"`
	Labels         labels.Labels         `json:"labels"`
	Annotations    labels.Labels         `json:"annotations"`
	Alerts         []*Alert              `json:"alerts"`
	Health         prom_rules.RuleHealth `json:"health"`
	LastError      string                `json:"lastError,omitempty"`
	EvaluationTime float64               `json:"evaluationTime"`
	LastEvaluation time.Time             `json:"lastEvaluation"`
	// Type of an alertingRule is always "alerting".
	Type string `json:"type"`
}

type Config

type Config struct {
	AllowedOrigin    *regexp.Regexp
	ReadOnly         bool
	HighAvailability bool
	AdminAPIEnabled  bool
	TelemetryPath    string

	MultiTenancy tenancy.Authorizer
	Rules        *rules.Manager
}

func ParseFlags

func ParseFlags(fs *flag.FlagSet, cfg *Config) *Config

type Metrics

type Metrics struct {
	// Using the first word in struct to ensure proper alignment in 32-bit systems.
	// Reference: https://golang.org/pkg/sync/atomic/#pkg-note-BUG
	LastRequestUnixNano       int64
	HTTPRequestDuration       *prometheus.HistogramVec
	RemoteReadReceivedQueries prometheus.Counter
}

func InitMetrics

func InitMetrics() *Metrics

InitMetrics sets up and returns the Prometheus metrics which Promscale exposes. This needs to be set before calling objects from the api package.

type RecordingRule

type RecordingRule struct {
	Name           string                `json:"name"`
	Query          string                `json:"query"`
	Labels         labels.Labels         `json:"labels,omitempty"`
	Health         prom_rules.RuleHealth `json:"health"`
	LastError      string                `json:"lastError,omitempty"`
	EvaluationTime float64               `json:"evaluationTime"`
	LastEvaluation time.Time             `json:"lastEvaluation"`
	// Type of a recordingRule is always "recording".
	Type string `json:"type"`
}

type Rule

type Rule interface{}

type RuleDiscovery

type RuleDiscovery struct {
	RuleGroups []*RuleGroup `json:"groups"`
}

RuleDiscovery has info for all rules

type RuleGroup

type RuleGroup struct {
	Name string `json:"name"`
	File string `json:"file"`
	// In order to preserve rule ordering, while exposing type (alerting or recording)
	// specific properties, both alerting and recording rules are exposed in the
	// same array.
	Rules          []Rule    `json:"rules"`
	Interval       float64   `json:"interval"`
	Limit          int       `json:"limit"`
	EvaluationTime float64   `json:"evaluationTime"`
	LastEvaluation time.Time `json:"lastEvaluation"`
}

RuleGroup has info for rules which are part of a group

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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