mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-05 02:01:05 +00:00
230 lines
7.5 KiB
Markdown
230 lines
7.5 KiB
Markdown
|
---
|
||
|
# ----------------------------------------------------------------------------
|
||
|
#
|
||
|
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
|
||
|
#
|
||
|
# ----------------------------------------------------------------------------
|
||
|
#
|
||
|
# This file is automatically generated by Magic Modules and manual
|
||
|
# changes will be clobbered when the file is regenerated.
|
||
|
#
|
||
|
# Please read more about how to change this file in
|
||
|
# .github/CONTRIBUTING.md.
|
||
|
#
|
||
|
# ----------------------------------------------------------------------------
|
||
|
layout: "google"
|
||
|
page_title: "Google: google_logging_metric"
|
||
|
sidebar_current: "docs-google-logging-metric"
|
||
|
description: |-
|
||
|
Logs-based metric can also be used to extract values from logs and create a a distribution
|
||
|
of the values.
|
||
|
---
|
||
|
|
||
|
# google\_logging\_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](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)
|
||
|
|
||
|
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
|
||
|
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=logging_metric_basic&cloudshell_image=gcr.io%2Fgraphite-cloud-shell-images%2Fterraform%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
|
||
|
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
|
||
|
</a>
|
||
|
</div>
|
||
|
## Example Usage - Logging Metric Basic
|
||
|
|
||
|
|
||
|
```hcl
|
||
|
resource "google_logging_metric" "logging_metric" {
|
||
|
name = "my-(custom)/metric"
|
||
|
filter = "resource.type=gae_app AND severity>=ERROR"
|
||
|
metric_descriptor {
|
||
|
metric_kind = "DELTA"
|
||
|
value_type = "DISTRIBUTION"
|
||
|
labels {
|
||
|
key = "mass"
|
||
|
value_type = "STRING"
|
||
|
description = "amount of matter"
|
||
|
}
|
||
|
}
|
||
|
value_extractor = "EXTRACT(jsonPayload.request)"
|
||
|
label_extractors = { "mass": "EXTRACT(jsonPayload.request)" }
|
||
|
bucket_options {
|
||
|
linear_buckets {
|
||
|
num_finite_buckets = 3
|
||
|
width = 1
|
||
|
offset = 1
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
|
||
|
## Argument Reference
|
||
|
|
||
|
The following arguments are supported:
|
||
|
|
||
|
|
||
|
* `name` -
|
||
|
(Required)
|
||
|
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.
|
||
|
|
||
|
* `filter` -
|
||
|
(Required)
|
||
|
An advanced logs filter (https://cloud.google.com/logging/docs/view/advanced-filters) which
|
||
|
is used to match log entries.
|
||
|
|
||
|
* `metric_descriptor` -
|
||
|
(Required)
|
||
|
The metric descriptor associated with the logs-based metric. Structure is documented below.
|
||
|
|
||
|
|
||
|
The `metric_descriptor` block supports:
|
||
|
|
||
|
* `value_type` -
|
||
|
(Required)
|
||
|
Whether the measurement is an integer, a floating-point number, etc.
|
||
|
Some combinations of metricKind and valueType might not be supported.
|
||
|
|
||
|
* `metric_kind` -
|
||
|
(Required)
|
||
|
Whether the metric records instantaneous values, changes to a value, etc.
|
||
|
Some combinations of metricKind and valueType might not be supported.
|
||
|
|
||
|
* `labels` -
|
||
|
(Optional)
|
||
|
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.
|
||
|
|
||
|
|
||
|
The `labels` block supports:
|
||
|
|
||
|
* `key` -
|
||
|
(Required)
|
||
|
The label key.
|
||
|
|
||
|
* `description` -
|
||
|
(Optional)
|
||
|
A human-readable description for the label.
|
||
|
|
||
|
* `value_type` -
|
||
|
(Optional)
|
||
|
The type of data that can be assigned to the label.
|
||
|
|
||
|
- - -
|
||
|
|
||
|
|
||
|
* `description` -
|
||
|
(Optional)
|
||
|
A description of this metric, which is used in documentation. The maximum length of the
|
||
|
description is 8000 characters.
|
||
|
|
||
|
* `label_extractors` -
|
||
|
(Optional)
|
||
|
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.
|
||
|
|
||
|
* `value_extractor` -
|
||
|
(Optional)
|
||
|
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` -
|
||
|
(Optional)
|
||
|
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.
|
||
|
* `project` - (Optional) The ID of the project in which the resource belongs.
|
||
|
If it is not provided, the provider project is used.
|
||
|
|
||
|
|
||
|
The `bucket_options` block supports:
|
||
|
|
||
|
* `linear_buckets` -
|
||
|
(Optional)
|
||
|
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.
|
||
|
|
||
|
* `exponential_buckets` -
|
||
|
(Optional)
|
||
|
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.
|
||
|
|
||
|
* `explicit` -
|
||
|
(Optional)
|
||
|
Specifies a set of buckets with arbitrary widths. Structure is documented below.
|
||
|
|
||
|
|
||
|
The `linear_buckets` block supports:
|
||
|
|
||
|
* `num_finite_buckets` -
|
||
|
(Optional)
|
||
|
Must be greater than 0.
|
||
|
|
||
|
* `width` -
|
||
|
(Optional)
|
||
|
Must be greater than 0.
|
||
|
|
||
|
* `offset` -
|
||
|
(Optional)
|
||
|
Lower bound of the first bucket.
|
||
|
|
||
|
The `exponential_buckets` block supports:
|
||
|
|
||
|
* `num_finite_buckets` -
|
||
|
(Optional)
|
||
|
Must be greater than 0.
|
||
|
|
||
|
* `growth_factor` -
|
||
|
(Optional)
|
||
|
Must be greater than 1.
|
||
|
|
||
|
* `scale` -
|
||
|
(Optional)
|
||
|
Must be greater than 0.
|
||
|
|
||
|
The `explicit` block supports:
|
||
|
|
||
|
* `bounds` -
|
||
|
(Optional)
|
||
|
The values must be monotonically increasing.
|
||
|
|
||
|
|
||
|
## Timeouts
|
||
|
|
||
|
This resource provides the following
|
||
|
[Timeouts](/docs/configuration/resources.html#timeouts) configuration options:
|
||
|
|
||
|
- `create` - Default is 4 minutes.
|
||
|
- `update` - Default is 4 minutes.
|
||
|
- `delete` - Default is 4 minutes.
|
||
|
|
||
|
## Import
|
||
|
|
||
|
Metric can be imported using any of these accepted formats:
|
||
|
|
||
|
```
|
||
|
$ terraform import google_logging_metric.default {{name}}
|
||
|
```
|
||
|
|
||
|
-> If you're importing a resource with beta features, make sure to include `-provider=google-beta`
|
||
|
as an argument so that Terraform uses the correct provider to import your resource.
|