storage

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// P8SProtoBuf is the native protocol (preferred)
	P8SProtoBuf string = "" /* 137-byte string literal not displayed */
	// PlainText is used for readable federate output
	PlainText = "text/plain; version=0.0.4"
	// JSON is used to obtain output in JSON (--format json)
	JSON = "application/json"
)
View Source
const (
	// ErrorNone means no error
	ErrorNone ErrorType = ""
	// ErrorTimeout means that a timeout occured while processing the request
	ErrorTimeout = "timeout"
	// ErrorCanceled means that the query was cancelled (to protect the service from malicious requests)
	ErrorCanceled = "canceled"
	// ErrorExec means unspecified error happened during query execution
	ErrorExec = "execution"
	// ErrorBadData means the API parameters where invalid
	ErrorBadData = "bad_data"
	// ErrorInternal means some unspecified internal error happened
	ErrorInternal = "internal"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver interface {
	/********** requests to Prometheus **********/
	Federate(selectors []string, acceptContentType string) (*http.Response, error)
	Query(query, time, timeout string, acceptContentType string) (*http.Response, error)
	QueryRange(query, start, end, step, timeout string, acceptContentType string) (*http.Response, error)
	Series(match []string, start, end string, acceptContentType string) (*http.Response, error)
	LabelValues(name string, acceptContentType string) (*http.Response, error)
	DelegateRequest(request *http.Request) (*http.Response, error)
}

Driver is an interface that wraps the underlying event storage mechanism. Because it is an interface, the real implementation can be mocked away in unit tests. For pragmatic reasons the HTTP response from the underlying storage service is passed on unchanged. For most API operations, Maia does not have to transform the response and that way we can avoid an entire in-memory unmarshal-marshal cycle.

func NewPrometheusDriver

func NewPrometheusDriver(prometheusAPIURL string, customHeader map[string]string) Driver

NewPrometheusDriver is a factory method which chooses the right driver implementation based on configuration settings

func Prometheus

func Prometheus(prometheusAPIURL string, customHeaders map[string]string) Driver

Prometheus creates a storage driver for Prometheus/Maia

type ErrorType

type ErrorType string

ErrorType enumerates different Prometheus error types

type LabelValuesResponse

type LabelValuesResponse struct {
	Status Status            `json:"status"`
	Data   model.LabelValues `json:"data"`
}

LabelValuesResponse encapsulates a response to the /label/values API of Prometheus

type QueryResponse

type QueryResponse struct {
	Status    Status      `json:"status"`
	Data      QueryResult `json:"data,omitempty"`
	ErrorType ErrorType   `json:"errorType,omitempty"`
	Error     string      `json:"error,omitempty"`
}

QueryResponse contains the response from a call to query or query_range

type QueryResult

type QueryResult struct {
	Type   model.ValueType `json:"resultType"`
	Result interface{}     `json:"result"`

	// The decoded value.
	Value model.Value
}

QueryResult contains the actual result of a query or query_range call

func (*QueryResult) UnmarshalJSON

func (qr *QueryResult) UnmarshalJSON(b []byte) error

UnmarshalJSON contains a custom unmarshaller

type Response

type Response struct {
	Status    Status        `json:"status"`
	Data      []interface{} `json:"data,omitempty"`
	ErrorType ErrorType     `json:"errorType,omitempty"`
	Error     string        `json:"error,omitempty"`
}

Response encapsulates a generic response of a Prometheus API

type SeriesResponse

type SeriesResponse struct {
	Status    Status           `json:"status"`
	Data      []model.LabelSet `json:"data,omitempty"`
	ErrorType ErrorType        `json:"errorType,omitempty"`
	Error     string           `json:"error,omitempty"`
}

SeriesResponse encapsulates a response to the /series API of Prometheus

type Status

type Status string

Status contains Prometheus status strings

const (
	// StatusSuccess means success
	StatusSuccess Status = "success"
	// StatusError means error
	StatusError = "error"
)

Jump to

Keyboard shortcuts

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