alarms

package
v0.9.9 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(client *golangsdk.ServiceClient, opts CreateOpts) (string, error)

Create creates a new alarm rule.

Types

type ActionOpts

type ActionOpts struct {
	// Specifies the IDs of the alarm rules.
	// A maximum of 100 alarm rules can be enabled or disabled at a time.
	AlarmIds []string `json:"alarm_ids" required:"true"`
	// Specifies whether to enable the alarm rules.
	// true: enables alarm rules, false: disables alarm rules
	AlarmEnabled bool `json:"alarm_enabled"`
}

ActionOpts contains the options for enabling or disabling alarm rules in batches.

type ActionResponse

type ActionResponse struct {
	// Specifies the IDs of the alarm rules that are enabled or disabled.
	AlarmIds []string `json:"alarm_ids"`
}

ActionResponse contains the response from the Action request.

func Action

func Action(client *golangsdk.ServiceClient, opts ActionOpts) (*ActionResponse, error)

Action enables or disables alarm rules in batches.

type Alarm

type Alarm struct {
	// Specifies the alarm rule ID.
	AlarmId string `json:"alarm_id"`
	// Specifies the alarm rule name.
	Name string `json:"name"`
	// Specifies the alarm rule description.
	Description string `json:"description"`
	// Specifies the namespace of the service.
	Namespace string `json:"namespace"`
	// Specifies the alarm policies.
	Policies []PolicyResp `json:"policies"`
	// Specifies the resource list.
	Resources []ResourceResp `json:"resources"`
	// Specifies the alarm rule type.
	Type string `json:"type"`
	// Specifies whether to generate alarms.
	Enabled bool `json:"enabled"`
	// Specifies whether notification is enabled.
	NotificationEnabled bool `json:"notification_enabled"`
	// Specifies the action triggered by an alarm.
	AlarmNotifications []Notification `json:"alarm_notifications"`
	// Specifies the action triggered after an alarm is cleared.
	OkNotifications []Notification `json:"ok_notifications"`
	// Specifies the time when the alarm notification was enabled.
	NotificationBeginTime string `json:"notification_begin_time"`
	// Specifies the time when the alarm notification was disabled.
	NotificationEndTime string `json:"notification_end_time"`
	// Specifies the enterprise project ID.
	EnterpriseProjectId string `json:"enterprise_project_id"`
	// Specifies the alarm template ID.
	AlarmTemplateId string `json:"alarm_template_id"`
}

Alarm represents an alarm rule.

type CreateOpts

type CreateOpts struct {
	// Specifies the alarm rule name.
	// Enter 1 to 128 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed.
	Name string `json:"name" required:"true"`
	// Provides supplementary information about the alarm rule. Enter 0 to 256 characters.
	Description string `json:"description,omitempty"`
	// Specifies the namespace of a service.
	// The value must be in the service.item format and can contain 3 to 32 characters.
	Namespace string `json:"namespace" required:"true"`
	// Specifies the resource group ID.
	// This parameter is mandatory when type is set to RESOURCE_GROUP.
	ResourceGroupId string `json:"resource_group_id,omitempty"`
	// Specifies the resource list. This parameter is mandatory when type is set to MULTI_INSTANCE.
	// A maximum of 1000 resources are supported.
	Resources [][]Dimension `json:"resources"`
	// Specifies the alarm policies.
	// Either policies or alarm_template_id must be configured.
	Policies []Policy `json:"policies,omitempty"`
	// Specifies the alarm rule type.
	// ALL_INSTANCE: all resources of a service
	// RESOURCE_GROUP: resource group
	// MULTI_INSTANCE: specified resources
	// EVENT.SYS: system event
	// EVENT.CUSTOM: custom event
	Type string `json:"type" required:"true"`
	// Specifies the alarm template ID. Either policies or alarm_template_id must be configured.
	AlarmTemplateId string `json:"alarm_template_id,omitempty"`
	// Specifies whether to generate alarms.
	Enabled *bool `json:"enabled,omitempty"`
	// Specifies whether to enable notification.
	NotificationEnabled *bool `json:"notification_enabled,omitempty"`
	// Specifies the action to be triggered when an alarm is generated.
	AlarmNotifications []Notification `json:"alarm_notifications,omitempty"`
	// Specifies the action to be triggered after an alarm is cleared.
	OkNotifications []Notification `json:"ok_notifications,omitempty"`
	// Specifies the time when the alarm notification was enabled. The value is in the format of HH:MM.
	NotificationBeginTime string `json:"notification_begin_time,omitempty"`
	// Specifies the time when the alarm notification was disabled. The value is in the format of HH:MM.
	NotificationEndTime string `json:"notification_end_time,omitempty"`
	// Specifies the enterprise project ID.
	EnterpriseProjectId string `json:"enterprise_project_id,omitempty"`
}

CreateOpts contains the options for creating an alarm rule.

type DeleteOpts

