@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
185 lines • 7.74 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MetricDescriptor = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(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}}
* $ terraform import google_monitoring_metric_descriptor.default "{{project}} {{name}}"
* $ 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, { ...opts, id: id });
}
/** @internal */
static __pulumiType = 'gcp:monitoring/metricDescriptor:MetricDescriptor';
/**
* 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["deletionPolicy"] = state?.deletionPolicy;
resourceInputs["description"] = state?.description;
resourceInputs["displayName"] = state?.displayName;
resourceInputs["labels"] = state?.labels;
resourceInputs["launchStage"] = state?.launchStage;
resourceInputs["metadata"] = state?.metadata;
resourceInputs["metricKind"] = state?.metricKind;
resourceInputs["monitoredResourceTypes"] = state?.monitoredResourceTypes;
resourceInputs["name"] = state?.name;
resourceInputs["project"] = state?.project;
resourceInputs["type"] = state?.type;
resourceInputs["unit"] = state?.unit;
resourceInputs["valueType"] = state?.valueType;
}
else {
const args = argsOrState;
if (args?.metricKind === undefined && !opts.urn) {
throw new Error("Missing required property 'metricKind'");
}
if (args?.type === undefined && !opts.urn) {
throw new Error("Missing required property 'type'");
}
if (args?.valueType === undefined && !opts.urn) {
throw new Error("Missing required property 'valueType'");
}
resourceInputs["deletionPolicy"] = args?.deletionPolicy;
resourceInputs["description"] = args?.description;
resourceInputs["displayName"] = args?.displayName;
resourceInputs["labels"] = args?.labels;
resourceInputs["launchStage"] = args?.launchStage;
resourceInputs["metadata"] = args?.metadata;
resourceInputs["metricKind"] = args?.metricKind;
resourceInputs["project"] = args?.project;
resourceInputs["type"] = args?.type;
resourceInputs["unit"] = args?.unit;
resourceInputs["valueType"] = args?.valueType;
resourceInputs["monitoredResourceTypes"] = undefined /*out*/;
resourceInputs["name"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(MetricDescriptor.__pulumiType, name, resourceInputs, opts);
}
}
exports.MetricDescriptor = MetricDescriptor;
//# sourceMappingURL=metricDescriptor.js.map