engine

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KustoDeepLink(q string) (string, error)

KustoDeepLink returns an encoded string that can be used to create a deep link to a Kusto query.

func KustoQueryLinks(preText, query, endpoint, database string) (string, error)

KustoQueryLinks returns a string containing HTML links to the Kusto query in both the web and desktop UI.

func NewWorker added in v0.2.0

func NewWorker(cfg *WorkerConfig) *worker

NewWorker creates a worker and performs one-time match evaluation.

Types

type AlertCli

type AlertCli interface {
	Create(ctx context.Context, endpoint string, alert alert.Alert) error
}

type AlertResult added in v0.4.0

type AlertResult struct {
	Destination   string
	Title         string
	Summary       string
	Description   string
	Severity      int64
	Source        string
	CorrelationID string
	CustomFields  map[string]string
}

AlertResult is the delivery-neutral result of converting an alert query row.

func ParseAlertResult added in v0.4.0

func ParseAlertResult(qc *QueryContext, row azquery.Row) (AlertResult, error)

ParseAlertResult converts and validates a query row without performing delivery enrichment or I/O.

type Client

type Client interface {
	Endpoint(db string) string
	Query(ctx context.Context, qc *QueryContext, fn func(ctx context.Context, endpoint string, qc *QueryContext, row azquery.Row) error) (error, int)
	AvailableDatabases() []string
	FindCaseInsensitiveMatch(db string) string
}

func NewFakeKustoClient

func NewFakeKustoClient() Client

type Executor

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

func NewExecutor

func NewExecutor(opts ExecutorOpts) *Executor

TODO make AlertAddr string part of alertcli

func (*Executor) Close

func (e *Executor) Close() error

func (*Executor) HandlerFn

func (e *Executor) HandlerFn(ctx context.Context, endpoint string, qc *QueryContext, row azquery.Row) error

HandlerFn converts rows of a query to Alerts.

func (*Executor) Open

func (e *Executor) Open(ctx context.Context) error

func (*Executor) RunOnce

func (e *Executor) RunOnce(ctx context.Context)

type ExecutorOpts

type ExecutorOpts struct {
	AlertCli    AlertCli
	AlertAddr   string
	KustoClient Client
	RuleStore   ruleStore
	Region      string
	Tags        map[string]string
	Concurrency int
	CtrlCli     client.Client
	Clock       clock.Clock
}

type Notification

type Notification struct {
	// Title maps to the Title Notification field.
	Title string `kusto:"Title"`

	// Summary maps to the Description Notification field.
	Summary string `kusto:"Summary"`

	// Description maps to the Description Notification field.
	Description string `kusto:"Description"`

	// Severity maps to the Severity Notification field.
	Severity int64 `kusto:"Severity"`

	// CorrelationID maps to the CorrelationId Notification field.  If a correlation ID is specified, the hit count for
	// the original Notification will be incremented on each firing of the Notification.
	CorrelationID string `kusto:"CorrelationId"`

	// Recipient is the destination of the Notification.  Typically, a queue or email address.
	Recipient string `kusto:"Recipient"`

	// CustomFields are any additional fields that are not part of the Notification struct.
	CustomFields map[string]string
}

func (Notification) Validate

func (i Notification) Validate() error

type NotificationValidationError

type NotificationValidationError struct {
	Msg string
}

func (*NotificationValidationError) Error

type QueryContext

type QueryContext struct {
	Rule      *rules.Rule
	Query     string
	Stmt      azkustodata.Statement
	Options   []azkustodata.QueryOption
	Region    string
	StartTime time.Time
	EndTime   time.Time
}

func NewQueryContext

func NewQueryContext(rule *rules.Rule, endTime time.Time, region string) (*QueryContext, error)

func NewQueryContextForWindow added in v0.4.0

func NewQueryContextForWindow(rule *rules.Rule, startTime, endTime time.Time, region string) (*QueryContext, error)

type ThrottledNotificationsError added in v0.4.0

type ThrottledNotificationsError struct {
	Notifications []AlertResult
	Total         int
}

func (*ThrottledNotificationsError) Add added in v0.4.0

func (err *ThrottledNotificationsError) Add(notification AlertResult)

func (*ThrottledNotificationsError) Error added in v0.4.0

func (err *ThrottledNotificationsError) Error() string

func (*ThrottledNotificationsError) Unwrap added in v0.4.0

func (err *ThrottledNotificationsError) Unwrap() error

type UnknownDBError

type UnknownDBError struct {
	DB                   string
	AvailableDatabases   []string
	CaseInsensitiveMatch string
}

func (*UnknownDBError) Error

func (e *UnknownDBError) Error() string

type WorkerConfig added in v0.2.0

type WorkerConfig struct {
	Rule                 *rules.Rule
	Region               string
	Tags                 map[string]string
	KustoClient          Client
	MaxConcurrentQueries int
	AlertClient          interface {
		Create(ctx context.Context, endpoint string, alert alert.Alert) error
	}
	AlertAddr  string
	HandlerFn  func(ctx context.Context, endpoint string, qc *QueryContext, row azquery.Row) error
	CtrlClient client.Client

	Clock clock.Clock
	// contains filtered or unexported fields
}

WorkerConfig groups parameters for constructing a worker.

Jump to

Keyboard shortcuts

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