Documentation
¶
Index ¶
Constants ¶
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" )
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 ¶
NewPrometheusDriver is a factory method which chooses the right driver implementation based on configuration settings
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