extension

package
v0.0.0-...-a2946bf Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommonEvent

type CommonEvent struct {
	Content string               `json:"content"`
	Meta    repository.EventMeta `json:"meta"`
	Tags    []string             `json:"tags"`
	Origin  string               `json:"origin"`

	Control EventControl `json:"control"`
}

func DatadogLogForwardingToCommonEvents

func DatadogLogForwardingToCommonEvents(content []byte) ([]CommonEvent, error)

DatadogLogForwardingToCommonEvents Convert Datadog logs to generic events

func GrafanaToCommonEvent

func GrafanaToCommonEvent(content []byte) (*CommonEvent, error)

func LogstashToCommonEvent

func LogstashToCommonEvent(content []byte, contentField string) (*CommonEvent, error)

func OpenFalconToCommonEvent

func OpenFalconToCommonEvent(tos, content string) *CommonEvent

func PrometheusAlertToCommonEvent

func PrometheusAlertToCommonEvent(content []byte) (*CommonEvent, error)

func PrometheusToCommonEvents

func PrometheusToCommonEvents(content []byte) ([]*CommonEvent, error)

func (CommonEvent) CreateRepoEvent

func (evt CommonEvent) CreateRepoEvent() repository.Event

func (CommonEvent) GetControl

func (evt CommonEvent) GetControl() EventControl

func (CommonEvent) Serialize

func (evt CommonEvent) Serialize() string

type DatadogLogEvent

type DatadogLogEvent struct {
	ID         string         `json:"_id"`
	Date       string         `json:"date"`
	Host       string         `json:"host"`
	Message    string         `json:"message"`
	Service    string         `json:"service"`
	Source     string         `json:"source"`
	Status     string         `json:"status"`
	Tags       []string       `json:"tags"`
	Attributes map[string]any `json:"attributes"`
}

DatadogLogEvent represents a log event from Datadog

func (DatadogLogEvent) ToRepo

func (evt DatadogLogEvent) ToRepo() repository.Event

ToRepo convert Datadog log event to repository.Event

type EventControl

type EventControl struct {
	ID              string `json:"id"`               // 消息标识,用于去重
	InhibitInterval string `json:"inhibit_interval"` // 抑制周期,周期内相同 ID 的消息直接丢弃
	RecoveryAfter   string `json:"recovery_after"`   // 自动恢复周期,该事件后一直没有发生相同标识的 消息,则自动生成一条恢复消息
}

func (EventControl) GetInhibitInterval

func (mc EventControl) GetInhibitInterval() time.Duration

func (EventControl) GetRecoveryAfter

func (mc EventControl) GetRecoveryAfter() time.Duration

type GrafanaEvalMatch

type GrafanaEvalMatch struct {
	Value  float64 `json:"value"`
	Metric string  `json:"metric"`
	Tags   map[string]string
}

type GrafanaEvent

type GrafanaEvent struct {
	EvalMatches []GrafanaEvalMatch `json:"evalMatches"`
	ImageURL    string             `json:"imageUrl"`
	Message     string             `json:"message"`
	RuleID      int64              `json:"ruleId"`
	RuleName    string             `json:"ruleName"`
	RuleURL     string             `json:"ruleUrl"`
	State       string             `json:"state"`
	Title       string             `json:"title"`
}

func (GrafanaEvent) ToRepo

func (g GrafanaEvent) ToRepo() repository.Event

type PrometheusAlertEvent

type PrometheusAlertEvent struct {
	Version  string `json:"version"`
	GroupKey string `json:"groupKey"`

	Receiver string            `json:"receiver"`
	Status   string            `json:"status"`
	Alerts   []PrometheusEvent `json:"alerts"`

	GroupLabels       repository.EventMeta `json:"groupLabels"`
	CommonLabels      repository.EventMeta `json:"commonLabels"`
	CommonAnnotations repository.EventMeta `json:"commonAnnotations"`

	ExternalURL string `json:"externalURL"`
}

func (PrometheusAlertEvent) ToRepo

func (pam PrometheusAlertEvent) ToRepo() repository.Event

type PrometheusEvent

type PrometheusEvent struct {
	Status       string               `json:"status"`
	Labels       repository.EventMeta `json:"labels"`
	Annotations  repository.EventMeta `json:"annotations"`
	StartsAt     time.Time            `json:"startsAt"`
	EndsAt       time.Time            `json:"endsAt"`
	GeneratorURL string               `json:"generatorURL"`
}

func (PrometheusEvent) CreateRepoEvent

func (pm PrometheusEvent) CreateRepoEvent() repository.Event

func (PrometheusEvent) GetControl

func (pm PrometheusEvent) GetControl() EventControl

type RepoEvent

type RepoEvent interface {
	CreateRepoEvent() repository.Event
	GetControl() EventControl
}

Jump to

Keyboard shortcuts

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