monitor

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2023 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// alert types enum
	AlertV2AlertType_AdvancedManual   = "ADVANCED_MANUAL"
	AlertV2AlertType_AnomalyDetection = "ANOMALY_DETECTION"
	AlertV2AlertType_Dowtime          = "DOWNTIME"
	AlertV2AlertType_Event            = "EVENT"
	AlertV2AlertType_GroupOutlier     = "GROUP_OUTLIER"
	AlertV2AlertType_Manual           = "MANUAL"
	AlertV2AlertType_Prometheus       = "PROMETHEUS"

	// severities enum
	AlertV2Severity_High   = "high"
	AlertV2Severity_Medium = "medium"
	AlertV2Severity_Low    = "low"
	AlertV2Severity_Info   = "info"

	// alert link type
	AlertLinkV2Type_Dashboard = "dashboard"
	AlertLinkV2Type_Runbook   = "runbook"

	// others
	AlertV2CaptureFilenameRegexp = `.*?\.scap`
)

--- Constants --

Variables

This section is empty.

Functions

func AlertLinkV2Type_Values added in v0.5.41

func AlertLinkV2Type_Values() []string

enums link types values

func AlertV2Severity_Values added in v0.5.41

func AlertV2Severity_Values() []string

enums severity values

func CloudAccountToJSON added in v0.5.47

func CloudAccountToJSON(providerInfo *CloudAccount) io.Reader

Types

type Alert

type Alert struct {
	ID                     int                 `json:"id,omitempty"`
	Version                int                 `json:"version,omitempty"`
	Type                   string              `json:"type"` // computed MANUAL
	Name                   string              `json:"name"`
	Description            string              `json:"description"`
	Enabled                bool                `json:"enabled"`
	GroupName              string              `json:"groupName,omitempty"`
	NotificationChannelIds []int               `json:"notificationChannelIds"`
	Filter                 string              `json:"filter"`
	Severity               int                 `json:"severity"` // 6 == INFO, 4 == LOW, 2 == MEDIUM, 0 == HIGH // NOT USED
	Timespan               int                 `json:"timespan"` // computed 600000000
	CustomNotification     *CustomNotification `json:"customNotification"`
	TeamID                 int                 `json:"teamId,omitempty"` // computed
	AutoCreated            bool                `json:"autoCreated"`
	SysdigCapture          *SysdigCapture      `json:"sysdigCapture"`
	RateOfChange           bool                `json:"rateOfChange,omitempty"`
	ReNotifyMinutes        int                 `json:"reNotifyMinutes"`
	ReNotify               bool                `json:"reNotify"`
	Valid                  bool                `json:"valid"`
	SeverityLabel          string              `json:"severityLabel,omitempty"` // MEDIUM == MEDIUM, LOW == LOW, NONE == INFO, HIGH == HIGH
	SegmentBy              []string            `json:"segmentBy"`
	SegmentCondition       *SegmentCondition   `json:"segmentCondition"`
	Criteria               *Criteria           `json:"criteria,omitempty"`
	Monitor                []*Monitor          `json:"monitor,omitempty"`
	Condition              string              `json:"condition"`
	SeverityLevel          int                 `json:"severityLevel,omitempty"` // 0 == MEDIUM, 2 == LOW, 4 == INFO, 6 == HIGH
}

func AlertFromJSON

func AlertFromJSON(body []byte) Alert

func (*Alert) ToJSON

func (a *Alert) ToJSON() io.Reader

type AlertLabelDescriptorV2 added in v0.5.41

type AlertLabelDescriptorV2 struct {
	ID       string `json:"id"`
	PublicID string `json:"publicId,omitempty"` //if passed empty in SegmentBy in put/posts will trigger an error 500
}

type AlertLinkV2 added in v0.5.41

type AlertLinkV2 struct {
	Type string `json:"type,omitempty"`
	ID   string `json:"id,omitempty"`
	Href string `json:"href,omitempty"`
}

type AlertMetricDescriptorV2 added in v0.5.41

type AlertMetricDescriptorV2 struct {
	ID string `json:"id"`
}

