prometheus

package
v0.3.51 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// StatusSuccess Status string literal of prometheus api request
	StatusSuccess = "success"
	// StatusError Status string literal of prometheus api request
	StatusError = "error"
)

Variables

View Source
var (
	DatahubAggregateFunction_DAOAggregateFunction = map[Common.TimeRange_AggregateFunction]DAO.AggregateFunction{
		Common.TimeRange_NONE: DAO.None,
		Common.TimeRange_MAX:  DAO.Max,
	}
)

Functions

func BuildQueryCondition added in v0.3.31

func BuildQueryCondition(query *Common.Query) DAO.QueryCondition

func ReadRawdata added in v0.3.31

func ReadRawdata(config *Config, queries []*Common.Query) ([]*Common.ReadRawdata, error)

func ResponseToReadRawdata added in v0.3.49

func ResponseToReadRawdata(response *Response, query *Common.Query) (*Common.ReadRawdata, error)

Types

type Config

type Config struct {
	URL             string     `mapstructure:"url"`
	BearerTokenFile string     `mapstructure:"bearer-token-file"`
	TLSConfig       *TLSConfig `mapstructure:"tls-config"`
	// contains filtered or unexported fields
}

Config Configuration of Prometheus datasource

func NewDefaultConfig

func NewDefaultConfig() Config

NewDefaultConfig Provide default configuration

func (*Config) Validate

func (c *Config) Validate() error

Validate Confirm the configuration is validate

type Data

type Data struct {
	ResultType ResultType    `json:"resultType"`
	Result     []interface{} `json:"result"`
}

Data Data represent the general value of prometheus http response field "data", the format of field "result" will depends on field "resultType"

type Entity

type Entity struct {
	Labels map[string]string
	Values []UnixTimeWithSampleValue
}

Entity Structure to store metrics data from Prometheus response

type MatrixData

type MatrixData struct {
	ResultType ResultType
	Result     []struct {
		Metric map[string]string
		Values []UnixTimeWithSampleValue
	}
}

MatrixData MatrixData

type MatrixResponse

type MatrixResponse struct {
	Status string
	Data   MatrixData
}

MatrixResponse MatrixResponse

type MatrixResult

type MatrixResult struct {
	Metric map[string]string `json:"metric"`
	Values []Value           `json:"values"`
}

type Option added in v0.3.31

type Option func(*Options)

func AggregateOverTimeFunction added in v0.3.31

func AggregateOverTimeFunction(f dao.AggregateFunction) Option

func EndTime added in v0.3.31

func EndTime(t *time.Time) Option

func StartTime added in v0.3.31

func StartTime(t *time.Time) Option

func StepDuration added in v0.3.31

func StepDuration(d *time.Duration) Option

func Timeout added in v0.3.31

func Timeout(t *time.Time) Option

type Options added in v0.3.31

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

func BuildDefaultOptions added in v0.3.31

func BuildDefaultOptions() Options

type Prometheus

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

Prometheus Prometheus api client

func New

func New(config Config) (*Prometheus, error)

New New Prometheus api client with configuration

func (*Prometheus) Close

func (p *Prometheus) Close()

Close Free resoure used by Prometehus

func (*Prometheus) Query added in v0.3.31

func (p *Prometheus) Query(query string, startTime, timeout *time.Time) (Response, error)

Query Query data over a range of time from prometheus

func (*Prometheus) QueryRange

func (p *Prometheus) QueryRange(query string, startTime, endTime *time.Time, stepTime *time.Duration) (Response, error)

QueryRange Query data over a range of time from prometheus

type Response

type Response struct {
	Status    string `json:"status"`
	Data      Data   `json:"data"`
	ErrorType string `json:"errorType"`
	Error     string `json:"error"`
}

Response Response structure of prometheus http response

func (Response) GetEntities added in v0.3.49

func (r Response) GetEntities() ([]Entity, error)

func (Response) GetEntitiesMatrix added in v0.3.49

func (r Response) GetEntitiesMatrix() ([]Entity, error)

func (Response) GetEntitiesVector added in v0.3.49

func (r Response) GetEntitiesVector() ([]Entity, error)

func (Response) GetMatrixResponse

func (r Response) GetMatrixResponse() (MatrixResponse, error)

type ResultType

type ResultType string

ResultType Prometheus http resultType

var MatrixResultType ResultType = "matrix"

MatrixResultType Prometheus http matrix resultType

var ScalarResultType ResultType = "scalar"

ScalarResultType Prometheus http scalar resultType

var StringResultType ResultType = "string"

StringResultType Prometheus http string resultType

var VectorResultType ResultType = "vector"

VectorResultType Prometheus http vector resultType

type ScalarResult

type ScalarResult UnixTimeWithScalarValue

type StringResult

type StringResult UnixTimeWithStringValue

type TLSConfig

type TLSConfig struct {
	InsecureSkipVerify bool `mapstructure:"insecure-skip-verify"`
}

TLSConfig Configuration of tls connection

type UnixTimeWithSampleValue

type UnixTimeWithSampleValue struct {
	UnixTime    time.Time
	SampleValue string
}

type UnixTimeWithScalarValue

type UnixTimeWithScalarValue struct {
	UnixTime    time.Time
	ScalarValue string
}

type UnixTimeWithStringValue

type UnixTimeWithStringValue struct {
	UnixTime    time.Time
	StringValue string
}

type Value

type Value []interface{}

type VectorData

type VectorData struct {
	ResultType ResultType
	Result     []struct {
		Metric map[string]string
		Value  UnixTimeWithSampleValue
	}
}

VectorData VectorData

type VectorResponse

type VectorResponse struct {
	Status string
	Data   VectorData
}

VectorResponse VectorResponse

type VectorResult

type VectorResult struct {
	Metric map[string]string `json:"metric"`
	Value  Value             `json:"value"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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