Metric
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
- How-to Guides
Create a Metric Resource
new Metric(name: string, args: MetricArgs, opts?: CustomResourceOptions);def Metric(resource_name, opts=None, bucket_options=None, description=None, filter=None, label_extractors=None, metric_descriptor=None, name=None, project=None, value_extractor=None, __props__=None);func NewMetric(ctx *Context, name string, args MetricArgs, opts ...ResourceOption) (*Metric, error)public Metric(string name, MetricArgs args, CustomResourceOptions? opts = null)- name string
- The unique name of the resource.
- args MetricArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- opts ResourceOptions
- A bag of options that control this resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args MetricArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args MetricArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
Metric Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The Metric resource accepts the following input properties:
- Filter string
An advanced logs filter (https://cloud.google.com/logging/docs/view/advanced-filters) which is used to match log entries.
- Metric
Descriptor MetricMetric Descriptor Args The metric descriptor associated with the logs-based metric. Structure is documented below.
- Bucket
Options MetricBucket Options Args 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.
- Description string
A description of this metric, which is used in documentation. The maximum length of the description is 8000 characters.
- Label
Extractors Dictionary<string, string> 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.
- Name string
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.
- Project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- Value
Extractor string 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.
- Filter string
An advanced logs filter (https://cloud.google.com/logging/docs/view/advanced-filters) which is used to match log entries.
- Metric
Descriptor MetricMetric Descriptor The metric descriptor associated with the logs-based metric. Structure is documented below.
- Bucket
Options MetricBucket Options 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.
- Description string
A description of this metric, which is used in documentation. The maximum length of the description is 8000 characters.
- Label
Extractors map[string]string 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.
- Name string
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.
- Project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- Value
Extractor string 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.
- filter string
An advanced logs filter (https://cloud.google.com/logging/docs/view/advanced-filters) which is used to match log entries.
- metric
Descriptor MetricMetric Descriptor The metric descriptor associated with the logs-based metric. Structure is documented below.
- bucket
Options MetricBucket Options 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.
- description string
A description of this metric, which is used in documentation. The maximum length of the description is 8000 characters.
- label
Extractors {[key: string]: string} 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.
- name string
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.
- project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- value
Extractor string 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.
- filter str
An advanced logs filter (https://cloud.google.com/logging/docs/view/advanced-filters) which is used to match log entries.
- metric_
descriptor Dict[MetricMetric Descriptor] The metric descriptor associated with the logs-based metric. Structure is documented below.
- bucket_
options Dict[MetricBucket Options] 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.
- description str
A description of this metric, which is used in documentation. The maximum length of the description is 8000 characters.
- label_
extractors Dict[str, str] 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.
- name str
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.
- project str
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- value_
extractor str 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.
Outputs
All input properties are implicitly available as output properties. Additionally, the Metric resource produces the following output properties:
Look up an Existing Metric Resource
Get an existing Metric resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: MetricState, opts?: CustomResourceOptions): Metricstatic get(resource_name, id, opts=None, bucket_options=None, description=None, filter=None, label_extractors=None, metric_descriptor=None, name=None, project=None, value_extractor=None, __props__=None);func GetMetric(ctx *Context, name string, id IDInput, state *MetricState, opts ...ResourceOption) (*Metric, error)public static Metric Get(string name, Input<string> id, MetricState? state, CustomResourceOptions? opts = null)- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
The following state arguments are supported:
- Bucket
Options MetricBucket Options Args 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.
- Description string
A description of this metric, which is used in documentation. The maximum length of the description is 8000 characters.
- Filter string
An advanced logs filter (https://cloud.google.com/logging/docs/view/advanced-filters) which is used to match log entries.
- Label
Extractors Dictionary<string, string> 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.
- Metric
Descriptor MetricMetric Descriptor Args The metric descriptor associated with the logs-based metric. Structure is documented below.
- Name string
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.
- Project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- Value
Extractor string 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.
- Bucket
Options MetricBucket Options 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.
- Description string
A description of this metric, which is used in documentation. The maximum length of the description is 8000 characters.
- Filter string
An advanced logs filter (https://cloud.google.com/logging/docs/view/advanced-filters) which is used to match log entries.
- Label
Extractors map[string]string 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.
- Metric
Descriptor MetricMetric Descriptor The metric descriptor associated with the logs-based metric. Structure is documented below.
- Name string
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.
- Project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- Value
Extractor string 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.
- bucket
Options MetricBucket Options 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.
- description string
A description of this metric, which is used in documentation. The maximum length of the description is 8000 characters.
- filter string
An advanced logs filter (https://cloud.google.com/logging/docs/view/advanced-filters) which is used to match log entries.
- label
Extractors {[key: string]: string} 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.
- metric
Descriptor MetricMetric Descriptor The metric descriptor associated with the logs-based metric. Structure is documented below.
- name string
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.
- project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- value
Extractor string 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.
- bucket_
options Dict[MetricBucket Options] 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.
- description str
A description of this metric, which is used in documentation. The maximum length of the description is 8000 characters.
- filter str
An advanced logs filter (https://cloud.google.com/logging/docs/view/advanced-filters) which is used to match log entries.
- label_
extractors Dict[str, str] 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.
- metric_
descriptor Dict[MetricMetric Descriptor] The metric descriptor associated with the logs-based metric. Structure is documented below.
- name str
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.
- project str
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- value_
extractor str 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.
Supporting Types
MetricBucketOptions
- Explicit
Buckets MetricBucket Options Explicit Buckets Args Specifies a set of buckets with arbitrary widths. Structure is documented below.
- Exponential
Buckets MetricBucket Options Exponential Buckets Args Specifies an exponential sequence of buckets that have a width that is proportional to the value of the lower bound. Each bucket represents a constant relative uncertainty on a specific value in the bucket. Structure is documented below.
- Linear
Buckets MetricBucket Options Linear Buckets Args Specifies a linear sequence of buckets that all have the same width (except overflow and underflow). Each bucket represents a constant absolute uncertainty on the specific value in the bucket. Structure is documented below.
- Explicit
Buckets MetricBucket Options Explicit Buckets Specifies a set of buckets with arbitrary widths. Structure is documented below.
- Exponential
Buckets MetricBucket Options Exponential Buckets Specifies an exponential sequence of buckets that have a width that is proportional to the value of the lower bound. Each bucket represents a constant relative uncertainty on a specific value in the bucket. Structure is documented below.
- Linear
Buckets MetricBucket Options Linear Buckets Specifies a linear sequence of buckets that all have the same width (except overflow and underflow). Each bucket represents a constant absolute uncertainty on the specific value in the bucket. Structure is documented below.
- explicit
Buckets MetricBucket Options Explicit Buckets Specifies a set of buckets with arbitrary widths. Structure is documented below.
- exponential
Buckets MetricBucket Options Exponential Buckets Specifies an exponential sequence of buckets that have a width that is proportional to the value of the lower bound. Each bucket represents a constant relative uncertainty on a specific value in the bucket. Structure is documented below.
- linear
Buckets MetricBucket Options Linear Buckets Specifies a linear sequence of buckets that all have the same width (except overflow and underflow). Each bucket represents a constant absolute uncertainty on the specific value in the bucket. Structure is documented below.
- explicit
Buckets Dict[MetricBucket Options Explicit Buckets] Specifies a set of buckets with arbitrary widths. Structure is documented below.
- exponential
Buckets Dict[MetricBucket Options Exponential Buckets] Specifies an exponential sequence of buckets that have a width that is proportional to the value of the lower bound. Each bucket represents a constant relative uncertainty on a specific value in the bucket. Structure is documented below.
- linear
Buckets Dict[MetricBucket Options Linear Buckets] Specifies a linear sequence of buckets that all have the same width (except overflow and underflow). Each bucket represents a constant absolute uncertainty on the specific value in the bucket. Structure is documented below.
MetricBucketOptionsExplicitBuckets
- Bounds List<double>
The values must be monotonically increasing.
- bounds List[Number]
The values must be monotonically increasing.
MetricBucketOptionsExponentialBuckets
- Growth
Factor double Must be greater than 1.
- Num
Finite intBuckets Must be greater than 0.
- Scale double
Must be greater than 0.
- Growth
Factor float64 Must be greater than 1.
- Num
Finite intBuckets Must be greater than 0.
- Scale float64
Must be greater than 0.
- growth
Factor number Must be greater than 1.
- num
Finite numberBuckets Must be greater than 0.
- scale number
Must be greater than 0.
- growth
Factor float Must be greater than 1.
- num
Finite floatBuckets Must be greater than 0.
- scale float
Must be greater than 0.
MetricBucketOptionsLinearBuckets
MetricMetricDescriptor
- Metric
Kind string Whether the metric records instantaneous values, changes to a value, etc. Some combinations of metricKind and valueType might not be supported. For counter metrics, set this to DELTA.
- Value
Type string The type of data that can be assigned to the label.
- Display
Name 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”. This field is optional but it is recommended to be set for any metrics associated with user-visible concepts, such as Quota.
- Labels
List<Metric
Metric Descriptor Label Args> The set of labels that can be used to describe a specific instance of this metric type. For example, the appengine.googleapis.com/http/server/response_latencies metric type has a label for the HTTP response code, response_code, so you can look at latencies for successful responses or just for responses that failed. Structure is documented below.
- Unit string
The unit in which the metric value is reported. It is only applicable if the valueType is
INT64,DOUBLE, orDISTRIBUTION. The supported units are a subset of The Unified Code for Units of Measure standard
- Metric
Kind string Whether the metric records instantaneous values, changes to a value, etc. Some combinations of metricKind and valueType might not be supported. For counter metrics, set this to DELTA.
- Value
Type string The type of data that can be assigned to the label.
- Display
Name 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”. This field is optional but it is recommended to be set for any metrics associated with user-visible concepts, such as Quota.
- Labels
[]Metric
Metric Descriptor Label The set of labels that can be used to describe a specific instance of this metric type. For example, the appengine.googleapis.com/http/server/response_latencies metric type has a label for the HTTP response code, response_code, so you can look at latencies for successful responses or just for responses that failed. Structure is documented below.
- Unit string
The unit in which the metric value is reported. It is only applicable if the valueType is
INT64,DOUBLE, orDISTRIBUTION. The supported units are a subset of The Unified Code for Units of Measure standard
- metric
Kind string Whether the metric records instantaneous values, changes to a value, etc. Some combinations of metricKind and valueType might not be supported. For counter metrics, set this to DELTA.
- value
Type string The type of data that can be assigned to the label.
- display
Name 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”. This field is optional but it is recommended to be set for any metrics associated with user-visible concepts, such as Quota.
- labels
Metric
Metric Descriptor Label[] The set of labels that can be used to describe a specific instance of this metric type. For example, the appengine.googleapis.com/http/server/response_latencies metric type has a label for the HTTP response code, response_code, so you can look at latencies for successful responses or just for responses that failed. Structure is documented below.
- unit string
The unit in which the metric value is reported. It is only applicable if the valueType is
INT64,DOUBLE, orDISTRIBUTION. The supported units are a subset of The Unified Code for Units of Measure standard
- metric
Kind str Whether the metric records instantaneous values, changes to a value, etc. Some combinations of metricKind and valueType might not be supported. For counter metrics, set this to DELTA.
- value
Type str The type of data that can be assigned to the label.
- display_
name str A concise name for the metric, which can be displayed in user interfaces. Use sentence case without an ending period, for example “Request count”. This field is optional but it is recommended to be set for any metrics associated with user-visible concepts, such as Quota.
- labels
List[Metric
Metric Descriptor Label] The set of labels that can be used to describe a specific instance of this metric type. For example, the appengine.googleapis.com/http/server/response_latencies metric type has a label for the HTTP response code, response_code, so you can look at latencies for successful responses or just for responses that failed. Structure is documented below.
- unit str
The unit in which the metric value is reported. It is only applicable if the valueType is
INT64,DOUBLE, orDISTRIBUTION. The supported units are a subset of The Unified Code for Units of Measure standard
MetricMetricDescriptorLabel
Package Details
- Repository
- https://github.com/pulumi/pulumi-gcp
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
google-betaTerraform Provider.