UNPKG

@pulumi/gcp

Version:

A Pulumi package for creating and managing Google Cloud Platform resources.

174 lines 7.41 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.MetricDescriptor = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Defines a metric type and its schema. Once a metric descriptor is created, deleting or altering it stops data collection and makes the metric type's existing data unusable. * * To get more information about MetricDescriptor, see: * * * [API documentation](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.metricDescriptors) * * How-to Guides * * [Official Documentation](https://cloud.google.com/monitoring/custom-metrics/) * * ## Example Usage * * ### Monitoring Metric Descriptor Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const basic = new gcp.monitoring.MetricDescriptor("basic", { * description: "Daily sales records from all branch stores.", * displayName: "metric-descriptor", * type: "custom.googleapis.com/stores/daily_sales", * metricKind: "GAUGE", * valueType: "DOUBLE", * unit: "{USD}", * labels: [{ * key: "store_id", * valueType: "STRING", * description: "The ID of the store.", * }], * launchStage: "BETA", * metadata: { * samplePeriod: "60s", * ingestDelay: "30s", * }, * }); * ``` * ### Monitoring Metric Descriptor Alert * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const withAlert = new gcp.monitoring.MetricDescriptor("with_alert", { * description: "Daily sales records from all branch stores.", * displayName: "metric-descriptor", * type: "custom.googleapis.com/stores/daily_sales", * metricKind: "GAUGE", * valueType: "DOUBLE", * unit: "{USD}", * }); * const alertPolicy = new gcp.monitoring.AlertPolicy("alert_policy", { * displayName: "metric-descriptor", * combiner: "OR", * conditions: [{ * displayName: "test condition", * conditionThreshold: { * filter: pulumi.interpolate`metric.type="${withAlert.type}" AND resource.type="gce_instance"`, * duration: "60s", * comparison: "COMPARISON_GT", * }, * }], * }); * ``` * * ## Import * * MetricDescriptor can be imported using any of these accepted formats: * * * `{{project}}/{{name}}` * * * `{{project}} {{name}}` * * * `{{name}}` * * When using the `pulumi import` command, MetricDescriptor can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:monitoring/metricDescriptor:MetricDescriptor default {{project}}/{{name}} * ``` * * ```sh * $ pulumi import gcp:monitoring/metricDescriptor:MetricDescriptor default "{{project}} {{name}}" * ``` * * ```sh * $ pulumi import gcp:monitoring/metricDescriptor:MetricDescriptor default {{name}} * ``` */ class MetricDescriptor extends pulumi.CustomResource { /** * Get an existing MetricDescriptor 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 MetricDescriptor(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of MetricDescriptor. 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'] === MetricDescriptor.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["description"] = state ? state.description : undefined; resourceInputs["displayName"] = state ? state.displayName : undefined; resourceInputs["labels"] = state ? state.labels : undefined; resourceInputs["launchStage"] = state ? state.launchStage : undefined; resourceInputs["metadata"] = state ? state.metadata : undefined; resourceInputs["metricKind"] = state ? state.metricKind : undefined; resourceInputs["monitoredResourceTypes"] = state ? state.monitoredResourceTypes : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["project"] = state ? state.project : undefined; resourceInputs["type"] = state ? state.type : undefined; resourceInputs["unit"] = state ? state.unit : undefined; resourceInputs["valueType"] = state ? state.valueType : undefined; } else { const args = argsOrState; if ((!args || args.description === undefined) && !opts.urn) { throw new Error("Missing required property 'description'"); } if ((!args || args.displayName === undefined) && !opts.urn) { throw new Error("Missing required property 'displayName'"); } if ((!args || args.metricKind === undefined) && !opts.urn) { throw new Error("Missing required property 'metricKind'"); } if ((!args || args.type === undefined) && !opts.urn) { throw new Error("Missing required property 'type'"); } if ((!args || args.valueType === undefined) && !opts.urn) { throw new Error("Missing required property 'valueType'"); } resourceInputs["description"] = args ? args.description : undefined; resourceInputs["displayName"] = args ? args.displayName : undefined; resourceInputs["labels"] = args ? args.labels : undefined; resourceInputs["launchStage"] = args ? args.launchStage : undefined; resourceInputs["metadata"] = args ? args.metadata : undefined; resourceInputs["metricKind"] = args ? args.metricKind : undefined; resourceInputs["project"] = args ? args.project : undefined; resourceInputs["type"] = args ? args.type : undefined; resourceInputs["unit"] = args ? args.unit : undefined; resourceInputs["valueType"] = args ? args.valueType : undefined; resourceInputs["monitoredResourceTypes"] = undefined /*out*/; resourceInputs["name"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(MetricDescriptor.__pulumiType, name, resourceInputs, opts); } } exports.MetricDescriptor = MetricDescriptor; /** @internal */ MetricDescriptor.__pulumiType = 'gcp:monitoring/metricDescriptor:MetricDescriptor'; //# sourceMappingURL=metricDescriptor.js.map