type AlertScopeV2 added in v0.5.41

type AlertScopeV2 struct {
	Expressions []ScopeExpressionV2 `json:"expressions,omitempty"`
}

AlertScopeV2

type AlertV2Common added in v0.5.41

type AlertV2Common struct {
	ID                            int                           `json:"id,omitempty"`
	Version                       int                           `json:"version,omitempty"`
	Name                          string                        `json:"name"`
	Description                   string                        `json:"description,omitempty"`
	DurationSec                   int                           `json:"durationSec"`
	Type                          string                        `json:"type"`
	Group                         string                        `json:"group,omitempty"`
	Severity                      string                        `json:"severity"`
	TeamID                        int                           `json:"teamId,omitempty"`
	Enabled                       bool                          `json:"enabled"`
	NotificationChannelConfigList []NotificationChannelConfigV2 `json:"notificationChannelConfigList"`
	CustomNotificationTemplate    *CustomNotificationTemplateV2 `json:"customNotificationTemplate,omitempty"`
	CaptureConfig                 *CaptureConfigV2              `json:"captureConfig,omitempty"`
	Links                         []AlertLinkV2                 `json:"links"`
}

AlertV2

type AlertV2ConfigDowntime added in v0.5.44

type AlertV2ConfigDowntime struct {
	ScopedSegmentedConfig

	ConditionOperator string  `json:"conditionOperator"`
	Threshold         float64 `json:"threshold"`

	GroupAggregation string                  `json:"groupAggregation"`
	TimeAggregation  string                  `json:"timeAggregation"`
	Metric           AlertMetricDescriptorV2 `json:"metric"`
	NoDataBehaviour  string                  `json:"noDataBehaviour"`
}

Downtime

type AlertV2ConfigEvent added in v0.5.44

type AlertV2ConfigEvent struct {
	ScopedSegmentedConfig

	ConditionOperator        string   `json:"conditionOperator"`
	Threshold                float64  `json:"threshold"`
	WarningConditionOperator string   `json:"warningConditionOperator,omitempty"`
	WarningThreshold         *float64 `json:"warningThreshold,omitempty"`

	Filter string   `json:"filter"`
	Tags   []string `json:"tags"`
}

Event

type AlertV2ConfigMetric added in v0.5.44

type AlertV2ConfigMetric struct {
	ScopedSegmentedConfig

	ConditionOperator        string   `json:"conditionOperator"`
	Threshold                float64  `json:"threshold"`
	WarningConditionOperator string   `json:"warningConditionOperator,omitempty"`
	WarningThreshold         *float64 `json:"warningThreshold,omitempty"`

	GroupAggregation string                  `json:"groupAggregation"`
	TimeAggregation  string                  `json:"timeAggregation"`
	Metric           AlertMetricDescriptorV2 `json:"metric"`
	NoDataBehaviour  string                  `json:"noDataBehaviour"`
}

Metric

type AlertV2ConfigPrometheus added in v0.5.41

type AlertV2ConfigPrometheus struct {
	Query string `json:"query"`
}

Prometheus

type AlertV2Downtime added in v0.5.44

type AlertV2Downtime struct {
	AlertV2Common
	Config AlertV2ConfigDowntime `json:"config"`
}

func AlertV2DowntimeFromJSON added in v0.5.44

func AlertV2DowntimeFromJSON(body []byte) AlertV2Downtime

func (*AlertV2Downtime) ToJSON added in v0.5.44

func (a *AlertV2Downtime) ToJSON() io.Reader

type AlertV2Event added in v0.5.44

type AlertV2Event struct {
	AlertV2Common
	Config AlertV2ConfigEvent `json:"config"`
}

func AlertV2EventFromJSON added in v0.5.44

func AlertV2EventFromJSON(body []byte) AlertV2Event

func (*AlertV2Event) ToJSON added in v0.5.44

func (a *AlertV2Event) ToJSON() io.Reader

type AlertV2Metric added in v0.5.44

type AlertV2Metric struct {
	AlertV2Common
	Config AlertV2ConfigMetric `json:"config"`
}

func AlertV2MetricFromJSON added in v0.5.44

func AlertV2MetricFromJSON(body []byte) AlertV2Metric

func (*AlertV2Metric) ToJSON added in v0.5.44

func (a *AlertV2Metric) ToJSON() io.Reader

type AlertV2Prometheus added in v0.5.41

type AlertV2Prometheus struct {
	AlertV2Common
	Config AlertV2ConfigPrometheus `json:"config"`
}

func AlertV2PrometheusFromJSON added in v0.5.41

func AlertV2PrometheusFromJSON(body []byte) AlertV2Prometheus

func (*AlertV2Prometheus) ToJSON added in v0.5.41

func (a *AlertV2Prometheus) ToJSON() io.Reader

type CaptureConfigV2 added in v0.5.41

type CaptureConfigV2 struct {
	DurationSec int    `json:"durationSec"`
	Storage     string `json:"storage"`
	Filter      string `json:"filter"`
	FileName    string `json:"fileName"`
	Enabled     bool   `json:"enabled"`
}

type CloudAccount added in v0.5.47

type CloudAccount struct {
	Id                int                     `json:"id"`
	Platform          string                  `json:"platform"`
	IntegrationType   string                  `json:"integrationType"`
	Credentials       CloudAccountCredentials `json:"credentials"`
	AdditionalOptions string                  `json:"additionalOptions"`
}

func CloudAccountFromJSON added in v0.5.47

func CloudAccountFromJSON(body []byte) *CloudAccount

type CloudAccountCredentials added in v0.5.47

type CloudAccountCredentials struct {
	AccountId string `json:"accountId"`
}

type Criteria

type Criteria struct {
	Text   string `json:"text"`
	Source string `json:"source"`
}

type CustomNotification

type CustomNotification struct {
	TitleTemplate  string `json:"titleTemplate"`
	UseNewTemplate bool   `json:"useNewTemplate"`
	PrependText    string `json:"prependText,omitempty"`
	AppendText     string `json:"appendText,omitempty"`
}

-------- Alert --------

type CustomNotificationTemplateV2 added in v0.5.41

type CustomNotificationTemplateV2 struct {
	Subject     string `json:"subject"`
	PrependText string `json:"prependText"`
	AppendText  string `json:"appendText"`
}

type EntryPoint

type EntryPoint struct {
	Module    string `json:"module"`
	Selection string `json:"selection,omitempty"`
}

type LabelDescriptorV3 added in v0.5.44

type LabelDescriptorV3 struct {
	ID       string `json:"id"`
	PublicID string `json:"publicId"`
}

type Monitor

type Monitor struct {
	Metric       string  `json:"metric"`
	StdDevFactor float64 `json:"stdDevFactor"`
}

type NotificationChannel

type NotificationChannel struct {
	ID      int                        `json:"id,omitempty"`
	Version int                        `json:"version,omitempty"`
	Type    string                     `json:"type"`
	Name    string                     `json:"name"`
	Enabled bool                       `json:"enabled"`
	Options NotificationChannelOptions `json:"options"`
}

func NotificationChannelFromJSON

func NotificationChannelFromJSON(body []byte) NotificationChannel

func NotificationChannelListFromJSON

func NotificationChannelListFromJSON(body []byte) []NotificationChannel

func (*NotificationChannel) ToJSON

func (n *NotificationChannel) ToJSON() io.Reader

type NotificationChannelConfigV2 added in v0.5.41

type NotificationChannelConfigV2 struct {
	// Type can be one of EMAIL, SNS, SLACK, PAGER_DUTY, VICTOROPS, OPSGENIE, WEBHOOK, IBM_FUNCTION, MS_TEAMS, TEAM_EMAIL, IBM_EVENT_NOTIFICATIONS, PROMETHEUS_ALERT_MANAGER
	ChannelID       int                          `json:"channelId,omitempty"`
	Type            string                       `json:"type,omitempty"`
	Name            string                       `json:"nam,omitempty"`
	Enabled         bool                         `json:"enabled,omitempty"`
	OverrideOptions NotificationChannelOptionsV2 `json:"overrideOptions"`
}

type NotificationChannelOptions

type NotificationChannelOptions struct {
	EmailRecipients   []string               `json:"emailRecipients,omitempty"`   // Type: email
	SnsTopicARNs      []string               `json:"snsTopicARNs,omitempty"`      // Type: SNS
	APIKey            string                 `json:"apiKey,omitempty"`            // Type: VictorOps
	RoutingKey        string                 `json:"routingKey,omitempty"`        // Type: VictorOps
	Url               string                 `json:"url,omitempty"`               // Type: OpsGenie, Webhook and Slack
	Channel           string                 `json:"channel,omitempty"`           // Type: Slack
	Account           string                 `json:"account,omitempty"`           // Type: PagerDuty
	ServiceKey        string                 `json:"serviceKey,omitempty"`        // Type: PagerDuty
	ServiceName       string                 `json:"serviceName,omitempty"`       // Type: PagerDuty
	AdditionalHeaders map[string]interface{} `json:"additionalHeaders,omitempty"` // Type: Webhook
	Region            string                 `json:"region,omitempty"`            // Type: OpsGenie

	NotifyOnOk           bool `json:"notifyOnOk"`
	NotifyOnResolve      bool `json:"notifyOnResolve"`
	SendTestNotification bool `json:"sendTestNotification"`
}

type NotificationChannelOptionsV2 added in v0.5.41

type NotificationChannelOptionsV2 struct {
	// commons
	NotifyOnAcknowledge        bool                          `json:"notifyOnAcknowledge,omitempty"`
	NotifyOnResolve            bool                          `json:"notifyOnResolve"`
	ReNotifyEverySec           *int                          `json:"reNotifyEverySec"` // must send null to remove this opt
	CustomNotificationTemplate *CustomNotificationTemplateV2 `json:"customNotificationTemplate,omitempty"`
	Thresholds                 []string                      `json:"thresholds"` //Set of thresholds the notification channel will be used for. Possible values [MAIN, WARNING]
}

type ScopeExpressionV2 added in v0.5.41

type ScopeExpressionV2 struct {
	Operand    string                  `json:"operand"` // old dot notation, e.g. "kubernetes.cluster.name"
	Descriptor *AlertLabelDescriptorV2 `json:"descriptor,omitempty"`
	Operator   string                  `json:"operator"`
	Value      []string                `json:"value"`
}

type ScopedSegmentedConfig added in v0.5.44

type ScopedSegmentedConfig struct {
	Scope     *AlertScopeV2            `json:"scope,omitempty"`
	SegmentBy []AlertLabelDescriptorV2 `json:"segmentBy"`
}

type SegmentCondition

type SegmentCondition struct {
	Type string `json:"type"`
}

type SysdigCapture

type SysdigCapture struct {
	Name       string      `json:"name"`
	Filters    string      `json:"filters,omitempty"`
	Duration   int         `json:"duration"`
	Type       string      `json:"type,omitempty"`
	BucketName string      `json:"bucketName"`
	Folder     string      `json:"folder,omitempty"`
	Enabled    bool        `json:"enabled"`
	StorageID  interface{} `json:"storageId,omitempty"`
}

type SysdigMonitorClient

