Documentation
¶
Index ¶
- Variables
- func ConvertField(frame *data.Frame, fieldName string, converter data.FieldConverter) error
- func DebugFrame(frame *data.Frame, headRows int) string
- func DebugFrameHead(frame *data.Frame, n int) string
- func DebugFrameInfo(frame *data.Frame) string
- func GetHistoryTimeRange(currentFrom time.Time, htr HistoryTimeRange) (time.Time, time.Time)
- func GetRecalculateTimeRange(from, to time.Time, htr HistoryTimeRange) (time.Time, time.Time)
- func NewDatasource(_ context.Context, _ backend.DataSourceInstanceSettings) (instancemgmt.Instance, error)
- func ParsePeriods(durations string, intervalMs int64) ([]uint, error)
- func RenderFrameWithBaseline(df *data.Frame, refID string) *data.Frame
- func RenderFrameWithForecast(df *data.Frame, refID string, seriesName string) *data.Frame
- func RenderFrameWithLLM(df *data.Frame) *data.Frame
- func RenderFrameWithOutlier(df *data.Frame) *data.Frame
- func TransformDataFrame(df *data.Frame) error
- func UniqueSlice[T comparable](s []T) []T
- type Alert4MLQueryBody
- type Alert4MLQueryJson
- type BaselineHyperParams
- type Datasource
- func (d *Datasource) CheckGrafanaHealth(config *models.PluginSettings) error
- func (d *Datasource) CheckHealth(_ context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error)
- func (d *Datasource) Dispose()
- func (d *Datasource) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error)
- type ForecastHyperParams
- type HistoryTimeRange
- type HyperParams
- type LLMHyperParams
- type RsodHyperParams
- type UniqueKeys
- type UniqueKeysUUID
Constants ¶
This section is empty.
Variables ¶
var ( // Alert4MLNamespace is the namespace UUID for Alert4ML plugin // Generated using uuid.NewSHA1(uuid.NameSpaceOID, []byte("alert4ml-plugin")) Alert4MLNamespace = uuid.MustParse("6ba7b810-9dad-11d1-80b4-00c04fd430c8") )
Define namespace UUID for generating deterministic UUID v5 Can use uuid.NameSpaceOID or custom namespace
Functions ¶
func ConvertField ¶
ConvertTimezField 应用 FieldConverter 对指定字段进行转换
func DebugFrameInfo ¶
func GetHistoryTimeRange ¶
func GetRecalculateTimeRange ¶
func NewDatasource ¶
func NewDatasource(_ context.Context, _ backend.DataSourceInstanceSettings) (instancemgmt.Instance, error)
NewDatasource creates a new datasource instance.
func RenderFrameWithBaseline ¶
func RenderFrameWithForecast ¶
func TransformDataFrame ¶
func UniqueSlice ¶
func UniqueSlice[T comparable](s []T) []T
Types ¶
type Alert4MLQueryBody ¶
type Alert4MLQueryBody struct {
Queries []json.RawMessage `json:"queries"`
From time.Time `json:"from"`
To time.Time `json:"to"`
IntervalMs int64 `json:"-"` // 查询间隔,单位毫秒
}
func ParseAlert4MLQueryTargets ¶
func ParseAlert4MLQueryTargets(queries []backend.DataQuery) ([]*Alert4MLQueryBody, error)
ParseAlert4MLQueryTargets 解析查询参数
type Alert4MLQueryJson ¶
type Alert4MLQueryJson struct {
DetectType string `json:"detectType"`
SupportDetect string `json:"supportDetect"`
SeriesRefId string `json:"seriesRefId"`
HyperParams json.RawMessage `json:"hyperParams"`
Targets []json.RawMessage `json:"targets,omitempty"`
ShowOriginalData bool `json:"showOriginalData"`
ShowAnomalyPoints bool `json:"showAnomalyPoints"`
HistoryTimeRange HistoryTimeRange `json:"historyTimeRange"`
UniqueKeys UniqueKeys `json:"uniqueKeys"`
}
func ParseQueryJson ¶
func ParseQueryJson(jsonData json.RawMessage) (*Alert4MLQueryJson, error)
ParseQuery 解析查询参数
type BaselineHyperParams ¶
type BaselineHyperParams struct {
TrendType string `json:"trendType,omitempty"`
IntervalMins int `json:"intervalMins,omitempty"`
ConfidenceLevel float64 `json:"confidenceLevel,omitempty"`
AllowNegativeBounds bool `json:"allowNegativeBounds,omitempty"`
StdDevMultiplier float64 `json:"stdDevMultiplier,omitempty"`
}
func (*BaselineHyperParams) GetType ¶
func (p *BaselineHyperParams) GetType() string
func (*BaselineHyperParams) SetDefaults ¶
func (p *BaselineHyperParams) SetDefaults()
type Datasource ¶
type Datasource struct{}
Datasource is an example datasource which can respond to data queries, reports its health and has streaming skills.
func (*Datasource) CheckGrafanaHealth ¶
func (d *Datasource) CheckGrafanaHealth(config *models.PluginSettings) error
func (*Datasource) CheckHealth ¶
func (d *Datasource) CheckHealth(_ context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error)
CheckHealth handles health checks sent from Grafana to the plugin. The main use case for these health checks is the test button on the datasource configuration page which allows users to verify that a datasource is working as expected.
func (*Datasource) Dispose ¶
func (d *Datasource) Dispose()
Dispose here tells plugin SDK that plugin wants to clean up resources when a new instance created. As soon as datasource settings change detected by SDK old datasource instance will be disposed and a new one will be created using NewSampleDatasource factory function.
func (*Datasource) QueryData ¶
func (d *Datasource) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error)
QueryData handles multiple queries and returns multiple responses. req contains the queries []DataQuery (where each query contains RefID as a unique identifier). The QueryDataResponse contains a map of RefID to the response for each query, and each response contains Frames ([]*Frame).
type ForecastHyperParams ¶
type ForecastHyperParams struct {
ModelName string `json:"model_name"`
Periods string `json:"periods"`
UUID string `json:"uuid"`
Budget float32 `json:"budget,omitempty"`
NumThreads int `json:"numThreads,omitempty"`
Nlags int `json:"nlags,omitempty"`
StdDevMultiplier float64 `json:"stdDevMultiplier,omitempty"`
AllowNegativeBounds bool `json:"allowNegativeBounds,omitempty"`
}
func (*ForecastHyperParams) GetType ¶
func (p *ForecastHyperParams) GetType() string
func (*ForecastHyperParams) SetDefaults ¶
func (p *ForecastHyperParams) SetDefaults()
type HistoryTimeRange ¶
type HyperParams ¶
type HyperParams interface {
GetType() string
SetDefaults() // 设置默认值的方法
}
HyperParams 是所有超参数的接口 参考 gRPC 源码模式,添加 SetDefaults 方法
func ParseHyperParams ¶
func ParseHyperParams(detectType string, data json.RawMessage) (HyperParams, error)
ParseHyperParams 根据检测类型解析超参数
type LLMHyperParams ¶
type LLMHyperParams struct {
ModelName string `json:"modelName,omitempty"`
Temperature int `json:"temperature,omitempty"`
MaxTokens int `json:"maxTokens,omitempty"`
}
func (*LLMHyperParams) GetType ¶
func (p *LLMHyperParams) GetType() string
func (*LLMHyperParams) SetDefaults ¶
func (p *LLMHyperParams) SetDefaults()
type RsodHyperParams ¶
type RsodHyperParams struct {
Periods string `json:"periods,omitempty"`
ModelName string `json:"model_name,omitempty"`
}
func (*RsodHyperParams) GetType ¶
func (p *RsodHyperParams) GetType() string
func (*RsodHyperParams) SetDefaults ¶
func (p *RsodHyperParams) SetDefaults()
SetDefaults 设置 RSOD 参数的默认值
type UniqueKeys ¶
type UniqueKeysUUID ¶
type UniqueKeysUUID struct {
DetectType string `json:"detectType"`
SupportDetect string `json:"supportDetect"`
UniqueKeys UniqueKeys `json:"uniqueKeys"`
SeriesName string `json:"seriesName"`
}
func (*UniqueKeysUUID) ToUUID ¶
func (uk *UniqueKeysUUID) ToUUID() (uuid.UUID, error)
ToUUID converts UniqueKeysUUID to UUID v5 Uses SHA-1 hash to ensure same input always generates same UUID
func (*UniqueKeysUUID) ToUUIDString ¶
func (uk *UniqueKeysUUID) ToUUIDString() (string, error)
ToUUIDString converts UniqueKeysUUID to UUID string