p8s

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPrometheusDatasource

func NewPrometheusDatasource(opts ...Option) agent.Datasource

NewPrometheusDatasource 创建 prometheus 数据源

Types

type Data

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

func (*Data) GetResult

func (d *Data) GetResult() []*Result

GetResult get result

func (*Data) GetResultType

func (d *Data) GetResultType() string

GetResultType get result type

type MetadataResponse

type MetadataResponse struct {
	Status string                  `json:"status"`
	Data   map[string][]MetricInfo `json:"data"`
}

func (*MetadataResponse) GetData

func (m *MetadataResponse) GetData() map[string][]MetricInfo

func (*MetadataResponse) GetMetricInfo

func (m *MetadataResponse) GetMetricInfo(metric string) []MetricInfo

func (*MetadataResponse) GetStatus

func (m *MetadataResponse) GetStatus() string

type MetricInfo

type MetricInfo struct {
	Type string `json:"type"`
	Help string `json:"help"`
	Unit string `json:"unit"`
}

func (*MetricInfo) GetHelp

func (m *MetricInfo) GetHelp() string

func (*MetricInfo) GetType

func (m *MetricInfo) GetType() string

func (*MetricInfo) GetUnit

func (m *MetricInfo) GetUnit() string

type MetricLabel

type MetricLabel map[string]string

func (MetricLabel) GetMetricName

func (m MetricLabel) GetMetricName() string

GetMetricName get metric name

type MetricSeriesResponse

type MetricSeriesResponse struct {
	Status    string        `json:"status"`
	Data      []MetricLabel `json:"data"`
	Error     string        `json:"error"`
	ErrorType string        `json:"errorType"`
}

func (*MetricSeriesResponse) GetData

func (m *MetricSeriesResponse) GetData() []MetricLabel

GetData get data

type Option

type Option func(*PrometheusDatasource)

func WithBasicAuth

func WithBasicAuth(basicAuth *agent.BasicAuth) Option

WithBasicAuth set basic auth

func WithEndpoint

func WithEndpoint(endpoint string) Option

WithEndpoint set endpoint

type PrometheusDatasource

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

PrometheusDatasource 数据源模型定义

func (*PrometheusDatasource) GetBasicAuth

func (p *PrometheusDatasource) GetBasicAuth() *agent.BasicAuth

func (*PrometheusDatasource) GetCategory

func (p *PrometheusDatasource) GetCategory() agent.Category

GetCategory 获取数据源类型

func (*PrometheusDatasource) GetEndpoint

func (p *PrometheusDatasource) GetEndpoint() string

func (*PrometheusDatasource) IsReady

func (p *PrometheusDatasource) IsReady() bool

IsReady 是否准备就绪

func (*PrometheusDatasource) Metadata

func (p *PrometheusDatasource) Metadata(ctx context.Context) (*agent.Metadata, error)

Metadata 实现数据源元数据获取接口

func (*PrometheusDatasource) Query

func (p *PrometheusDatasource) Query(ctx context.Context, expr string, duration int64) (*agent.QueryResponse, error)

Query 实现数据源查询接口

func (*PrometheusDatasource) WithBasicAuth

func (p *PrometheusDatasource) WithBasicAuth(basicAuth *agent.BasicAuth) agent.Datasource

type QueryResponse

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

func (*QueryResponse) GetData

func (r *QueryResponse) GetData() *Data

GetData get data

func (*QueryResponse) GetError

func (r *QueryResponse) GetError() string

GetError get error

func (*QueryResponse) GetErrorType

func (r *QueryResponse) GetErrorType() string

GetErrorType get error type

func (*QueryResponse) GetStatus

func (r *QueryResponse) GetStatus() string

GetStatus get status

type Result

type Result struct {
	Metric agent.Metric `json:"metric"`
	Value  []any        `json:"value"`
}

func (*Result) GetMetric

func (r *Result) GetMetric() agent.Metric

GetMetric get metric

func (*Result) GetValue

func (r *Result) GetValue() []any

GetValue get value

Jump to

Keyboard shortcuts

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