type SysdigMonitorClient interface {
	CreateAlert(context.Context, Alert) (Alert, error)
	DeleteAlert(context.Context, int) error
	UpdateAlert(context.Context, Alert) (Alert, error)
	GetAlertById(context.Context, int) (Alert, error)

	CreateAlertV2Prometheus(context.Context, AlertV2Prometheus) (AlertV2Prometheus, error)
	DeleteAlertV2Prometheus(context.Context, int) error
	UpdateAlertV2Prometheus(context.Context, AlertV2Prometheus) (AlertV2Prometheus, error)
	GetAlertV2PrometheusById(context.Context, int) (AlertV2Prometheus, error)

	CreateAlertV2Event(context.Context, AlertV2Event) (AlertV2Event, error)
	DeleteAlertV2Event(context.Context, int) error
	UpdateAlertV2Event(context.Context, AlertV2Event) (AlertV2Event, error)
	GetAlertV2EventById(context.Context, int) (AlertV2Event, error)

	CreateAlertV2Metric(context.Context, AlertV2Metric) (AlertV2Metric, error)
	DeleteAlertV2Metric(context.Context, int) error
	UpdateAlertV2Metric(context.Context, AlertV2Metric) (AlertV2Metric, error)
	GetAlertV2MetricById(context.Context, int) (AlertV2Metric, error)

	CreateAlertV2Downtime(context.Context, AlertV2Downtime) (AlertV2Downtime, error)
	DeleteAlertV2Downtime(context.Context, int) error
	UpdateAlertV2Downtime(context.Context, AlertV2Downtime) (AlertV2Downtime, error)
	GetAlertV2DowntimeById(context.Context, int) (AlertV2Downtime, error)

	GetLabelDescriptor(ctx context.Context, label string) (LabelDescriptorV3, error)

	CreateNotificationChannel(context.Context, NotificationChannel) (NotificationChannel, error)
	GetNotificationChannelById(context.Context, int) (NotificationChannel, error)
	GetNotificationChannelByName(context.Context, string) (NotificationChannel, error)
	DeleteNotificationChannel(context.Context, int) error
	UpdateNotificationChannel(context.Context, NotificationChannel) (NotificationChannel, error)

	GetDashboardByID(context.Context, int) (*model.Dashboard, error)
	CreateDashboard(context.Context, *model.Dashboard) (*model.Dashboard, error)
	UpdateDashboard(context.Context, *model.Dashboard) (*model.Dashboard, error)
	DeleteDashboard(context.Context, int) error

	GetCloudAccountById(context.Context, int) (*CloudAccount, error)
	CreateCloudAccount(context.Context, *CloudAccount) (*CloudAccount, error)
	UpdateCloudAccount(context.Context, int, *CloudAccount) (*CloudAccount, error)
	DeleteCloudAccountById(context.Context, int) error
}

func NewSysdigMonitorClient

func NewSysdigMonitorClient(apiToken string, url string, insecure bool) SysdigMonitorClient

func WithExtraHeaders

func WithExtraHeaders(client SysdigMonitorClient, extraHeaders map[string]string) SysdigMonitorClient

type Team

type Team struct {
	UserRoles           []UserRoles `json:"userRoles"`
	Description         string      `json:"description"`
	Name                string      `json:"name"`
	ID                  int         `json:"id,omitempty"`
	Version             int         `json:"version,omitempty"`
	Origin              string      `json:"origin,omitempty"`
	LastUpdated         int64       `json:"lastUpdated,omitempty"`
	EntryPoint          EntryPoint  `json:"entryPoint"`
	Theme               string      `json:"theme"`
	CustomerID          int         `json:"customerId"`
	DateCreated         int64       `json:"dateCreated"`
	Products            []string    `json:"products,omitempty"`
	Show                string      `json:"show"`
	Immutable           bool        `json:"immutable"`
	CanUseSysdigCapture bool        `json:"canUseSysdigCapture"`
	CanUseCustomEvents  bool        `json:"canUseCustomEvents"`
	CanUseAwsMetrics    bool        `json:"canUseAwsMetrics"`
	CanUseBeaconMetrics bool        `json:"canUseBeaconMetrics"`
	UserCount           int         `json:"userCount"`
	Filter              string      `json:"filter,omitempty"`
	DefaultTeam         bool        `json:"default,omitempty"`
}

-------- Team --------

func TeamFromJSON

func TeamFromJSON(body []byte) Team

func (*Team) ToJSON

func (t *Team) ToJSON() io.Reader

type UserRoles

type UserRoles struct {
	UserId int    `json:"userId"`
	Email  string `json:"userName,omitempty"`
	Role   string `json:"role"`
	Admin  bool   `json:"admin,omitempty"`
}

type UsersList

type UsersList struct {
	ID    int    `json:"id"`
	Email string `json:"username"`
}

-------- UsersList --------

func UsersListFromJSON

func UsersListFromJSON(body []byte) []UsersList

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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