All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.gcp.logging.kotlin.Metric.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

There is a newer version: 8.12.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.gcp.logging.kotlin

import com.pulumi.core.Output
import com.pulumi.gcp.logging.kotlin.outputs.MetricBucketOptions
import com.pulumi.gcp.logging.kotlin.outputs.MetricMetricDescriptor
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.Map
import com.pulumi.gcp.logging.kotlin.outputs.MetricBucketOptions.Companion.toKotlin as metricBucketOptionsToKotlin
import com.pulumi.gcp.logging.kotlin.outputs.MetricMetricDescriptor.Companion.toKotlin as metricMetricDescriptorToKotlin

/**
 * Builder for [Metric].
 */
@PulumiTagMarker
public class MetricResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: MetricArgs = MetricArgs()

    public var opts: CustomResourceOptions = CustomResourceOptions()

    /**
     * @param name The _unique_ name of the resulting resource.
     */
    public fun name(`value`: String) {
        this.name = value
    }

    /**
     * @param block The arguments to use to populate this resource's properties.
     */
    public suspend fun args(block: suspend MetricArgsBuilder.() -> Unit) {
        val builder = MetricArgsBuilder()
        block(builder)
        this.args = builder.build()
    }

    /**
     * @param block A bag of options that control this resource's behavior.
     */
    public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
        this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
    }

    internal fun build(): Metric {
        val builtJavaResource = com.pulumi.gcp.logging.Metric(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return Metric(builtJavaResource)
    }
}

