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.
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.
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 (x PolicyMetadataSet) Filter(selector PolicySelector) PolicyMetadataSet
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 QueryInput ¶
type QueryOutput ¶
type QueryOutput struct {
Alert []AlertBody `json:"alert"`
}
Click to show internal directories.
Click to hide internal directories.