Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command interface { // DatasourceUID returns UID of a data source that is used by machine learning as the source of data DatasourceUID() string // Execute creates a payload send request to the ML API by calling the function argument sendRequest, and then parses response. // Function sendRequest is supposed to abstract the client configuration such creating http request, adding authorization parameters, host etc. Execute(from, to time.Time, sendRequest func(method string, path string, payload []byte) (response.Response, error)) (*backend.QueryDataResponse, error) Type() string }
Command is an interface implemented by all Machine Learning commands that can be executed against ML API.
type CommandConfiguration ¶
type CommandConfiguration struct { Type string `json:"type"` IntervalMs *uint `json:"intervalMs,omitempty"` Config jsoniter.RawMessage `json:"config"` }
type FakeCommand ¶
type FakeCommand struct { Method string Path string Payload []byte Response *backend.QueryDataResponse Error error Recordings []struct { From time.Time To time.Time Response response.Response Error error } }
func (*FakeCommand) DatasourceUID ¶
func (f *FakeCommand) DatasourceUID() string
func (*FakeCommand) Type ¶
func (f *FakeCommand) Type() string
type OutlierCommand ¶
type OutlierCommand struct {
// contains filtered or unexported fields
}
OutlierCommand implements Command that sends a request to outlier proxy API and converts response to backend.QueryDataResponse
func (OutlierCommand) DatasourceUID ¶
func (c OutlierCommand) DatasourceUID() string
func (OutlierCommand) Execute ¶
func (c OutlierCommand) Execute(from, to time.Time, sendRequest func(method string, path string, payload []byte) (response.Response, error)) (*backend.QueryDataResponse, error)
Execute copies the original configuration JSON and appends (overwrites) a field "start_end_attributes" and "grafana_url" to the root object. The value of "start_end_attributes" is JSON object that configures time range and interval. The value of "grafana_url" is app URL that should be used by ML to query the data source. After payload is generated it sends it to POST /proxy/api/v1/outlier endpoint and parses the response. The proxy API normally responds with a structured data. It recognizes status 200 and 204 as successful result. Other statuses are considered unsuccessful and result in error. Tries to extract error from the structured payload. Otherwise, mentions the full message in error
func (OutlierCommand) Type ¶
func (c OutlierCommand) Type() string
type OutlierCommandConfiguration ¶
type OutlierCommandConfiguration struct { DatasourceType string `json:"datasource_type"` DatasourceUID string `json:"datasource_uid,omitempty"` // If Query is empty it should be contained in a datasource specific format // inside of QueryParms. Query string `json:"query,omitempty"` QueryParams map[string]any `json:"query_params,omitempty"` Algorithm map[string]any `json:"algorithm"` ResponseType string `json:"response_type"` }