model

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AlertSchemaVersion = "v0"
)

Variables

This section is empty.

Functions

func SelectPolicyAll

func SelectPolicyAll(meta *PolicyMetadata) bool

Types

type Alert

type Alert struct {
	// ID is unique identifier of alert. It would be used for aggregation. If ID is empty, it will be generated automatically.
	ID AlertID `json:"id"`

	// Version is schema version of alert. It should be overwritten with AlertSchemaVersion.
	Version string `json:"version"`

	// JobID is identifier of job that generates alert.
	JobID types.JobID `json:"job_id"`

	// Timestamp is time when alert is generated. If Timestamp is zero, it will be set to current time.
	Timestamp time.Time `json:"timestamp"`

	AlertBody
}

Alert is a notification of overseer. It's generated by eval rules and sent to NotifyService. It's based on AlertBody and has additional metadata fields.

func NewAlert added in v0.0.4

func NewAlert(ctx context.Context, body AlertBody) (*Alert, error)

type AlertBody added in v0.0.4

type AlertBody struct {
	// RuleID is identifier of rule that generates alert. It's optional.
	RuleID string `json:"rule_id"`

	// Title is short description of alert. It's required.
	Title string `json:"title"`

	// Description is detailed description of alert.
	Description string `json:"description"`

	// Timestamp is time when alert is generated. If Timestamp is nil, it will be set to current time. It allows not only string time format (RFC3339) but also integer (Unix timestamp) and float (Unix timestamp with nano seconds).
	Timestamp any `json:"timestamp"`

	// Attrs is key-value pairs of additional information of alert.
	Attrs Attrs `json:"attrs"`
}

AlertBody is a body of Alert. It contains title, description, timestamp and additional attributes.

func (AlertBody) Validate added in v0.0.4

func (x AlertBody) Validate() error

type AlertID

type AlertID string

func NewAlertID added in v0.0.3

func NewAlertID() AlertID

type Attrs

type Attrs map[string]any

type PolicyMetadata

type PolicyMetadata struct {
	Title       string    `json:"title"`
	Description string    `json:"description"`
	Tags        []string  `json:"tags"`
	Input       []QueryID `json:"input"`
	Package     string    `json:"package"`
	Location    string    `json:"location"`
}

func NewPolicyMetadataFromAnnotation

func NewPolicyMetadataFromAnnotation(ref *ast.AnnotationsRef) (*PolicyMetadata, error)

func (*PolicyMetadata) HasAnyTag added in v0.0.3

func (x *PolicyMetadata) HasAnyTag(tags []string) bool

func (*PolicyMetadata) HasTag

func (x *PolicyMetadata) HasTag(tag string) bool

type PolicyMetadataSet

type PolicyMetadataSet []*PolicyMetadata

func NewPolicyMetadataSetFromAnnotation

func NewPolicyMetadataSetFromAnnotation(refs ast.FlatAnnotationsRefSet) (PolicyMetadataSet, error)

func (PolicyMetadataSet) Filter

func (PolicyMetadataSet) RequiredQueries

func (x PolicyMetadataSet) RequiredQueries(base Queries) Queries

type PolicySelector

type PolicySelector func(meta *PolicyMetadata) bool

func SelectPolicyByTag

func SelectPolicyByTag(tags ...string) PolicySelector

type Queries

type Queries []*Query

func (Queries) FindByID

func (x Queries) FindByID(id QueryID) *Query

func (Queries) IDs added in v0.0.4

func (x Queries) IDs() []QueryID

func (Queries) Validate

func (x Queries) Validate() error

type Query

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

func MustNewQuery

func MustNewQuery(name string, data []byte) *Query

func NewQuery

func NewQuery(name string, data []byte) (*Query, error)

func (*Query) ID

func (x *Query) ID() QueryID

func (*Query) String

func (x *Query) String() string

func (*Query) Validate

func (x *Query) Validate() error

type QueryID

type QueryID string

type QueryInput

type QueryInput map[QueryID]any

type QueryOutput

type QueryOutput struct {
	Alert []AlertBody `json:"alert"`
}

Jump to

Keyboard shortcuts

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