/**
 * Logs-based metric can also be used to extract values from logs and create a a distribution
 * of the values. The distribution records the statistics of the extracted values along with
 * an optional histogram of the values as specified by the bucket options.
 * To get more information about Metric, see:
 * * [API documentation](https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/create)
 * * How-to Guides
 *     * [Official Documentation](https://cloud.google.com/logging/docs/apis)
 * ## Example Usage
 * ### Logging Metric Basic
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const loggingMetric = new gcp.logging.Metric("logging_metric", {
 *     name: "my-(custom)/metric",
 *     filter: "resource.type=gae_app AND severity>=ERROR",
 *     metricDescriptor: {
 *         metricKind: "DELTA",
 *         valueType: "DISTRIBUTION",
 *         unit: "1",
 *         labels: [
 *             {
 *                 key: "mass",
 *                 valueType: "STRING",
 *                 description: "amount of matter",
 *             },
 *             {
 *                 key: "sku",
 *                 valueType: "INT64",
 *                 description: "Identifying number for item",
 *             },
 *         ],
 *         displayName: "My metric",
 *     },
 *     valueExtractor: "EXTRACT(jsonPayload.request)",
 *     labelExtractors: {
 *         mass: "EXTRACT(jsonPayload.request)",
 *         sku: "EXTRACT(jsonPayload.id)",
 *     },
 *     bucketOptions: {
 *         linearBuckets: {
 *             numFiniteBuckets: 3,
 *             width: 1,
 *             offset: 1,
 *         },
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * logging_metric = gcp.logging.Metric("logging_metric",
 *     name="my-(custom)/metric",
 *     filter="resource.type=gae_app AND severity>=ERROR",
 *     metric_descriptor=gcp.logging.MetricMetricDescriptorArgs(
 *         metric_kind="DELTA",
 *         value_type="DISTRIBUTION",
 *         unit="1",
 *         labels=[
 *             gcp.logging.MetricMetricDescriptorLabelArgs(
 *                 key="mass",
 *                 value_type="STRING",
 *                 description="amount of matter",
 *             ),
 *             gcp.logging.MetricMetricDescriptorLabelArgs(
 *                 key="sku",
 *                 value_type="INT64",
 *                 description="Identifying number for item",
 *             ),
 *         ],
 *         display_name="My metric",
 *     ),
 *     value_extractor="EXTRACT(jsonPayload.request)",
 *     label_extractors={
 *         "mass": "EXTRACT(jsonPayload.request)",
 *         "sku": "EXTRACT(jsonPayload.id)",
 *     },
 *     bucket_options=gcp.logging.MetricBucketOptionsArgs(
 *         linear_buckets=gcp.logging.MetricBucketOptionsLinearBucketsArgs(
 *             num_finite_buckets=3,
 *             width=1,
 *             offset=1,
 *         ),
 *     ))
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var loggingMetric = new Gcp.Logging.Metric("logging_metric", new()
 *     {
 *         Name = "my-(custom)/metric",
 *         Filter = "resource.type=gae_app AND severity>=ERROR",
 *         MetricDescriptor = new Gcp.Logging.Inputs.MetricMetricDescriptorArgs
 *         {
 *             MetricKind = "DELTA",
 *             ValueType = "DISTRIBUTION",
 *             Unit = "1",
 *             Labels = new[]
 *             {
 *                 new Gcp.Logging.Inputs.MetricMetricDescriptorLabelArgs
 *                 {
 *                     Key = "mass",
 *                     ValueType = "STRING",
 *                     Description = "amount of matter",
 *                 },
 *                 new Gcp.Logging.Inputs.MetricMetricDescriptorLabelArgs
 *                 {
 *                     Key = "sku",
 *                     ValueType = "INT64",
 *                     Description = "Identifying number for item",
 *                 },
 *             },
 *             DisplayName = "My metric",
 *         },
 *         ValueExtractor = "EXTRACT(jsonPayload.request)",
 *         LabelExtractors =
 *         {
 *             { "mass", "EXTRACT(jsonPayload.request)" },
 *             { "sku", "EXTRACT(jsonPayload.id)" },
 *         },
 *         BucketOptions = new Gcp.Logging.Inputs.MetricBucketOptionsArgs
 *         {
 *             LinearBuckets = new Gcp.Logging.Inputs.MetricBucketOptionsLinearBucketsArgs
 *             {
 *                 NumFiniteBuckets = 3,
 *                 Width = 1,
 *                 Offset = 1,
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/logging"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := logging.NewMetric(ctx, "logging_metric", &logging.MetricArgs{
 * 			Name:   pulumi.String("my-(custom)/metric"),
 * 			Filter: pulumi.String("resource.type=gae_app AND severity>=ERROR"),
 * 			MetricDescriptor: &logging.MetricMetricDescriptorArgs{
 * 				MetricKind: pulumi.String("DELTA"),
 * 				ValueType:  pulumi.String("DISTRIBUTION"),
 * 				Unit:       pulumi.String("1"),
 * 				Labels: logging.MetricMetricDescriptorLabelArray{
 * 					&logging.MetricMetricDescriptorLabelArgs{
 * 						Key:         pulumi.String("mass"),
 * 						ValueType:   pulumi.String("STRING"),
 * 						Description: pulumi.String("amount of matter"),
 * 					},
 * 					&logging.MetricMetricDescriptorLabelArgs{
 * 						Key:         pulumi.String("sku"),
 * 						ValueType:   pulumi.String("INT64"),
 * 						Description: pulumi.String("Identifying number for item"),
 * 					},
 * 				},
 * 				DisplayName: pulumi.String("My metric"),
 * 			},
 * 			ValueExtractor: pulumi.String("EXTRACT(jsonPayload.request)"),
 * 			LabelExtractors: pulumi.StringMap{
 * 				"mass": pulumi.String("EXTRACT(jsonPayload.request)"),
 * 				"sku":  pulumi.String("EXTRACT(jsonPayload.id)"),
 * 			},
 * 			BucketOptions: &logging.MetricBucketOptionsArgs{
 * 				LinearBuckets: &logging.MetricBucketOptionsLinearBucketsArgs{
 * 					NumFiniteBuckets: pulumi.Int(3),
 * 					Width:            pulumi.Float64(1),
 * 					Offset:           pulumi.Float64(1),
 * 				},
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		return nil
 * 	})
 * }
 * ```
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.logging.Metric;
 * import com.pulumi.gcp.logging.MetricArgs;
 * import com.pulumi.gcp.logging.inputs.MetricMetricDescriptorArgs;
 * import com.pulumi.gcp.logging.inputs.MetricBucketOptionsArgs;
 * import com.pulumi.gcp.logging.inputs.MetricBucketOptionsLinearBucketsArgs;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 *     public static void stack(Context ctx) {
 *         var loggingMetric = new Metric("loggingMetric", MetricArgs.builder()
 *             .name("my-(custom)/metric")
 *             .filter("resource.type=gae_app AND severity>=ERROR")
 *             .metricDescriptor(MetricMetricDescriptorArgs.builder()
 *                 .metricKind("DELTA")
 *                 .valueType("DISTRIBUTION")
 *                 .unit("1")
 *                 .labels(
 *                     MetricMetricDescriptorLabelArgs.builder()
 *                         .key("mass")
 *                         .valueType("STRING")
 *                         .description("amount of matter")
 *                         .build(),
 *                     MetricMetricDescriptorLabelArgs.builder()
 *                         .key("sku")
 *                         .valueType("INT64")
 *                         .description("Identifying number for item")
 *                         .build())
 *                 .displayName("My metric")
 *                 .build())
 *             .valueExtractor("EXTRACT(jsonPayload.request)")
 *             .labelExtractors(Map.ofEntries(
 *                 Map.entry("mass", "EXTRACT(jsonPayload.request)"),
 *                 Map.entry("sku", "EXTRACT(jsonPayload.id)")
 *             ))
 *             .bucketOptions(MetricBucketOptionsArgs.builder()
 *                 .linearBuckets(MetricBucketOptionsLinearBucketsArgs.builder()
 *                     .numFiniteBuckets(3)
 *                     .width(1)
 *                     .offset(1)
 *                     .build())
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   loggingMetric:
 *     type: gcp:logging:Metric
 *     name: logging_metric
 *     properties:
 *       name: my-(custom)/metric
 *       filter: resource.type=gae_app AND severity>=ERROR
 *       metricDescriptor:
 *         metricKind: DELTA
 *         valueType: DISTRIBUTION
 *         unit: '1'
 *         labels:
 *           - key: mass
 *             valueType: STRING
 *             description: amount of matter
 *           - key: sku
 *             valueType: INT64
 *             description: Identifying number for item
 *         displayName: My metric
 *       valueExtractor: EXTRACT(jsonPayload.request)
 *       labelExtractors:
 *         mass: EXTRACT(jsonPayload.request)
 *         sku: EXTRACT(jsonPayload.id)
 *       bucketOptions:
 *         linearBuckets:
 *           numFiniteBuckets: 3
 *           width: 1
 *           offset: 1
 * ```
 * 
 * ### Logging Metric Counter Basic
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const loggingMetric = new gcp.logging.Metric("logging_metric", {
 *     name: "my-(custom)/metric",
 *     filter: "resource.type=gae_app AND severity>=ERROR",
 *     metricDescriptor: {
 *         metricKind: "DELTA",
 *         valueType: "INT64",
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * logging_metric = gcp.logging.Metric("logging_metric",
 *     name="my-(custom)/metric",
 *     filter="resource.type=gae_app AND severity>=ERROR",
 *     metric_descriptor=gcp.logging.MetricMetricDescriptorArgs(
 *         metric_kind="DELTA",
 *         value_type="INT64",
 *     ))
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var loggingMetric = new Gcp.Logging.Metric("logging_metric", new()
 *     {
 *         Name = "my-(custom)/metric",
 *         Filter = "resource.type=gae_app AND severity>=ERROR",
 *         MetricDescriptor = new Gcp.Logging.Inputs.MetricMetricDescriptorArgs
 *         {
 *             MetricKind = "DELTA",
 *             ValueType = "INT64",
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/logging"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := logging.NewMetric(ctx, "logging_metric", &logging.MetricArgs{
 * 			Name:   pulumi.String("my-(custom)/metric"),
 * 			Filter: pulumi.String("resource.type=gae_app AND severity>=ERROR"),
 * 			MetricDescriptor: &logging.MetricMetricDescriptorArgs{
 * 				MetricKind: pulumi.String("DELTA"),
 * 				ValueType:  pulumi.String("INT64"),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		return nil
 * 	})
 * }
 * ```
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.logging.Metric;
 * import com.pulumi.gcp.logging.MetricArgs;
 * import com.pulumi.gcp.logging.inputs.MetricMetricDescriptorArgs;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 *     public static void stack(Context ctx) {
 *         var loggingMetric = new Metric("loggingMetric", MetricArgs.builder()
 *             .name("my-(custom)/metric")
 *             .filter("resource.type=gae_app AND severity>=ERROR")
 *             .metricDescriptor(MetricMetricDescriptorArgs.builder()
 *                 .metricKind("DELTA")
 *                 .valueType("INT64")
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   loggingMetric:
 *     type: gcp:logging:Metric
 *     name: logging_metric
 *     properties:
 *       name: my-(custom)/metric
 *       filter: resource.type=gae_app AND severity>=ERROR
 *       metricDescriptor:
 *         metricKind: DELTA
 *         valueType: INT64
 * ```
 * 
 * ### Logging Metric Counter Labels
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const loggingMetric = new gcp.logging.Metric("logging_metric", {
 *     name: "my-(custom)/metric",
 *     filter: "resource.type=gae_app AND severity>=ERROR",
 *     metricDescriptor: {
 *         metricKind: "DELTA",
 *         valueType: "INT64",
 *         labels: [{
 *             key: "mass",
 *             valueType: "STRING",
 *             description: "amount of matter",
 *         }],
 *     },
 *     labelExtractors: {
 *         mass: "EXTRACT(jsonPayload.request)",
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * logging_metric = gcp.logging.Metric("logging_metric",
 *     name="my-(custom)/metric",
 *     filter="resource.type=gae_app AND severity>=ERROR",
 *     metric_descriptor=gcp.logging.MetricMetricDescriptorArgs(
 *         metric_kind="DELTA",
 *         value_type="INT64",
 *         labels=[gcp.logging.MetricMetricDescriptorLabelArgs(
 *             key="mass",
 *             value_type="STRING",
 *             description="amount of matter",
 *         )],
 *     ),
 *     label_extractors={
 *         "mass": "EXTRACT(jsonPayload.request)",
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var loggingMetric = new Gcp.Logging.Metric("logging_metric", new()
 *     {
 *         Name = "my-(custom)/metric",
 *         Filter = "resource.type=gae_app AND severity>=ERROR",
 *         MetricDescriptor = new Gcp.Logging.Inputs.MetricMetricDescriptorArgs
 *         {
 *             MetricKind = "DELTA",
 *             ValueType = "INT64",
 *             Labels = new[]
 *             {
 *                 new Gcp.Logging.Inputs.MetricMetricDescriptorLabelArgs
 *                 {
 *                     Key = "mass",
 *                     ValueType = "STRING",
 *                     Description = "amount of matter",
 *                 },
 *             },
 *         },
 *         LabelExtractors =
 *         {
 *             { "mass", "EXTRACT(jsonPayload.request)" },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/logging"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := logging.NewMetric(ctx, "logging_metric", &logging.MetricArgs{
 * 			Name:   pulumi.String("my-(custom)/metric"),
 * 			Filter: pulumi.String("resource.type=gae_app AND severity>=ERROR"),
 * 			MetricDescriptor: &logging.MetricMetricDescriptorArgs{
 * 				MetricKind: pulumi.String("DELTA"),
 * 				ValueType:  pulumi.String("INT64"),
 * 				Labels: logging.MetricMetricDescriptorLabelArray{
 * 					&logging.MetricMetricDescriptorLabelArgs{
 * 						Key:         pulumi.String("mass"),
 * 						ValueType:   pulumi.String("STRING"),
 * 						Description: pulumi.String("amount of matter"),
 * 					},
 * 				},
 * 			},
 * 			LabelExtractors: pulumi.StringMap{
 * 				"mass": pulumi.String("EXTRACT(jsonPayload.request)"),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		return nil
 * 	})
 * }
 * ```
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.logging.Metric;
 * import com.pulumi.gcp.logging.MetricArgs;
 * import com.pulumi.gcp.logging.inputs.MetricMetricDescriptorArgs;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 *     public static void stack(Context ctx) {
 *         var loggingMetric = new Metric("loggingMetric", MetricArgs.builder()
 *             .name("my-(custom)/metric")
 *             .filter("resource.type=gae_app AND severity>=ERROR")
 *             .metricDescriptor(MetricMetricDescriptorArgs.builder()
 *                 .metricKind("DELTA")
 *                 .valueType("INT64")
 *                 .labels(MetricMetricDescriptorLabelArgs.builder()
 *                     .key("mass")
 *                     .valueType("STRING")
 *                     .description("amount of matter")
 *                     .build())
 *                 .build())
 *             .labelExtractors(Map.of("mass", "EXTRACT(jsonPayload.request)"))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   loggingMetric:
 *     type: gcp:logging:Metric
 *     name: logging_metric
 *     properties:
 *       name: my-(custom)/metric
 *       filter: resource.type=gae_app AND severity>=ERROR
 *       metricDescriptor:
 *         metricKind: DELTA
 *         valueType: INT64
 *         labels:
 *           - key: mass
 *             valueType: STRING
 *             description: amount of matter
 *       labelExtractors:
 *         mass: EXTRACT(jsonPayload.request)
 * ```
 * 
 * ### Logging Metric Logging Bucket
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const loggingMetric = new gcp.logging.ProjectBucketConfig("logging_metric", {
 *     location: "global",
 *     project: "my-project-name",
 *     bucketId: "_Default",
 * });
 * const loggingMetricMetric = new gcp.logging.Metric("logging_metric", {
 *     name: "my-(custom)/metric",
 *     filter: "resource.type=gae_app AND severity>=ERROR",
 *     bucketName: loggingMetric.id,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * logging_metric = gcp.logging.ProjectBucketConfig("logging_metric",
 *     location="global",
 *     project="my-project-name",
 *     bucket_id="_Default")
 * logging_metric_metric = gcp.logging.Metric("logging_metric",
 *     name="my-(custom)/metric",
 *     filter="resource.type=gae_app AND severity>=ERROR",
 *     bucket_name=logging_metric.id)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var loggingMetric = new Gcp.Logging.ProjectBucketConfig("logging_metric", new()
 *     {
 *         Location = "global",
 *         Project = "my-project-name",
 *         BucketId = "_Default",
 *     });
 *     var loggingMetricMetric = new Gcp.Logging.Metric("logging_metric", new()
 *     {
 *         Name = "my-(custom)/metric",
 *         Filter = "resource.type=gae_app AND severity>=ERROR",
 *         BucketName = loggingMetric.Id,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/logging"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		loggingMetric, err := logging.NewProjectBucketConfig(ctx, "logging_metric", &logging.ProjectBucketConfigArgs{
 * 			Location: pulumi.String("global"),
 * 			Project:  pulumi.String("my-project-name"),
 * 			BucketId: pulumi.String("_Default"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = logging.NewMetric(ctx, "logging_metric", &logging.MetricArgs{
 * 			Name:       pulumi.String("my-(custom)/metric"),
 * 			Filter:     pulumi.String("resource.type=gae_app AND severity>=ERROR"),
 * 			BucketName: loggingMetric.ID(),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		return nil
 * 	})
 * }
 * ```
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.logging.ProjectBucketConfig;
 * import com.pulumi.gcp.logging.ProjectBucketConfigArgs;
 * import com.pulumi.gcp.logging.Metric;
 * import com.pulumi.gcp.logging.MetricArgs;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 *     public static void stack(Context ctx) {
 *         var loggingMetric = new ProjectBucketConfig("loggingMetric", ProjectBucketConfigArgs.builder()
 *             .location("global")
 *             .project("my-project-name")
 *             .bucketId("_Default")
 *             .build());
 *         var loggingMetricMetric = new Metric("loggingMetricMetric", MetricArgs.builder()
 *             .name("my-(custom)/metric")
 *             .filter("resource.type=gae_app AND severity>=ERROR")
 *             .bucketName(loggingMetric.id())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   loggingMetric:
 *     type: gcp:logging:ProjectBucketConfig
 *     name: logging_metric
 *     properties:
 *       location: global
 *       project: my-project-name
 *       bucketId: _Default
 *   loggingMetricMetric:
 *     type: gcp:logging:Metric
 *     name: logging_metric
 *     properties:
 *       name: my-(custom)/metric
 *       filter: resource.type=gae_app AND severity>=ERROR
 *       bucketName: ${loggingMetric.id}
 * ```
 * 
 * ### Logging Metric Disabled
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const loggingMetric = new gcp.logging.Metric("logging_metric", {
 *     name: "my-(custom)/metric",
 *     filter: "resource.type=gae_app AND severity>=ERROR",
 *     metricDescriptor: {
 *         metricKind: "DELTA",
 *         valueType: "INT64",
 *     },
 *     disabled: true,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * logging_metric = gcp.logging.Metric("logging_metric",
 *     name="my-(custom)/metric",
 *     filter="resource.type=gae_app AND severity>=ERROR",
 *     metric_descriptor=gcp.logging.MetricMetricDescriptorArgs(
 *         metric_kind="DELTA",
 *         value_type="INT64",
 *     ),
 *     disabled=True)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var loggingMetric = new Gcp.Logging.Metric("logging_metric", new()
 *     {
 *         Name = "my-(custom)/metric",
 *         Filter = "resource.type=gae_app AND severity>=ERROR",
 *         MetricDescriptor = new Gcp.Logging.Inputs.MetricMetricDescriptorArgs
 *         {
 *             MetricKind = "DELTA",
 *             ValueType = "INT64",
 *         },
 *         Disabled = true,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/logging"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := logging.NewMetric(ctx, "logging_metric", &logging.MetricArgs{
 * 			Name:   pulumi.String("my-(custom)/metric"),
 * 			Filter: pulumi.String("resource.type=gae_app AND severity>=ERROR"),
 * 			MetricDescriptor: &logging.MetricMetricDescriptorArgs{
 * 				MetricKind: pulumi.String("DELTA"),
 * 				ValueType:  pulumi.String("INT64"),
 * 			},
 * 			Disabled: pulumi.Bool(true),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		return nil
 * 	})
 * }
 * ```
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.logging.Metric;
 * import com.pulumi.gcp.logging.MetricArgs;
 * import com.pulumi.gcp.logging.inputs.MetricMetricDescriptorArgs;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 *     public static void stack(Context ctx) {
 *         var loggingMetric = new Metric("loggingMetric", MetricArgs.builder()
 *             .name("my-(custom)/metric")
 *             .filter("resource.type=gae_app AND severity>=ERROR")
 *             .metricDescriptor(MetricMetricDescriptorArgs.builder()
 *                 .metricKind("DELTA")
 *                 .valueType("INT64")
 *                 .build())
 *             .disabled(true)
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   loggingMetric:
 *     type: gcp:logging:Metric
 *     name: logging_metric
 *     properties:
 *       name: my-(custom)/metric
 *       filter: resource.type=gae_app AND severity>=ERROR
 *       metricDescriptor:
 *         metricKind: DELTA
 *         valueType: INT64
 *       disabled: true
 * ```
 * 
 * ## Import
 * Metric can be imported using any of these accepted formats:
 * * `{{project}} {{name}}`
 * * `{{name}}`
 * When using the `pulumi import` command, Metric can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:logging/metric:Metric default {{project}} {{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:logging/metric:Metric default {{name}}
 * ```
 */
