monitoring

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourceTypeAlertPolicy         = "alertPolicy"
	ResourceTypeNotificationChannel = "notificationChannel"
	ResourceTypeSnooze              = "snooze"
)
View Source
const AlertPayloadType = "gcp.monitoring.alert"

AlertPayloadType is the event type emitted for each matching incident.

Variables

This section is empty.

Functions

func ListAlertingPolicyResources

func ListAlertingPolicyResources(ctx context.Context, c Client) ([]core.IntegrationResource, error)

ListAlertingPolicyResources lists the alert policies in the project, keyed by resource name so the Get/Delete/Update components can target one directly.

func ListNotificationChannelResources

func ListNotificationChannelResources(ctx context.Context, c Client) ([]core.IntegrationResource, error)

ListNotificationChannelResources lists the notification channels in the project so they can be attached to a policy.

func ListSnoozeResources added in v0.26.0

func ListSnoozeResources(ctx context.Context, c Client) ([]core.IntegrationResource, error)

ListSnoozeResources lists the snoozes in the project so the Get/Expire components can target one directly.

func SetClientFactory

func SetClientFactory(fn func(httpCtx core.HTTPContext, integration core.IntegrationContext) (Client, error))

Types

type AlertPolicyNodeMetadata

type AlertPolicyNodeMetadata struct {
	PolicyName  string `json:"policyName" mapstructure:"policyName"`
	DisplayName string `json:"displayName" mapstructure:"displayName"`
	ID          string `json:"id" mapstructure:"id"`
}

AlertPolicyNodeMetadata is stored on the node at Setup so the collapsed UI can show the policy's human-readable display name instead of its numeric ID.

type Client

type Client interface {
	GetURL(ctx context.Context, fullURL string) ([]byte, error)
	PostURL(ctx context.Context, fullURL string, body any) ([]byte, error)
	PatchURL(ctx context.Context, fullURL string, body any) ([]byte, error)
	DeleteURL(ctx context.Context, fullURL string) ([]byte, error)
	ProjectID() string
}

Client is the interface used by Cloud Monitoring components to call the API. Alert policies live on monitoring.googleapis.com (a different host than Compute), so every call uses the fully-qualified *URL helpers.

type ConditionSpec

type ConditionSpec struct {
	MetricType         string   `mapstructure:"metricType"`
	Comparison         string   `mapstructure:"comparison"`
	Threshold          *float64 `mapstructure:"threshold"`
	Duration           string   `mapstructure:"duration"`
	Aligner            string   `mapstructure:"aligner"`
	AlignmentPeriod    string   `mapstructure:"alignmentPeriod"`
	CrossSeriesReducer string   `mapstructure:"crossSeriesReducer"`
	GroupByFields      []string `mapstructure:"groupByFields"`
	TriggerType        string   `mapstructure:"triggerType"`
	TriggerValue       *float64 `mapstructure:"triggerValue"`
}

ConditionSpec is one threshold condition within an alerting policy.

type CreateAlertingPolicy

type CreateAlertingPolicy struct{}

func (*CreateAlertingPolicy) Cancel

func (*CreateAlertingPolicy) Cleanup

func (c *CreateAlertingPolicy) Cleanup(ctx core.SetupContext) error

func (*CreateAlertingPolicy) Color

func (c *CreateAlertingPolicy) Color() string

func (*CreateAlertingPolicy) Configuration

func (c *CreateAlertingPolicy) Configuration() []configuration.Field

func (*CreateAlertingPolicy) Description

func (c *CreateAlertingPolicy) Description() string

func (*CreateAlertingPolicy) Documentation

func (c *CreateAlertingPolicy) Documentation() string

func (*CreateAlertingPolicy) ExampleOutput

func (c *CreateAlertingPolicy) ExampleOutput() map[string]any

func (*CreateAlertingPolicy) Execute

func (*CreateAlertingPolicy) HandleHook

func (c *CreateAlertingPolicy) HandleHook(ctx core.ActionHookContext) error

func (*CreateAlertingPolicy) HandleWebhook

func (*CreateAlertingPolicy) Hooks

func (c *CreateAlertingPolicy) Hooks() []core.Hook

func (*CreateAlertingPolicy) Icon

func (c *CreateAlertingPolicy) Icon() string

func (*CreateAlertingPolicy) Label

func (c *CreateAlertingPolicy) Label() string

func (*CreateAlertingPolicy) Name

func (c *CreateAlertingPolicy) Name() string

func (*CreateAlertingPolicy) OutputChannels

func (c *CreateAlertingPolicy) OutputChannels(configuration any) []core.OutputChannel

