prometheus

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2020 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package prometheus provides the Prometheus Origin Type

Index

Constants

View Source
const (
	APIPath = "/api/v1/"
)

Prometheus API

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client Implements Proxy Client Interface

func NewClient

func NewClient(name string, oc *config.OriginConfig, cache cache.Cache) (*Client, error)

NewClient returns a new Client Instance

func (*Client) BaseURL

func (c *Client) BaseURL() *url.URL

BaseURL returns a URL in the form of scheme://host/path based on the proxy configuration

func (*Client) BuildUpstreamURL

func (c *Client) BuildUpstreamURL(r *http.Request) *url.URL

BuildUpstreamURL will merge the downstream request with the BaseURL to construct the full upstream URL

func (*Client) Cache

func (c *Client) Cache() cache.Cache

Cache returns and handle to the Cache instance used by the Client

func (*Client) Configuration

func (c *Client) Configuration() *config.OriginConfig

Configuration returns the upstream Configuration for this Client

func (*Client) DefaultPathConfigs

func (c *Client) DefaultPathConfigs(oc *config.OriginConfig) map[string]*config.PathConfig

DefaultPathConfigs returns the default PathConfigs for the given OriginType

func (*Client) FastForwardURL

func (c *Client) FastForwardURL(r *http.Request) (*url.URL, error)

FastForwardURL returns the url to fetch the Fast Forward value based on a timerange url

func (*Client) HTTPClient

func (c *Client) HTTPClient() *http.Client

HTTPClient returns the HTTP Client for this origin

func (*Client) Handlers

func (c *Client) Handlers() map[string]http.Handler

Handlers returns a map of the HTTP Handlers the client has registered

func (*Client) HealthHandler

func (c *Client) HealthHandler(w http.ResponseWriter, r *http.Request)

HealthHandler checks the health of the Configured Upstream Origin

func (*Client) MarshalTimeseries

func (c *Client) MarshalTimeseries(ts timeseries.Timeseries) ([]byte, error)

MarshalTimeseries converts a Timeseries into a JSON blob

func (*Client) Name

func (c *Client) Name() string

Name returns the name of the upstream Configuration proxied by the Client

func (*Client) ObjectProxyCacheHandler

func (c *Client) ObjectProxyCacheHandler(w http.ResponseWriter, r *http.Request)

ObjectProxyCacheHandler handles calls to /query (for instantaneous values)

func (*Client) ParseTimeRangeQuery

func (c *Client) ParseTimeRangeQuery(r *http.Request) (*timeseries.TimeRangeQuery, error)

ParseTimeRangeQuery parses the key parts of a TimeRangeQuery from the inbound HTTP Request

func (*Client) ProxyHandler

func (c *Client) ProxyHandler(w http.ResponseWriter, r *http.Request)

ProxyHandler sends a request through the basic reverse proxy to the origin, and services non-cacheable Prometheus API calls.

func (*Client) QueryHandler

func (c *Client) QueryHandler(w http.ResponseWriter, r *http.Request)

QueryHandler handles calls to /query (for instantaneous values)

func (*Client) QueryRangeHandler

func (c *Client) QueryRangeHandler(w http.ResponseWriter, r *http.Request)

QueryRangeHandler handles timeseries requests for Prometheus and processes them through the delta proxy cache

func (*Client) SeriesHandler

func (c *Client) SeriesHandler(w http.ResponseWriter, r *http.Request)

SeriesHandler proxies requests for path /series to the origin by way of the object proxy cache

func (*Client) SetCache

func (c *Client) SetCache(cc cache.Cache)

SetCache sets the Cache object the client will use for caching origin content

func (*Client) SetExtent

func (c *Client) SetExtent(r *http.Request, trq *timeseries.TimeRangeQuery, extent *timeseries.Extent)

SetExtent will change the upstream request query to use the provided Extent

func (*Client) UnmarshalInstantaneous

func (c *Client) UnmarshalInstantaneous(data []byte) (timeseries.Timeseries, error)

UnmarshalInstantaneous converts a JSON blob into an Instantaneous Data Point

