Documentation
¶
Index ¶
- func DomainEval(_ context.Context, domain string, port uint32, timeout time.Duration) (map[watch.Indexer]*Point, error)
- func EndpointDuration(ctx context.Context, url string, method vobj.HTTPMethod, ...) map[watch.Indexer]*Point
- func EndpointPing(_ context.Context, endpoint string, seconds 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 Config
- func (d *Config) GetKafka() *conf.Kafka
- func (d *Config) GetMQTT() *conf.MQTT
- func (d *Config) GetMetric() *MetricConfig
- func (d *Config) GetRocketMQ() *conf.RocketMQ
- func (d *Config) Map() map[string]any
- func (d *Config) MarshalJSON() ([]byte, error)
- func (d *Config) Scan(src any) (err error)
- func (d *Config) String() string
- func (d *Config) Value() (driver.Value, error)
- type Datasource
- type EvalFunc
- type Metadata
- type Metric
- type MetricConfig
- type MetricConfigHeader
- type MetricConfigParams
- 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(ctx context.Context, url string, method vobj.HTTPMethod, headers map[string]string, body string, timeout time.Duration) map[watch.Indexer]*Point
EndpointDuration 函数用于获取指定endpoint的请求相应时间和状态码
Types ¶
type BasicInfo ¶ added in v1.0.2
type BasicInfo struct {
Endpoint string `json:"endpoint"`
ID uint32 `json:"id"`
BasicAuth *BasicAuth `json:"basic_auth"`
}
BasicInfo 数据源信息
type Config ¶ added in v1.2.0
type Config struct {
// contains filtered or unexported fields
}
Config 数据源配置
func NewDatasourceConfig ¶ added in v1.2.0
NewDatasourceConfig 基于map创建DatasourceConfig
func NewDatasourceConfigByString ¶ added in v1.2.0
NewDatasourceConfigByString 基于string创建DatasourceConfig
func (*Config) GetMetric ¶ added in v1.2.16
func (d *Config) GetMetric() *MetricConfig
GetMetric 获取指标数据源配置
func (*Config) GetRocketMQ ¶ added in v1.2.0
GetRocketMQ 获取RocketMQ配置
func (*Config) MarshalJSON ¶ added in v1.2.0
MarshalJSON 实现 json.Marshaler 接口
type Datasource ¶
type Datasource interface {
Metric() (MetricDatasource, error)
}
Datasource 数据源通用接口
func NewDatasource ¶
func NewDatasource(config *api.DatasourceItem) Datasource
NewDatasource 根据配置创建对应的数据源
type EvalFunc ¶
type EvalFunc func(ctx context.Context, expr string, duration *types.Duration) (map[watch.Indexer]*Point, error)
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 MetricConfig ¶ added in v1.2.16
type MetricConfig struct {
ClientCert string `json:"clientCert"`
ClientKey string `json:"clientKey"`
Headers []*MetricConfigHeader `json:"headers"`
Params []*MetricConfigParams `json:"params"`
Password string `json:"password"`
SelfCACert string `json:"selfCACert"`
ServerName string `json:"serverName"`
SkipVerify bool `json:"skipVerify"`
Username string `json:"username"`
}
MetricConfig 指标数据源配置
type MetricConfigHeader ¶ added in v1.2.16
MetricConfigHeader 指标数据源配置-请求头参数
type MetricConfigParams ¶ added in v1.2.16
MetricConfigParams 指标数据源配置-请求参数
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 ¶ added in v1.2.14
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"`
}
PingDetail ping探测器详情
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 Value ¶
type Value struct {
Value float64 `json:"value"`
Timestamp int64 `json:"timestamp"`
Ext map[string]any `json:"ext"`
}
Value 数据源查询值
type VictoriaMetricsDatasourceOption ¶ added in v1.2.14
type VictoriaMetricsDatasourceOption func(*victoriaMetricsDatasource)
VictoriaMetricsDatasourceOption victoriaMetrics数据源选项
func WithVictoriaMetricsBasicAuth ¶ added in v1.2.14
func WithVictoriaMetricsBasicAuth(username, password string) VictoriaMetricsDatasourceOption
WithVictoriaMetricsBasicAuth 设置数据源配置
func WithVictoriaMetricsEndpoint ¶ added in v1.2.14
func WithVictoriaMetricsEndpoint(endpoint string) VictoriaMetricsDatasourceOption
WithVictoriaMetricsEndpoint 设置数据源地址
func WithVictoriaMetricsID ¶ added in v1.2.14
func WithVictoriaMetricsID(id uint32) VictoriaMetricsDatasourceOption
WithVictoriaMetricsID 设置数据源ID
func WithVictoriaMetricsStep ¶ added in v1.2.14
func WithVictoriaMetricsStep(step uint32) VictoriaMetricsDatasourceOption
WithVictoriaMetricsStep 设置步长
type VictoriaMetricsMetadataResponse ¶ added in v1.2.14
type VictoriaMetricsMetadataResponse struct {
Status string `json:"status"`
Data []string `json:"data"`
}
VictoriaMetricsMetadataResponse victoriaMetrics元数据响应