Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.pulumi.gcp.logging.kotlin.MetricArgs.kt Maven / Gradle / Ivy
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.gcp.logging.kotlin
import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.gcp.logging.MetricArgs.builder
import com.pulumi.gcp.logging.kotlin.inputs.MetricBucketOptionsArgs
import com.pulumi.gcp.logging.kotlin.inputs.MetricBucketOptionsArgsBuilder
import com.pulumi.gcp.logging.kotlin.inputs.MetricMetricDescriptorArgs
import com.pulumi.gcp.logging.kotlin.inputs.MetricMetricDescriptorArgsBuilder
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.applySuspend
import kotlin.Boolean
import kotlin.Pair
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.Map
import kotlin.jvm.JvmName
/**
* 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={
* "metric_kind": "DELTA",
* "value_type": "DISTRIBUTION",
* "unit": "1",
* "labels": [
* {
* "key": "mass",
* "value_type": "STRING",
* "description": "amount of matter",
* },
* {
* "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={
* "linear_buckets": {
* "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={
* "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={
* "metric_kind": "DELTA",
* "value_type": "INT64",
* "labels": [{
* "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={
* "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}}
* ```
* @property bucketName 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.
* @property bucketOptions 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.
* @property description A description of this metric, which is used in documentation. The maximum length of the
* description is 8000 characters.
* @property disabled If set to True, then this metric is disabled and it does not generate any points.
* @property filter An advanced logs filter (https://cloud.google.com/logging/docs/view/advanced-filters) which
* is used to match log entries.
* - - -
* @property labelExtractors 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.
* @property metricDescriptor 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.
* @property name 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.
* @property project The ID of the project in which the resource belongs.
* If it is not provided, the provider project is used.
* @property valueExtractor 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 data class MetricArgs(
public val bucketName: Output? = null,
public val bucketOptions: Output? = null,
public val description: Output? = null,
public val disabled: Output? = null,
public val filter: Output? = null,
public val labelExtractors: Output>? = null,
public val metricDescriptor: Output? = null,
public val name: Output? = null,
public val project: Output? = null,
public val valueExtractor: Output? = null,
) : ConvertibleToJava {
override fun toJava(): com.pulumi.gcp.logging.MetricArgs =
com.pulumi.gcp.logging.MetricArgs.builder()
.bucketName(bucketName?.applyValue({ args0 -> args0 }))
.bucketOptions(bucketOptions?.applyValue({ args0 -> args0.let({ args0 -> args0.toJava() }) }))
.description(description?.applyValue({ args0 -> args0 }))
.disabled(disabled?.applyValue({ args0 -> args0 }))
.filter(filter?.applyValue({ args0 -> args0 }))
.labelExtractors(
labelExtractors?.applyValue({ args0 ->
args0.map({ args0 ->
args0.key.to(args0.value)
}).toMap()
}),
)
.metricDescriptor(metricDescriptor?.applyValue({ args0 -> args0.let({ args0 -> args0.toJava() }) }))
.name(name?.applyValue({ args0 -> args0 }))
.project(project?.applyValue({ args0 -> args0 }))
.valueExtractor(valueExtractor?.applyValue({ args0 -> args0 })).build()
}
/**
* Builder for [MetricArgs].
*/
@PulumiTagMarker
public class MetricArgsBuilder internal constructor() {
private var bucketName: Output? = null
private var bucketOptions: Output? = null
private var description: Output? = null
private var disabled: Output? = null
private var filter: Output? = null
private var labelExtractors: Output>? = null
private var metricDescriptor: Output? = null
private var name: Output? = null
private var project: Output? = null
private var valueExtractor: Output? = null
/**
* @param value 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.
*/
@JvmName("whssupsktavtmwhk")
public suspend fun bucketName(`value`: Output) {
this.bucketName = value
}
/**
* @param value 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.
*/
@JvmName("nidxbaghwkqppgdx")
public suspend fun bucketOptions(`value`: Output) {
this.bucketOptions = value
}
/**
* @param value A description of this metric, which is used in documentation. The maximum length of the
* description is 8000 characters.
*/
@JvmName("lmqtxvmfxeeomdni")
public suspend fun description(`value`: Output) {
this.description = value
}
/**
* @param value If set to True, then this metric is disabled and it does not generate any points.
*/
@JvmName("likeohigbndpjehm")
public suspend fun disabled(`value`: Output) {
this.disabled = value
}
/**
* @param value An advanced logs filter (https://cloud.google.com/logging/docs/view/advanced-filters) which
* is used to match log entries.
* - - -
*/
@JvmName("hckfyeephotgxekp")
public suspend fun filter(`value`: Output) {
this.filter = value
}
/**
* @param value 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.
*/
@JvmName("rwvuehjguqbbtgfw")
public suspend fun labelExtractors(`value`: Output>) {
this.labelExtractors = value
}
/**
* @param value 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.
*/
@JvmName("edfljukgalwpshyi")
public suspend fun metricDescriptor(`value`: Output) {
this.metricDescriptor = value
}
/**
* @param value 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.
*/
@JvmName("rnqybvdqulbqftgg")
public suspend fun name(`value`: Output) {
this.name = value
}
/**
* @param value The ID of the project in which the resource belongs.
* If it is not provided, the provider project is used.
*/
@JvmName("uysfandwwkrohpft")
public suspend fun project(`value`: Output) {
this.project = value
}
/**
* @param value 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.
*/
@JvmName("bgtwsdiggfdkxauf")
public suspend fun valueExtractor(`value`: Output) {
this.valueExtractor = value
}
/**
* @param value 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.
*/
@JvmName("tbqghoxmbtqrqusg")
public suspend fun bucketName(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.bucketName = mapped
}
/**
* @param value 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.
*/
@JvmName("nfriocbvkdmcpuje")
public suspend fun bucketOptions(`value`: MetricBucketOptionsArgs?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.bucketOptions = mapped
}
/**
* @param argument 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.
*/
@JvmName("xvkwknypfkgmumcu")
public suspend fun bucketOptions(argument: suspend MetricBucketOptionsArgsBuilder.() -> Unit) {
val toBeMapped = MetricBucketOptionsArgsBuilder().applySuspend { argument() }.build()
val mapped = of(toBeMapped)
this.bucketOptions = mapped
}
/**
* @param value A description of this metric, which is used in documentation. The maximum length of the
* description is 8000 characters.
*/
@JvmName("nokitjulfpnrdvxn")
public suspend fun description(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.description = mapped
}
/**
* @param value If set to True, then this metric is disabled and it does not generate any points.
*/
@JvmName("qtponasruojldwhc")
public suspend fun disabled(`value`: Boolean?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.disabled = mapped
}
/**
* @param value An advanced logs filter (https://cloud.google.com/logging/docs/view/advanced-filters) which
* is used to match log entries.
* - - -
*/
@JvmName("lvrnoheaxcvxheyq")
public suspend fun filter(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.filter = mapped
}
/**
* @param value 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.
*/
@JvmName("yusauakwireuhkov")
public suspend fun labelExtractors(`value`: Map?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.labelExtractors = mapped
}
/**
* @param values 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.
*/
@JvmName("emrasmaeakimnqbo")
public fun labelExtractors(vararg values: Pair) {
val toBeMapped = values.toMap()
val mapped = toBeMapped.let({ args0 -> of(args0) })
this.labelExtractors = mapped
}
/**
* @param value 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.
*/
@JvmName("nlnawffhvkaekarc")
public suspend fun metricDescriptor(`value`: MetricMetricDescriptorArgs?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.metricDescriptor = mapped
}
/**
* @param argument 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.
*/
@JvmName("quwuafuvrjaujlib")
public suspend fun metricDescriptor(argument: suspend MetricMetricDescriptorArgsBuilder.() -> Unit) {
val toBeMapped = MetricMetricDescriptorArgsBuilder().applySuspend { argument() }.build()
val mapped = of(toBeMapped)
this.metricDescriptor = mapped
}
/**
* @param value 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.
*/
@JvmName("hesmaxocfssgkgna")
public suspend fun name(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.name = mapped
}
/**
* @param value The ID of the project in which the resource belongs.
* If it is not provided, the provider project is used.
*/
@JvmName("dhammjheknwdgacy")
public suspend fun project(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.project = mapped
}
/**
* @param value 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.
*/
@JvmName("lpnacgsgysljkjgp")
public suspend fun valueExtractor(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.valueExtractor = mapped
}
internal fun build(): MetricArgs = MetricArgs(
bucketName = bucketName,
bucketOptions = bucketOptions,
description = description,
disabled = disabled,
filter = filter,
labelExtractors = labelExtractors,
metricDescriptor = metricDescriptor,
name = name,
project = project,
valueExtractor = valueExtractor,
)
}