func (*Client) UnmarshalTimeseries

func (c *Client) UnmarshalTimeseries(data []byte) (timeseries.Timeseries, error)

UnmarshalTimeseries converts a JSON blob into a Timeseries

type MatrixData

type MatrixData struct {
	ResultType string       `json:"resultType"`
	Result     model.Matrix `json:"result"`
}

MatrixData represents the Data body of a Matrix response object from the Prometheus HTTP API

type MatrixEnvelope

type MatrixEnvelope struct {
	Status       string                `json:"status"`
	Data         MatrixData            `json:"data"`
	ExtentList   timeseries.ExtentList `json:"extents,omitempty"`
	StepDuration time.Duration         `json:"step,omitempty"`
	// contains filtered or unexported fields
}

MatrixEnvelope represents a Matrix response object from the Prometheus HTTP API

func (*MatrixEnvelope) Clone

func (me *MatrixEnvelope) Clone() timeseries.Timeseries

Clone returns a perfect copy of the base Timeseries

func (*MatrixEnvelope) CropToRange

func (me *MatrixEnvelope) CropToRange(e timeseries.Extent)

CropToRange reduces the Timeseries down to timestamps contained within the provided Extents (inclusive). CropToRange assumes the base Timeseries is already sorted, and will corrupt an unsorted Timeseries

func (*MatrixEnvelope) CropToSize

func (me *MatrixEnvelope) CropToSize(sz int, t time.Time, lur timeseries.Extent)

CropToSize reduces the number of elements in the Timeseries to the provided count, by evicting elements using a least-recently-used methodology. Any timestamps newer than the provided time are removed before sizing, in order to support backfill tolerance. The provided extent will be marked as used during crop.

func (*MatrixEnvelope) Extents

func (me *MatrixEnvelope) Extents() timeseries.ExtentList

Extents returns the Timeseries's ExentList

func (*MatrixEnvelope) Merge

func (me *MatrixEnvelope) Merge(sort bool, collection ...timeseries.Timeseries)

Merge merges the provided Timeseries list into the base Timeseries (in the order provided) and optionally sorts the merged Timeseries

func (*MatrixEnvelope) SeriesCount

func (me *MatrixEnvelope) SeriesCount() int

SeriesCount returns the number of individual Series in the Timeseries object

func (*MatrixEnvelope) SetExtents

func (me *MatrixEnvelope) SetExtents(extents timeseries.ExtentList)

SetExtents overwrites a Timeseries's known extents with the provided extent list

func (*MatrixEnvelope) SetStep

func (me *MatrixEnvelope) SetStep(step time.Duration)

SetStep sets the step for the Timeseries

func (*MatrixEnvelope) Size

func (me *MatrixEnvelope) Size() int

Size returns the approximate memory utilization in bytes of the timeseries

func (*MatrixEnvelope) Sort

func (me *MatrixEnvelope) Sort()

Sort sorts all Values in each Series chronologically by their timestamp

func (*MatrixEnvelope) Step

func (me *MatrixEnvelope) Step() time.Duration

Step returns the step for the Timeseries

func (*MatrixEnvelope) TimestampCount

func (me *MatrixEnvelope) TimestampCount() int

TimestampCount returns the number of unique timestamps across the timeseries

func (*MatrixEnvelope) ValueCount

func (me *MatrixEnvelope) ValueCount() int

ValueCount returns the count of all values across all Series in the Timeseries object

type VectorData

type VectorData struct {
	ResultType string       `json:"resultType"`
	Result     model.Vector `json:"result"`
}

VectorData represents the Data body of a Vector response object from the Prometheus HTTP API

type VectorEnvelope

type VectorEnvelope struct {
	Status string     `json:"status"`
	Data   VectorData `json:"data"`
}

VectorEnvelope represents a Vector response object from the Prometheus HTTP API

func (*VectorEnvelope) ToMatrix

func (ve *VectorEnvelope) ToMatrix() *MatrixEnvelope

ToMatrix converts a VectorEnvelope to a MatrixEnvelope

Jump to

Keyboard shortcuts

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