@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
329 lines (328 loc) • 17.5 kB
TypeScript
import * as pulumi from "@pulumi/pulumi";
import * as inputs from "../types/input";
import * as outputs from "../types/output";
/**
* 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}}
* ```
*/
export declare 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: string, id: pulumi.Input<pulumi.ID>, state?: MetricDescriptorState, opts?: pulumi.CustomResourceOptions): 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: any): obj is MetricDescriptor;
/**
* A detailed description of the metric, which can be used in documentation.
*/
readonly description: pulumi.Output<string | undefined>;
/**
* A concise name for the metric, which can be displayed in user interfaces. Use sentence case without an ending period, for example "Request count".
*/
readonly displayName: pulumi.Output<string | undefined>;
/**
* The set of labels that can be used to describe a specific instance of this metric type. In order to delete a label, the entire resource must be deleted, then created with the desired labels.
* Structure is documented below.
*/
readonly labels: pulumi.Output<outputs.monitoring.MetricDescriptorLabel[] | undefined>;
/**
* The launch stage of the metric definition.
* Possible values are: `LAUNCH_STAGE_UNSPECIFIED`, `UNIMPLEMENTED`, `PRELAUNCH`, `EARLY_ACCESS`, `ALPHA`, `BETA`, `GA`, `DEPRECATED`.
*/
readonly launchStage: pulumi.Output<string | undefined>;
/**
* Metadata which can be used to guide usage of the metric.
* Structure is documented below.
*/
readonly metadata: pulumi.Output<outputs.monitoring.MetricDescriptorMetadata | undefined>;
/**
* Whether the metric records instantaneous values, changes to a value, etc. Some combinations of metricKind and valueType might not be supported.
* Possible values are: `METRIC_KIND_UNSPECIFIED`, `GAUGE`, `DELTA`, `CUMULATIVE`.
*/
readonly metricKind: pulumi.Output<string>;
/**
* If present, then a time series, which is identified partially by a metric type and a MonitoredResourceDescriptor, that is associated with this metric type can only be associated with one of the monitored resource types listed here. This field allows time series to be associated with the intersection of this metric type and the monitored resource types in this list.
*/
readonly monitoredResourceTypes: pulumi.Output<string[]>;
/**
* The resource name of the metric descriptor.
*/
readonly name: pulumi.Output<string>;
/**
* The ID of the project in which the resource belongs.
* If it is not provided, the provider project is used.
*/
readonly project: pulumi.Output<string>;
/**
* The metric type, including its DNS name prefix. The type is not URL-encoded. All service defined metrics must be prefixed with the service name, in the format of {service name}/{relative metric name}, such as cloudsql.googleapis.com/database/cpu/utilization. The relative metric name must have only upper and lower-case letters, digits, '/' and underscores '_' are allowed. Additionally, the maximum number of characters allowed for the relativeMetricName is 100. All user-defined metric types have the DNS name custom.googleapis.com, external.googleapis.com, or logging.googleapis.com/user/.
*/
readonly type: pulumi.Output<string>;
/**
* The units in which the metric value is reported. It is only applicable if the
* valueType is INT64, DOUBLE, or DISTRIBUTION. The unit defines the representation of
* the stored metric values.
* Different systems may scale the values to be more easily displayed (so a value of
* 0.02KBy might be displayed as 20By, and a value of 3523KBy might be displayed as
* 3.5MBy). However, if the unit is KBy, then the value of the metric is always in
* thousands of bytes, no matter how it may be displayed.
* If you want a custom metric to record the exact number of CPU-seconds used by a job,
* you can create an INT64 CUMULATIVE metric whose unit is s{CPU} (or equivalently
* 1s{CPU} or just s). If the job uses 12,005 CPU-seconds, then the value is written as
* 12005.
* Alternatively, if you want a custom metric to record data in a more granular way, you
* can create a DOUBLE CUMULATIVE metric whose unit is ks{CPU}, and then write the value
* 12.005 (which is 12005/1000), or use Kis{CPU} and write 11.723 (which is 12005/1024).
* The supported units are a subset of The Unified Code for Units of Measure standard.
* More info can be found in the API documentation
* (https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.metricDescriptors).
*/
readonly unit: pulumi.Output<string | undefined>;
/**
* Whether the measurement is an integer, a floating-point number, etc. Some combinations of metricKind and valueType might not be supported.
* Possible values are: `BOOL`, `INT64`, `DOUBLE`, `STRING`, `DISTRIBUTION`.
*/
readonly valueType: pulumi.Output<string>;
/**
* Create a MetricDescriptor resource with the given unique name, arguments, and options.
*
* @param name The _unique_ name of the resource.
* @param args The arguments to use to populate this resource's properties.
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args: MetricDescriptorArgs, opts?: pulumi.CustomResourceOptions);
}
/**
* Input properties used for looking up and filtering MetricDescriptor resources.
*/
export interface MetricDescriptorState {
/**
* A detailed description of the metric, which can be used in documentation.
*/
description?: pulumi.Input<string>;
/**
* A concise name for the metric, which can be displayed in user interfaces. Use sentence case without an ending period, for example "Request count".
*/
displayName?: pulumi.Input<string>;
/**
* The set of labels that can be used to describe a specific instance of this metric type. In order to delete a label, the entire resource must be deleted, then created with the desired labels.
* Structure is documented below.
*/
labels?: pulumi.Input<pulumi.Input<inputs.monitoring.MetricDescriptorLabel>[]>;
/**
* The launch stage of the metric definition.
* Possible values are: `LAUNCH_STAGE_UNSPECIFIED`, `UNIMPLEMENTED`, `PRELAUNCH`, `EARLY_ACCESS`, `ALPHA`, `BETA`, `GA`, `DEPRECATED`.
*/
launchStage?: pulumi.Input<string>;
/**
* Metadata which can be used to guide usage of the metric.
* Structure is documented below.
*/
metadata?: pulumi.Input<inputs.monitoring.MetricDescriptorMetadata>;
/**
* Whether the metric records instantaneous values, changes to a value, etc. Some combinations of metricKind and valueType might not be supported.
* Possible values are: `METRIC_KIND_UNSPECIFIED`, `GAUGE`, `DELTA`, `CUMULATIVE`.
*/
metricKind?: pulumi.Input<string>;
/**
* If present, then a time series, which is identified partially by a metric type and a MonitoredResourceDescriptor, that is associated with this metric type can only be associated with one of the monitored resource types listed here. This field allows time series to be associated with the intersection of this metric type and the monitored resource types in this list.
*/
monitoredResourceTypes?: pulumi.Input<pulumi.Input<string>[]>;
/**
* The resource name of the metric descriptor.
*/
name?: pulumi.Input<string>;
/**
* The ID of the project in which the resource belongs.
* If it is not provided, the provider project is used.
*/
project?: pulumi.Input<string>;
/**
* The metric type, including its DNS name prefix. The type is not URL-encoded. All service defined metrics must be prefixed with the service name, in the format of {service name}/{relative metric name}, such as cloudsql.googleapis.com/database/cpu/utilization. The relative metric name must have only upper and lower-case letters, digits, '/' and underscores '_' are allowed. Additionally, the maximum number of characters allowed for the relativeMetricName is 100. All user-defined metric types have the DNS name custom.googleapis.com, external.googleapis.com, or logging.googleapis.com/user/.
*/
type?: pulumi.Input<string>;
/**
* The units in which the metric value is reported. It is only applicable if the
* valueType is INT64, DOUBLE, or DISTRIBUTION. The unit defines the representation of
* the stored metric values.
* Different systems may scale the values to be more easily displayed (so a value of
* 0.02KBy might be displayed as 20By, and a value of 3523KBy might be displayed as
* 3.5MBy). However, if the unit is KBy, then the value of the metric is always in
* thousands of bytes, no matter how it may be displayed.
* If you want a custom metric to record the exact number of CPU-seconds used by a job,
* you can create an INT64 CUMULATIVE metric whose unit is s{CPU} (or equivalently
* 1s{CPU} or just s). If the job uses 12,005 CPU-seconds, then the value is written as
* 12005.
* Alternatively, if you want a custom metric to record data in a more granular way, you
* can create a DOUBLE CUMULATIVE metric whose unit is ks{CPU}, and then write the value
* 12.005 (which is 12005/1000), or use Kis{CPU} and write 11.723 (which is 12005/1024).
* The supported units are a subset of The Unified Code for Units of Measure standard.
* More info can be found in the API documentation
* (https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.metricDescriptors).
*/
unit?: pulumi.Input<string>;
/**
* Whether the measurement is an integer, a floating-point number, etc. Some combinations of metricKind and valueType might not be supported.
* Possible values are: `BOOL`, `INT64`, `DOUBLE`, `STRING`, `DISTRIBUTION`.
*/
valueType?: pulumi.Input<string>;
}
/**
* The set of arguments for constructing a MetricDescriptor resource.
*/
export interface MetricDescriptorArgs {
/**
* A detailed description of the metric, which can be used in documentation.
*/
description?: pulumi.Input<string>;
/**
* A concise name for the metric, which can be displayed in user interfaces. Use sentence case without an ending period, for example "Request count".
*/
displayName?: pulumi.Input<string>;
/**
* The set of labels that can be used to describe a specific instance of this metric type. In order to delete a label, the entire resource must be deleted, then created with the desired labels.
* Structure is documented below.
*/
labels?: pulumi.Input<pulumi.Input<inputs.monitoring.MetricDescriptorLabel>[]>;
/**
* The launch stage of the metric definition.
* Possible values are: `LAUNCH_STAGE_UNSPECIFIED`, `UNIMPLEMENTED`, `PRELAUNCH`, `EARLY_ACCESS`, `ALPHA`, `BETA`, `GA`, `DEPRECATED`.
*/
launchStage?: pulumi.Input<string>;
/**
* Metadata which can be used to guide usage of the metric.
* Structure is documented below.
*/
metadata?: pulumi.Input<inputs.monitoring.MetricDescriptorMetadata>;
/**
* Whether the metric records instantaneous values, changes to a value, etc. Some combinations of metricKind and valueType might not be supported.
* Possible values are: `METRIC_KIND_UNSPECIFIED`, `GAUGE`, `DELTA`, `CUMULATIVE`.
*/
metricKind: pulumi.Input<string>;
/**
* The ID of the project in which the resource belongs.
* If it is not provided, the provider project is used.
*/
project?: pulumi.Input<string>;
/**
* The metric type, including its DNS name prefix. The type is not URL-encoded. All service defined metrics must be prefixed with the service name, in the format of {service name}/{relative metric name}, such as cloudsql.googleapis.com/database/cpu/utilization. The relative metric name must have only upper and lower-case letters, digits, '/' and underscores '_' are allowed. Additionally, the maximum number of characters allowed for the relativeMetricName is 100. All user-defined metric types have the DNS name custom.googleapis.com, external.googleapis.com, or logging.googleapis.com/user/.
*/
type: pulumi.Input<string>;
/**
* The units in which the metric value is reported. It is only applicable if the
* valueType is INT64, DOUBLE, or DISTRIBUTION. The unit defines the representation of
* the stored metric values.
* Different systems may scale the values to be more easily displayed (so a value of
* 0.02KBy might be displayed as 20By, and a value of 3523KBy might be displayed as
* 3.5MBy). However, if the unit is KBy, then the value of the metric is always in
* thousands of bytes, no matter how it may be displayed.
* If you want a custom metric to record the exact number of CPU-seconds used by a job,
* you can create an INT64 CUMULATIVE metric whose unit is s{CPU} (or equivalently
* 1s{CPU} or just s). If the job uses 12,005 CPU-seconds, then the value is written as
* 12005.
* Alternatively, if you want a custom metric to record data in a more granular way, you
* can create a DOUBLE CUMULATIVE metric whose unit is ks{CPU}, and then write the value
* 12.005 (which is 12005/1000), or use Kis{CPU} and write 11.723 (which is 12005/1024).
* The supported units are a subset of The Unified Code for Units of Measure standard.
* More info can be found in the API documentation
* (https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.metricDescriptors).
*/
unit?: pulumi.Input<string>;
/**
* Whether the measurement is an integer, a floating-point number, etc. Some combinations of metricKind and valueType might not be supported.
* Possible values are: `BOOL`, `INT64`, `DOUBLE`, `STRING`, `DISTRIBUTION`.
*/
valueType: pulumi.Input<string>;
}