Documentation ¶
Index ¶
- func DomainEval(_ context.Context, domain string, port uint32, timeout time.Duration) (map[watch.Indexer]*Point, error)
- func EndpointDuration(_ context.Context, url string, method vobj.HttpMethod, ...) map[watch.Indexer]*Point
- func EndpointPing(_ context.Context, endpoint string, timeout time.Duration) (map[watch.Indexer]*Point, error)
- func EndpointPortEval(_ context.Context, endpoint string, port uint32, timeout time.Duration) (map[watch.Indexer]*Point, error)
- type BasicAuth
- type BasicInfo
- type Datasource
- type EvalFunc
- type Metadata
- type Metric
- type MetricDatasource
- func NewMetricDatasource(storageType vobj.StorageType, opts ...MetricDatasourceBuildOption) (MetricDatasource, error)
- func NewMockMetricDatasource() MetricDatasource
- func NewPrometheusDatasource(opts ...PrometheusOption) MetricDatasource
- func NewVictoriametricsDatasource(opts ...VictoriametricsDatasourceOption) MetricDatasource
- type MetricDatasourceBuildOption
- type PingDetail
- type Point
- type PromMetadataResponse
- type PromMetricInfo
- type PromMetricSeriesResponse
- type PromQueryData
- type PromQueryResponse
- type PromQueryResult
- type PrometheusOption
- type QueryResponse
- type QueryValue
- type Value
- type VictoriametricsDatasourceOption
- func WithVictoriametricsBasicAuth(username, password string) VictoriametricsDatasourceOption
- func WithVictoriametricsEndpoint(endpoint string) VictoriametricsDatasourceOption
- func WithVictoriametricsID(id uint32) VictoriametricsDatasourceOption
- func WithVictoriametricsStep(step uint32) VictoriametricsDatasourceOption
- type VictoriametricsMetadataResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DomainEval ¶ added in v1.1.0
func DomainEval(_ context.Context, domain string, port uint32, timeout time.Duration) (map[watch.Indexer]*Point, error)
DomainEval 函数用于获取域名的证书信息,并返回一个 map[Indexer]*Point 结构
其中 Indexer 是一个标签,用于标识一个数据点,Point 是一个数据点,包含标签和值。
func EndpointDuration ¶ added in v1.1.0
func EndpointDuration(_ context.Context, url string, method vobj.HttpMethod, headers map[string]string, body string, timeout time.Duration) map[watch.Indexer]*Point
EndpointDuration 函数用于获取指定endpoint的请求相应时间和状态码
Types ¶
type Datasource ¶
type Datasource interface {
Metric() (MetricDatasource, error)
}
Datasource 数据源通用接口
func NewDatasource ¶
func NewDatasource(config *api.Datasource) Datasource
NewDatasource 根据配置创建对应的数据源
type EvalFunc ¶
type EvalFunc func(ctx context.Context, expr string, duration *types.Duration) (map[watch.Indexer]*Point, error)
func MetricEval ¶
func MetricEval(items ...MetricDatasource) EvalFunc
type Metadata ¶
type Metadata struct { // Metric 元数据列表 Metric []*Metric `json:"metric"` // Timestamp 查询时间戳 Timestamp int64 `json:"timestamp"` }
Metadata 查询到的元数据详情
type Metric ¶
type Metric struct { // Name 指标名称 Name string `json:"name"` // Help 帮助信息 Help string `json:"help"` // Type 类型 Type string `json:"type"` // Labels 标签集合 Labels map[string][]string `json:"labels"` // Unit 指标单位 Unit string `json:"unit"` }
Metric 查询到的数据详情, 用与元数据构建
type MetricDatasource ¶
type MetricDatasource interface { Step() uint32 // Query 查询数据 Query(ctx context.Context, expr string, duration int64) ([]*QueryResponse, error) // QueryRange 查询数据 QueryRange(ctx context.Context, expr string, start, end int64, step uint32) ([]*QueryResponse, error) // Metadata 查询元数据 Metadata(ctx context.Context) (*Metadata, error) // GetBasicInfo 获取数据源信息 GetBasicInfo() *BasicInfo }
MetricDatasource 数据源完整接口定义
func NewMetricDatasource ¶
func NewMetricDatasource(storageType vobj.StorageType, opts ...MetricDatasourceBuildOption) (MetricDatasource, error)
NewMetricDatasource 创建数据源
func NewMockMetricDatasource ¶
func NewMockMetricDatasource() MetricDatasource
NewMockMetricDatasource 创建一个mock metric数据源
func NewPrometheusDatasource ¶
func NewPrometheusDatasource(opts ...PrometheusOption) MetricDatasource
NewPrometheusDatasource 创建 prometheus 数据源
func NewVictoriametricsDatasource ¶
func NewVictoriametricsDatasource(opts ...VictoriametricsDatasourceOption) MetricDatasource
NewVictoriametricsDatasource creates a new victoriametrics datasource.
type MetricDatasourceBuildOption ¶
type MetricDatasourceBuildOption func(p *datasourceBuild)
MetricDatasourceBuildOption 数据源构建选项
func WithMetricBasicAuth ¶
func WithMetricBasicAuth(username, password string) MetricDatasourceBuildOption
WithMetricBasicAuth 设置数据源认证信息
func WithMetricEndpoint ¶
func WithMetricEndpoint(endpoint string) MetricDatasourceBuildOption
WithMetricEndpoint 设置数据源地址
func WithMetricID ¶ added in v1.0.2
func WithMetricID(id uint32) MetricDatasourceBuildOption
WithMetricID 设置数据源ID
func WithMetricStep ¶
func WithMetricStep(step uint32) MetricDatasourceBuildOption
WithMetricStep 设置数据源步长
type PingDetail ¶ added in v1.1.0
type PingDetail struct { // 总包数 TotalPackets float64 `json:"totalPackets,omitempty"` // 成功包数 SuccessPackets float64 `json:"successPackets,omitempty"` // 丢包率 LossRate float64 `json:"lossRate,omitempty"` // 最小延迟 MinDelay float64 `json:"minDelay,omitempty"` // 最大延迟 MaxDelay float64 `json:"maxDelay,omitempty"` // 平均延迟 AvgDelay float64 `json:"avgDelay,omitempty"` // 标准差 StdDevDelay float64 `json:"stdDevDelay,omitempty"` }
type Point ¶
type Point struct { // 标签集合 Labels map[string]string `json:"labels"` // 值 Values []*Value `json:"value"` }
Point 数据点
type PromMetadataResponse ¶
type PromMetadataResponse struct { Status string `json:"status"` Data map[string][]PromMetricInfo `json:"data"` }
PromMetadataResponse 元数据响应
type PromMetricInfo ¶
type PromMetricInfo struct { Type string `json:"type"` Help string `json:"help"` Unit string `json:"unit"` }
PromMetricInfo 元数据信息
type PromMetricSeriesResponse ¶
type PromMetricSeriesResponse struct { Status string `json:"status"` Data []map[string]string `json:"data"` Error string `json:"error"` ErrorType string `json:"errorType"` }
PromMetricSeriesResponse 元数据响应
type PromQueryData ¶
type PromQueryData struct { ResultType string `json:"resultType"` Result []*PromQueryResult `json:"result"` }
PromQueryData 查询数据
type PromQueryResponse ¶
type PromQueryResponse struct { Status string `json:"status"` Data *PromQueryData `json:"data"` ErrorType string `json:"errorType"` Error string `json:"error"` }
PromQueryResponse 查询响应 {"status":"success","data":{"resultType":"vector","result":[{"metric":{"__name__":"node_cpu_seconds_total","cpu":"0","instance":"10.0.0.1:9100","job":"node-exporter","mode":"idle"},"value":[1629874800.0,"0.01"]},{"metric":{"__name__":"node_cpu_seconds_total","cpu":"0","instance":"10.0.0.2:9100","job":"node-exporter","mode":"idle"},"value":[1629874800.0,"0.01"]}]}}
type PromQueryResult ¶
type PromQueryResult struct { Metric map[string]string `json:"metric"` Value [2]any `json:"value"` Values [][2]any `json:"values"` }
PromQueryResult 查询响应数据
type PrometheusOption ¶
type PrometheusOption func(p *prometheusDatasource)
PrometheusOption 数据源配置
func WithPrometheusBasicAuth ¶
func WithPrometheusBasicAuth(username, password string) PrometheusOption
WithPrometheusBasicAuth 设置数据源配置
func WithPrometheusEndpoint ¶
func WithPrometheusEndpoint(endpoint string) PrometheusOption
WithPrometheusEndpoint 设置数据源地址
func WithPrometheusID ¶ added in v1.1.0
func WithPrometheusID(id uint32) PrometheusOption
WithPrometheusID 设置数据源ID
func WithPrometheusStep ¶
func WithPrometheusStep(step uint32) PrometheusOption
WithPrometheusStep 设置步长
type QueryResponse ¶
type QueryResponse struct { // 标签集合 Labels map[string]string `json:"labels"` // 值 Value *QueryValue `json:"value"` Values []*QueryValue `json:"values"` // 结果类型 ResultType string `json:"resultType"` }
QueryResponse 查询到的响应
type QueryValue ¶
QueryValue 查询到的值
type VictoriametricsDatasourceOption ¶
type VictoriametricsDatasourceOption func(*victoriametricsDatasource)
func WithVictoriametricsBasicAuth ¶
func WithVictoriametricsBasicAuth(username, password string) VictoriametricsDatasourceOption
WithVictoriametricsBasicAuth 设置数据源配置
func WithVictoriametricsEndpoint ¶
func WithVictoriametricsEndpoint(endpoint string) VictoriametricsDatasourceOption
WithVictoriametricsEndpoint 设置数据源地址
func WithVictoriametricsID ¶ added in v1.1.0
func WithVictoriametricsID(id uint32) VictoriametricsDatasourceOption
WithVictoriametricsID 设置数据源ID
func WithVictoriametricsStep ¶
func WithVictoriametricsStep(step uint32) VictoriametricsDatasourceOption
WithVictoriametricsStep 设置步长