type DeleteOpts struct {
	// Specifies the IDs of the alarm rules to be deleted in batches.
	// A maximum of 10 alarm rules can be deleted at a time.
	AlarmIds []string `json:"alarm_ids" required:"true"`
}

DeleteOpts contains the options for deleting alarm rules in batches.

type DeleteResponse

type DeleteResponse struct {
	// Specifies the IDs of the alarm rules that are deleted.
	AlarmIds []string `json:"alarm_ids"`
}

DeleteResponse contains the response from the Delete request.

func Delete

func Delete(client *golangsdk.ServiceClient, opts DeleteOpts) (*DeleteResponse, error)

Delete deletes alarm rules in batches.

type Dimension

type Dimension struct {
	// Specifies the dimension name.
	Name string `json:"name" required:"true"`
	// Specifies the dimension value.
	Value string `json:"value,omitempty"`
}

Dimension represents a metric dimension.

type ListOpts

type ListOpts struct {
	// Specifies the alarm rule ID.
	AlarmId string `q:"alarm_id"`
	// Specifies the alarm rule name.
	Name string `q:"name"`
	// Specifies the namespace of a service.
	Namespace string `q:"namespace"`
	// Specifies the resource ID.
	ResourceId string `q:"resource_id"`
	// Specifies the enterprise project ID.
	EnterpriseProjectId string `q:"enterprise_project_id"`
	// Specifies the pagination offset. Default: 0
	Offset int `q:"offset"`
	// Specifies the number of records on each page. Default: 10, Max: 100
	Limit int `q:"limit"`
}

ListOpts contains the options for querying alarm rules.

type ListResponse

type ListResponse struct {
	// Specifies the list of alarm rules.
	Alarms []Alarm `json:"alarms"`
	// Specifies the total number of alarm rules.
	Count int `json:"count"`
}

ListResponse contains the response from the List request.

func List

func List(client *golangsdk.ServiceClient, opts ListOpts) (*ListResponse, error)

List returns a list of alarm rules.

type Notification

type Notification struct {
	// Specifies the notification type.
	// Possible values: notification, contact
	Type string `json:"type" required:"true"`
	// Specifies the list of SMN topic URNs.
	NotificationList []string `json:"notification_list" required:"true"`
}

Notification represents an alarm notification.

type Policy

type Policy struct {
	// Specifies the metric name.
	MetricName string `json:"metric_name" required:"true"`
	// Specifies the rollup period in seconds.
	// Possible values: 0, 1, 300, 1200, 3600, 14400, 86400
	Period int `json:"period" required:"true"`
	// Specifies the data rollup method.
	// Possible values: average, max, min, sum, variance
	Filter string `json:"filter" required:"true"`
	// Specifies the comparison operator.
	// Possible values: >, <, >=, <=, =, !=
	ComparisonOperator string `json:"comparison_operator" required:"true"`
	// Specifies the alarm threshold.
	Value float64 `json:"value" required:"true"`
	// Specifies the data unit.
	Unit string `json:"unit,omitempty"`
	// Specifies the number of consecutive times that the alarm condition is met.
	Count int `json:"count" required:"true"`
	// Specifies the interval for triggering an alarm if the alarm persists in seconds.
	// Possible values: 0, 300, 600, 900, 1800, 3600, 10800, 21600, 43200, 86400
	SuppressDuration int `json:"suppress_duration,omitempty"`
	// Specifies the alarm severity.
	// 1: critical, 2: major, 3: minor, 4: informational
	Level int `json:"level,omitempty"`
}

Policy represents an alarm policy.

type PolicyResp

type PolicyResp struct {
	// Specifies the metric name.
	MetricName string `json:"metric_name"`
	// Specifies the rollup period in seconds.
	Period int `json:"period"`
	// Specifies the data rollup method.
	Filter string `json:"filter"`
	// Specifies the comparison operator.
	ComparisonOperator string `json:"comparison_operator"`
	// Specifies the alarm threshold.
	Value float64 `json:"value"`
	// Specifies the hierarchical alarm threshold.
	HierarchicalValue map[string]interface{} `json:"hierarchical_value"`
	// Specifies the data unit.
	Unit string `json:"unit"`
	// Specifies the number of consecutive times.
	Count int `json:"count"`
	// Specifies the interval for triggering an alarm if the alarm persists.
	SuppressDuration int `json:"suppress_duration"`
	// Specifies the alarm severity.
	Level int `json:"level"`
}

PolicyResp represents an alarm policy in the response.

type ResourceResp

type ResourceResp struct {
	// Specifies the resource group ID.
	ResourceGroupId string `json:"resource_group_id"`
	// Specifies the resource group name.
	ResourceGroupName string `json:"resource_group_name"`
	// Specifies the metric dimensions.
	Dimensions []Dimension `json:"dimensions"`
}

ResourceResp represents a resource in the response.

Jump to

Keyboard shortcuts

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