func (*CreateAlertingPolicy) ProcessQueueItem

func (c *CreateAlertingPolicy) ProcessQueueItem(ctx core.ProcessQueueContext) (*uuid.UUID, error)

func (*CreateAlertingPolicy) Setup

type CreateAlertingPolicySpec

type CreateAlertingPolicySpec struct {
	DisplayName           string          `mapstructure:"displayName"`
	PromQL                PromQLSpec      `mapstructure:",squash"`
	Conditions            []ConditionSpec `mapstructure:"conditions"`
	Combiner              string          `mapstructure:"combiner"`
	Severity              string          `mapstructure:"severity"`
	NotificationChannels  []string        `mapstructure:"notificationChannels"`
	UserLabels            []KeyValueSpec  `mapstructure:"userLabels"`
	Enabled               *bool           `mapstructure:"enabled"`
	AutoClose             string          `mapstructure:"autoClose"`
	NotificationRateLimit string          `mapstructure:"notificationRateLimit"`
	Documentation         string          `mapstructure:"documentation"`
	DocumentationSubject  string          `mapstructure:"documentationSubject"`
}

type CreateSnooze added in v0.26.0

type CreateSnooze struct{}

func (*CreateSnooze) Cancel added in v0.26.0

func (c *CreateSnooze) Cancel(ctx core.ExecutionContext) error

func (*CreateSnooze) Cleanup added in v0.26.0

func (c *CreateSnooze) Cleanup(ctx core.SetupContext) error

func (*CreateSnooze) Color added in v0.26.0

func (c *CreateSnooze) Color() string

func (*CreateSnooze) Configuration added in v0.26.0

func (c *CreateSnooze) Configuration() []configuration.Field

func (*CreateSnooze) Description added in v0.26.0

func (c *CreateSnooze) Description() string

func (*CreateSnooze) Documentation added in v0.26.0

func (c *CreateSnooze) Documentation() string

func (*CreateSnooze) ExampleOutput added in v0.26.0

func (c *CreateSnooze) ExampleOutput() map[string]any

func (*CreateSnooze) Execute added in v0.26.0

func (c *CreateSnooze) Execute(ctx core.ExecutionContext) error

func (*CreateSnooze) HandleHook added in v0.26.0

func (c *CreateSnooze) HandleHook(ctx core.ActionHookContext) error

func (*CreateSnooze) HandleWebhook added in v0.26.0

func (*CreateSnooze) Hooks added in v0.26.0

func (c *CreateSnooze) Hooks() []core.Hook

func (*CreateSnooze) Icon added in v0.26.0

func (c *CreateSnooze) Icon() string

func (*CreateSnooze) Label added in v0.26.0

func (c *CreateSnooze) Label() string

func (*CreateSnooze) Name added in v0.26.0

func (c *CreateSnooze) Name() string

func (*CreateSnooze) OutputChannels added in v0.26.0

func (c *CreateSnooze) OutputChannels(configuration any) []core.OutputChannel

func (*CreateSnooze) ProcessQueueItem added in v0.26.0

func (c *CreateSnooze) ProcessQueueItem(ctx core.ProcessQueueContext) (*uuid.UUID, error)

func (*CreateSnooze) Setup added in v0.26.0

func (c *CreateSnooze) Setup(ctx core.SetupContext) error

type CreateSnoozeSpec added in v0.26.0

type CreateSnoozeSpec struct {
	DisplayName string   `mapstructure:"displayName"`
	Policies    []string `mapstructure:"policies"`
	Duration    string   `mapstructure:"duration"`
}

type DeleteAlertingPolicy

type DeleteAlertingPolicy struct{}

func (*DeleteAlertingPolicy) Cancel

func (*DeleteAlertingPolicy) Cleanup

func (d *DeleteAlertingPolicy) Cleanup(ctx core.SetupContext) error

func (*DeleteAlertingPolicy) Color

func (d *DeleteAlertingPolicy) Color() string

func (*DeleteAlertingPolicy) Configuration

func (d *DeleteAlertingPolicy) Configuration() []configuration.Field

func (*DeleteAlertingPolicy) Description

func (d *DeleteAlertingPolicy) Description() string

func (*DeleteAlertingPolicy) Documentation

func (d *DeleteAlertingPolicy) Documentation() string

func (*DeleteAlertingPolicy) ExampleOutput

func (d *DeleteAlertingPolicy) ExampleOutput() map[string]any

func (*DeleteAlertingPolicy) Execute

func (*DeleteAlertingPolicy) HandleHook

func (d *DeleteAlertingPolicy) HandleHook(ctx core.ActionHookContext) error