public class Metric internal constructor(
    override val javaResource: com.pulumi.gcp.logging.Metric,
) : KotlinCustomResource(javaResource, MetricMapper) {
    /**
     * The resource name of the Log Bucket that owns the Log Metric. Only Log Buckets in projects
     * are supported. The bucket has to be in the same project as the metric.
     */
    public val bucketName: Output?
        get() = javaResource.bucketName().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The bucketOptions are required when the logs-based metric is using a DISTRIBUTION value type and it
     * describes the bucket boundaries used to create a histogram of the extracted values.
     * Structure is documented below.
     */
    public val bucketOptions: Output?
        get() = javaResource.bucketOptions().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> metricBucketOptionsToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * A description of this metric, which is used in documentation. The maximum length of the
     * description is 8000 characters.
     */
    public val description: Output?
        get() = javaResource.description().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * If set to True, then this metric is disabled and it does not generate any points.
     */
    public val disabled: Output?
        get() = javaResource.disabled().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * An advanced logs filter (https://cloud.google.com/logging/docs/view/advanced-filters) which
     * is used to match log entries.
     * - - -
     */
    public val filter: Output
        get() = javaResource.filter().applyValue({ args0 -> args0 })

    /**
     * A map from a label key string to an extractor expression which is used to extract data from a log
     * entry field and assign as the label value. Each label key specified in the LabelDescriptor must
     * have an associated extractor expression in this map. The syntax of the extractor expression is
     * the same as for the valueExtractor field.
     */
    public val labelExtractors: Output>?
        get() = javaResource.labelExtractors().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 -> args0.key.to(args0.value) }).toMap()
            }).orElse(null)
        })

    /**
     * The optional metric descriptor associated with the logs-based metric.
     * If unspecified, it uses a default metric descriptor with a DELTA metric kind,
     * INT64 value type, with no labels and a unit of "1". Such a metric counts the
     * number of log entries matching the filter expression.
     * Structure is documented below.
     */
    public val metricDescriptor: Output
        get() = javaResource.metricDescriptor().applyValue({ args0 ->
            args0.let({ args0 ->
                metricMetricDescriptorToKotlin(args0)
            })
        })

    /**
     * The client-assigned metric identifier. Examples - "error_count", "nginx/requests".
     * Metric identifiers are limited to 100 characters and can include only the following
     * characters A-Z, a-z, 0-9, and the special characters _-.,+!*',()%/. The forward-slash
     * character (/) denotes a hierarchy of name pieces, and it cannot be the first character
     * of the name.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The ID of the project in which the resource belongs.
     * If it is not provided, the provider project is used.
     */
    public val project: Output
        get() = javaResource.project().applyValue({ args0 -> args0 })

    /**
     * A valueExtractor is required when using a distribution logs-based metric to extract the values to
     * record from a log entry. Two functions are supported for value extraction - EXTRACT(field) or
     * REGEXP_EXTRACT(field, regex). The argument are 1. field - The name of the log entry field from which
     * the value is to be extracted. 2. regex - A regular expression using the Google RE2 syntax
     * (https://github.com/google/re2/wiki/Syntax) with a single capture group to extract data from the specified
     * log entry field. The value of the field is converted to a string before applying the regex. It is an
     * error to specify a regex that does not include exactly one capture group.
     */
    public val valueExtractor: Output?
        get() = javaResource.valueExtractor().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })
}

public object MetricMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.logging.Metric::class == javaResource::class

    override fun map(javaResource: Resource): Metric = Metric(
        javaResource as
            com.pulumi.gcp.logging.Metric,
    )
}

/**
 * @see [Metric].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [Metric].
 */
public suspend fun metric(name: String, block: suspend MetricResourceBuilder.() -> Unit): Metric {
    val builder = MetricResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [Metric].
 * @param name The _unique_ name of the resulting resource.
 */
public fun metric(name: String): Metric {
    val builder = MetricResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy