UNPKG

@huaweicloudos/pulumi

Version:

A Pulumi package for creating and managing Huaweicloud cloud resources.

273 lines 10.6 kB
"use strict"; // *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.Alarmrule = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Manages a Cloud Eye alarm rule resource within HuaweiCloud. * * ## Example Usage * ### Basic example * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as pulumi from "@huaweicloudos/pulumi"; * * const config = new pulumi.Config(); * const instanceId1 = config.requireObject("instanceId1"); * const instanceId2 = config.requireObject("instanceId2"); * const topicUrn = config.requireObject("topicUrn"); * const test = new huaweicloud.cse.Alarmrule("test", { * alarmName: "rule-test", * alarmActionEnabled: true, * alarmEnabled: true, * alarmType: "MULTI_INSTANCE", * metric: { * namespace: "SYS.ECS", * }, * resources: [ * { * dimensions: [{ * name: "instance_id", * value: instanceId1, * }], * }, * { * dimensions: [{ * name: "instance_id", * value: instanceId2, * }], * }, * ], * conditions: [ * { * period: 1200, * filter: "average", * comparisonOperator: ">", * value: 6.5, * unit: "B/s", * count: 1, * suppressDuration: 300, * metricName: "network_outgoing_bytes_rate_inband", * alarmLevel: 4, * }, * { * period: 3600, * filter: "average", * comparisonOperator: ">=", * value: 20, * unit: "B/s", * count: 1, * suppressDuration: 300, * metricName: "network_outgoing_bytes_rate_inband", * alarmLevel: 4, * }, * ], * alarmActions: [{ * type: "notification", * notificationLists: [topicUrn], * }], * }); * ``` * ### Alarm rule for All instance * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as pulumi from "@huaweicloudos/pulumi"; * * const config = new pulumi.Config(); * const topicUrn = config.requireObject("topicUrn"); * const test = new huaweicloud.cse.Alarmrule("test", { * alarmName: "rule-test", * alarmActionEnabled: true, * alarmEnabled: true, * alarmType: "ALL_INSTANCE", * metric: { * namespace: "AGT.ECS", * }, * resources: [{ * dimensions: [ * { * name: "instance_id", * }, * { * name: "mount_point", * }, * ], * }], * conditions: [{ * alarmLevel: 2, * suppressDuration: 0, * period: 1, * filter: "average", * comparisonOperator: ">", * value: 80, * count: 1, * metricName: "disk_usedPercent", * }], * alarmActions: [{ * type: "notification", * notificationLists: [topicUrn], * }], * }); * ``` * ### Alarm rule for event monitoring * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as pulumi from "@huaweicloudos/pulumi"; * * const config = new pulumi.Config(); * const topicUrn = config.requireObject("topicUrn"); * const test = new huaweicloud.cse.Alarmrule("test", { * alarmName: "rule-test", * alarmActionEnabled: true, * alarmType: "EVENT.SYS", * metric: { * namespace: "SYS.ECS", * }, * conditions: [{ * metricName: "stopServer", * period: 0, * filter: "average", * comparisonOperator: ">=", * value: 1, * unit: "count", * count: 1, * suppressDuration: 0, * alarmLevel: 2, * }], * alarmActions: [{ * type: "notification", * notificationLists: [topicUrn], * }], * }); * ``` * ### Alarm rule using the alarm template * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as pulumi from "@huaweicloudos/pulumi"; * * const config = new pulumi.Config(); * const topicUrn = config.requireObject("topicUrn"); * const alarmTemplateId = config.requireObject("alarmTemplateId"); * const instanceId = config.requireObject("instanceId"); * const test = new huaweicloud.cse.Alarmrule("test", { * alarmName: "rule-test", * alarmEnabled: true, * alarmActionEnabled: true, * alarmType: "MULTI_INSTANCE", * alarmTemplateId: alarmTemplateId, * metric: { * namespace: "SYS.ECS", * }, * resources: [{ * dimensions: [{ * name: "instance_id", * value: instanceId, * }], * }], * alarmActions: [{ * type: "notification", * notificationLists: [topicUrn], * }], * }); * ``` * * ## Import * * CES alarm rules can be imported using the `id`, e.g. bash * * ```sh * $ pulumi import huaweicloud:Cse/alarmrule:Alarmrule alarm_rule al1619578509719Ga0X1RGWv * ``` */ class Alarmrule extends pulumi.CustomResource { /** * Get an existing Alarmrule resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name, id, state, opts) { return new Alarmrule(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of Alarmrule. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === Alarmrule.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["alarmActionEnabled"] = state ? state.alarmActionEnabled : undefined; resourceInputs["alarmActions"] = state ? state.alarmActions : undefined; resourceInputs["alarmDescription"] = state ? state.alarmDescription : undefined; resourceInputs["alarmEnabled"] = state ? state.alarmEnabled : undefined; resourceInputs["alarmLevel"] = state ? state.alarmLevel : undefined; resourceInputs["alarmName"] = state ? state.alarmName : undefined; resourceInputs["alarmState"] = state ? state.alarmState : undefined; resourceInputs["alarmTemplateId"] = state ? state.alarmTemplateId : undefined; resourceInputs["alarmType"] = state ? state.alarmType : undefined; resourceInputs["conditions"] = state ? state.conditions : undefined; resourceInputs["enterpriseProjectId"] = state ? state.enterpriseProjectId : undefined; resourceInputs["insufficientdataActions"] = state ? state.insufficientdataActions : undefined; resourceInputs["metric"] = state ? state.metric : undefined; resourceInputs["notificationBeginTime"] = state ? state.notificationBeginTime : undefined; resourceInputs["notificationEndTime"] = state ? state.notificationEndTime : undefined; resourceInputs["okActions"] = state ? state.okActions : undefined; resourceInputs["region"] = state ? state.region : undefined; resourceInputs["resourceGroupId"] = state ? state.resourceGroupId : undefined; resourceInputs["resources"] = state ? state.resources : undefined; resourceInputs["updateTime"] = state ? state.updateTime : undefined; } else { const args = argsOrState; if ((!args || args.alarmName === undefined) && !opts.urn) { throw new Error("Missing required property 'alarmName'"); } if ((!args || args.metric === undefined) && !opts.urn) { throw new Error("Missing required property 'metric'"); } resourceInputs["alarmActionEnabled"] = args ? args.alarmActionEnabled : undefined; resourceInputs["alarmActions"] = args ? args.alarmActions : undefined; resourceInputs["alarmDescription"] = args ? args.alarmDescription : undefined; resourceInputs["alarmEnabled"] = args ? args.alarmEnabled : undefined; resourceInputs["alarmLevel"] = args ? args.alarmLevel : undefined; resourceInputs["alarmName"] = args ? args.alarmName : undefined; resourceInputs["alarmTemplateId"] = args ? args.alarmTemplateId : undefined; resourceInputs["alarmType"] = args ? args.alarmType : undefined; resourceInputs["conditions"] = args ? args.conditions : undefined; resourceInputs["enterpriseProjectId"] = args ? args.enterpriseProjectId : undefined; resourceInputs["insufficientdataActions"] = args ? args.insufficientdataActions : undefined; resourceInputs["metric"] = args ? args.metric : undefined; resourceInputs["notificationBeginTime"] = args ? args.notificationBeginTime : undefined; resourceInputs["notificationEndTime"] = args ? args.notificationEndTime : undefined; resourceInputs["okActions"] = args ? args.okActions : undefined; resourceInputs["region"] = args ? args.region : undefined; resourceInputs["resourceGroupId"] = args ? args.resourceGroupId : undefined; resourceInputs["resources"] = args ? args.resources : undefined; resourceInputs["alarmState"] = undefined /*out*/; resourceInputs["updateTime"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Alarmrule.__pulumiType, name, resourceInputs, opts); } } exports.Alarmrule = Alarmrule; /** @internal */ Alarmrule.__pulumiType = 'huaweicloud:Cse/alarmrule:Alarmrule'; //# sourceMappingURL=alarmrule.js.map