func (*DeleteAlertingPolicy) HandleWebhook

func (*DeleteAlertingPolicy) Hooks

func (d *DeleteAlertingPolicy) Hooks() []core.Hook

func (*DeleteAlertingPolicy) Icon

func (d *DeleteAlertingPolicy) Icon() string

func (*DeleteAlertingPolicy) Label

func (d *DeleteAlertingPolicy) Label() string

func (*DeleteAlertingPolicy) Name

func (d *DeleteAlertingPolicy) Name() string

func (*DeleteAlertingPolicy) OutputChannels

func (d *DeleteAlertingPolicy) OutputChannels(configuration any) []core.OutputChannel

func (*DeleteAlertingPolicy) ProcessQueueItem

func (d *DeleteAlertingPolicy) ProcessQueueItem(ctx core.ProcessQueueContext) (*uuid.UUID, error)

func (*DeleteAlertingPolicy) Setup

type DeleteAlertingPolicySpec

type DeleteAlertingPolicySpec struct {
	AlertPolicy string `mapstructure:"alertPolicy"`
}

type ExpireSnooze added in v0.26.0

type ExpireSnooze struct{}

func (*ExpireSnooze) Cancel added in v0.26.0

func (e *ExpireSnooze) Cancel(ctx core.ExecutionContext) error

func (*ExpireSnooze) Cleanup added in v0.26.0

func (e *ExpireSnooze) Cleanup(ctx core.SetupContext) error

func (*ExpireSnooze) Color added in v0.26.0

func (e *ExpireSnooze) Color() string

func (*ExpireSnooze) Configuration added in v0.26.0

func (e *ExpireSnooze) Configuration() []configuration.Field

func (*ExpireSnooze) Description added in v0.26.0

func (e *ExpireSnooze) Description() string

func (*ExpireSnooze) Documentation added in v0.26.0

func (e *ExpireSnooze) Documentation() string

func (*ExpireSnooze) ExampleOutput added in v0.26.0

func (e *ExpireSnooze) ExampleOutput() map[string]any

func (*ExpireSnooze) Execute added in v0.26.0

func (e *ExpireSnooze) Execute(ctx core.ExecutionContext) error

func (*ExpireSnooze) HandleHook added in v0.26.0

func (e *ExpireSnooze) HandleHook(ctx core.ActionHookContext) error

func (*ExpireSnooze) HandleWebhook added in v0.26.0

func (*ExpireSnooze) Hooks added in v0.26.0

func (e *ExpireSnooze) Hooks() []core.Hook

func (*ExpireSnooze) Icon added in v0.26.0

func (e *ExpireSnooze) Icon() string

func (*ExpireSnooze) Label added in v0.26.0

func (e *ExpireSnooze) Label() string

func (*ExpireSnooze) Name added in v0.26.0

func (e *ExpireSnooze) Name() string

func (*ExpireSnooze) OutputChannels added in v0.26.0

func (e *ExpireSnooze) OutputChannels(configuration any) []core.OutputChannel

func (*ExpireSnooze) ProcessQueueItem added in v0.26.0

func (e *ExpireSnooze) ProcessQueueItem(ctx core.ProcessQueueContext) (*uuid.UUID, error)

func (*ExpireSnooze) Setup added in v0.26.0

func (e *ExpireSnooze) Setup(ctx core.SetupContext) error

type ExpireSnoozeSpec added in v0.26.0

type ExpireSnoozeSpec struct {
	Snooze string `mapstructure:"snooze"`
}

type GetAlertingPolicy

type GetAlertingPolicy struct{}

func (*GetAlertingPolicy) Cancel

func (*GetAlertingPolicy) Cleanup

func (g *GetAlertingPolicy) Cleanup(ctx core.SetupContext) error

func (*GetAlertingPolicy) Color

func (g *GetAlertingPolicy) Color() string

func (*GetAlertingPolicy) Configuration

func (g *GetAlertingPolicy) Configuration() []configuration.Field

func (*GetAlertingPolicy) Description

func (g *GetAlertingPolicy) Description() string

func (*GetAlertingPolicy) Documentation

func (g *GetAlertingPolicy) Documentation() string

func (*GetAlertingPolicy) ExampleOutput

func (g *GetAlertingPolicy) ExampleOutput() map[string]any

func (*GetAlertingPolicy) Execute

func (g *GetAlertingPolicy) Execute(ctx core.ExecutionContext) error

func (*GetAlertingPolicy) HandleHook

func (g *GetAlertingPolicy) HandleHook(ctx core.ActionHookContext) error

func (*GetAlertingPolicy) HandleWebhook

func (*GetAlertingPolicy) Hooks

func (g *GetAlertingPolicy) Hooks() []core.Hook

func (*GetAlertingPolicy) Icon

func (g *GetAlertingPolicy) Icon() string

func (*GetAlertingPolicy) Label

func (g *GetAlertingPolicy) Label() string

func (*GetAlertingPolicy) Name

func (g *GetAlertingPolicy) Name() string

func (*GetAlertingPolicy) OutputChannels

func (g *GetAlertingPolicy) OutputChannels(configuration any) []core.OutputChannel

func (*GetAlertingPolicy) ProcessQueueItem

func (g *GetAlertingPolicy) ProcessQueueItem(ctx core.ProcessQueueContext) (*uuid.UUID, error)

func (*GetAlertingPolicy) Setup

func (g *GetAlertingPolicy) Setup(ctx core.SetupContext) error

type GetAlertingPolicySpec

type GetAlertingPolicySpec struct {
	AlertPolicy string `mapstructure:"alertPolicy"`
}

type GetSnooze added in v0.26.0

type GetSnooze struct{}

func (*GetSnooze) Cancel added in v0.26.0

func (g *GetSnooze) Cancel(ctx core.ExecutionContext) error

func (*GetSnooze) Cleanup added in v0.26.0

func (g *GetSnooze) Cleanup(ctx core.SetupContext) error

func (*GetSnooze) Color added in v0.26.0

func (g *GetSnooze) Color() string

func (*GetSnooze) Configuration added in v0.26.0

func (g *GetSnooze) Configuration() []configuration.Field

func (*GetSnooze) Description added in v0.26.0

func (g *GetSnooze) Description() string

func (*GetSnooze) Documentation added in v0.26.0

func (g *GetSnooze) Documentation() string

func (*GetSnooze) ExampleOutput added in v0.26.0

func (g *GetSnooze) ExampleOutput() map[string]any

func (*GetSnooze) Execute added in v0.26.0

func (g *GetSnooze) Execute(ctx core.ExecutionContext) error

func (*GetSnooze) HandleHook added in v0.26.0

func (g *GetSnooze) HandleHook(ctx core.ActionHookContext) error

func (*GetSnooze) HandleWebhook added in v0.26.0

func (*GetSnooze) Hooks added in v0.26.0

func (g *GetSnooze) Hooks() []core.Hook

func (*GetSnooze) Icon added in v0.26.0

func (g *GetSnooze) Icon() string

func (*GetSnooze) Label added in v0.26.0

func (g *GetSnooze) Label() string

func (*GetSnooze) Name added in v0.26.0

func (g *GetSnooze) Name() string

func (*GetSnooze) OutputChannels added in v0.26.0

func (g *GetSnooze) OutputChannels(configuration any) []core.OutputChannel

func (*GetSnooze) ProcessQueueItem added in v0.26.0

func (g *GetSnooze) ProcessQueueItem(ctx core.ProcessQueueContext) (*uuid.UUID, error)

func (*GetSnooze) Setup added in v0.26.0

func (g *GetSnooze) Setup(ctx core.SetupContext) error

type GetSnoozeSpec added in v0.26.0

type GetSnoozeSpec struct {
	Snooze string `mapstructure:"snooze"`
}

type KeyValueSpec

type KeyValueSpec struct {
	Key   string `mapstructure:"key"`
	Value string `mapstructure:"value"`
}

KeyValueSpec is one user label (key/value pair).

type OnAlert added in v0.26.0

type OnAlert struct{}

func (*OnAlert) Cleanup added in v0.26.0

func (t *OnAlert) Cleanup(ctx core.TriggerContext) error

func (*OnAlert) Color added in v0.26.0

func (t *OnAlert) Color() string

func (*OnAlert) Configuration added in v0.26.0

func (t *OnAlert) Configuration() []configuration.Field

func (*OnAlert) Description added in v0.26.0

func (t *OnAlert) Description() string

func (*OnAlert) Documentation added in v0.26.0

func (t *OnAlert) Documentation() string

func (*OnAlert) ExampleData added in v0.26.0

func (t *OnAlert) ExampleData() map[string]any

func (*OnAlert) HandleHook added in v0.26.0

func (t *OnAlert) HandleHook(ctx core.TriggerHookContext) (map[string]any, error)

func (*OnAlert) HandleWebhook added in v0.26.0

func (t *OnAlert) HandleWebhook(ctx core.WebhookRequestContext) (int, *core.WebhookResponseBody, error)

func (*OnAlert) Hooks added in v0.26.0

func (t *OnAlert) Hooks() []core.Hook

func (*OnAlert) Icon added in v0.26.0

func (t *OnAlert) Icon() string

func (*OnAlert) Label added in v0.26.0

func (t *OnAlert) Label() string

func (*OnAlert) Name added in v0.26.0

func (t *OnAlert) Name() string

func (*OnAlert) Setup added in v0.26.0

func (t *OnAlert) Setup(ctx core.TriggerContext) error

type OnAlertConfiguration added in v0.26.0

type OnAlertConfiguration struct {
	States []string `json:"states" mapstructure:"states"`
}

type OnAlertMetadata added in v0.26.0

type OnAlertMetadata struct {
	WebhookURL          string `json:"webhookUrl,omitempty" mapstructure:"webhookUrl"`
	NotificationChannel string `json:"notificationChannel,omitempty" mapstructure:"notificationChannel"`
}

type PromQLSpec added in v0.26.0

type PromQLSpec struct {
	ConditionKind      string `mapstructure:"conditionKind"`
	Query              string `mapstructure:"promqlQuery"`
	Duration           string `mapstructure:"promqlDuration"`
	EvaluationInterval string `mapstructure:"promqlEvaluationInterval"`
}

PromQLSpec holds the PromQL-condition inputs (used when conditionKind=promql).

type SnoozeNodeMetadata added in v0.26.0

type SnoozeNodeMetadata struct {
	SnoozeName  string `json:"snoozeName" mapstructure:"snoozeName"`
	DisplayName string `json:"displayName" mapstructure:"displayName"`
	ID          string `json:"id" mapstructure:"id"`
}

SnoozeNodeMetadata is stored on the node at Setup so the collapsed UI can show the snooze's human-readable display name instead of its numeric ID.

type UpdateAlertingPolicy

type UpdateAlertingPolicy struct{}

func (*UpdateAlertingPolicy) Cancel

func (*UpdateAlertingPolicy) Cleanup

func (u *UpdateAlertingPolicy) Cleanup(ctx core.SetupContext) error

func (*UpdateAlertingPolicy) Color

func (u *UpdateAlertingPolicy) Color() string

func (*UpdateAlertingPolicy) Configuration

func (u *UpdateAlertingPolicy) Configuration() []configuration.Field

func (*UpdateAlertingPolicy) Description

func (u *UpdateAlertingPolicy) Description() string

func (*UpdateAlertingPolicy) Documentation

func (u *UpdateAlertingPolicy) Documentation() string

func (*UpdateAlertingPolicy) ExampleOutput

func (u *UpdateAlertingPolicy) ExampleOutput() map[string]any

func (*UpdateAlertingPolicy) Execute

func (*UpdateAlertingPolicy) HandleHook

func (u *UpdateAlertingPolicy) HandleHook(ctx core.ActionHookContext) error

func (*UpdateAlertingPolicy) HandleWebhook

func (*UpdateAlertingPolicy) Hooks

func (u *UpdateAlertingPolicy) Hooks() []core.Hook

func (*UpdateAlertingPolicy) Icon

func (u *UpdateAlertingPolicy) Icon() string

func (*UpdateAlertingPolicy) Label

func (u *UpdateAlertingPolicy) Label() string

func (*UpdateAlertingPolicy) Name

func (u *UpdateAlertingPolicy) Name() string

func (*UpdateAlertingPolicy) OutputChannels

func (u *UpdateAlertingPolicy) OutputChannels(configuration any) []core.OutputChannel

func (*UpdateAlertingPolicy) ProcessQueueItem

func (u *UpdateAlertingPolicy) ProcessQueueItem(ctx core.ProcessQueueContext) (*uuid.UUID, error)

func (*UpdateAlertingPolicy) Setup

type UpdateAlertingPolicySpec

type UpdateAlertingPolicySpec struct {
	AlertPolicy           string          `mapstructure:"alertPolicy"`
	DisplayName           string          `mapstructure:"displayName"`
	PromQL                PromQLSpec      `mapstructure:",squash"`
	Conditions            []ConditionSpec `mapstructure:"conditions"`
	Combiner              string          `mapstructure:"combiner"`
	Severity              string          `mapstructure:"severity"`
	NotificationChannels  []string        `mapstructure:"notificationChannels"`
	UserLabels            []KeyValueSpec  `mapstructure:"userLabels"`
	Enabled               string          `mapstructure:"enabled"`
	AutoClose             string          `mapstructure:"autoClose"`
	NotificationRateLimit string          `mapstructure:"notificationRateLimit"`
	Documentation         string          `mapstructure:"documentation"`
	DocumentationSubject  string          `mapstructure:"documentationSubject"`
}

Jump to

Keyboard shortcuts

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