This module creates a Logs-based metric and optionally creates a distribution of the values, recording the statistics of the extracted values along with an optional histogram of the values as specified by the bucket options on Google Cloud Platform.
Note: For full explanation over dynamic blocks allowed options, please visit the resource documentation.
module logging_metric {
source = "smartscaling/logging-metric/google"
name = "<metric-identifier>"
filter = "<filter-to-base-metric-on>"
metric_descriptor = { <map-with-metric-descriptor-options> }
}
# Example of a counter Logging Metric
module logging_metric_counter {
source = "smartscaling/logging-metric/google"
name = "dummy-metric"
filter = "resource.type=gae_app AND severity>=ERROR"
metric_descriptor = {
metric_kind = "DELTA"
value_type = "INT64"
}
}
# Example of a counter Logging Metric with labels
module logging_metric_counter_labeled {
source = "smartscaling/logging-metric/google"
name = "dummy-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)"
}
}
# Example of a distribution Logging Metric
module logging_metric_distribution {
source = "smartscaling/logging-metric/google"
name = "dummy-metric"
filter = "resource.type=gae_app AND severity>=ERROR"
value_extractor = "EXTRACT(jsonPayload.request)"
metric_descriptor = {
display_name = "Dummy Metric"
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"
}
]
}
label_extractors = {
"mass" = "EXTRACT(jsonPayload.request)"
"sku" = "EXTRACT(jsonPayload.id)"
}
bucket_options = {
linear_buckets = {
num_finite_buckets = 3
width = 1
offset = 1
}
}
}
Name | Version |
---|---|
terraform | >= 0.13.0 |
>= 3.0.0 |
Name | Version |
---|---|
>= 3.0.0 |
No modules.
Name | Type |
---|---|
google_logging_metric.main | resource |
Name | Description | Type | Default | Required |
---|---|---|---|---|
bucket_options | Map containing 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. | any |
{} |
no |
create_resource | Specify wheter or not to create the resource. | bool |
true |
no |
description | A description of this metric, which is used in documentation. The maximum length of the description is 8000 characters. | string |
null |
no |
filter | An advanced logs filter (https://cloud.google.com/logging/docs/view/advanced-filters) which is used to match log entries. | string |
n/a | yes |
label_extractors | 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. | map(string) |
{} |
no |
metric_descriptor | Map containing the metric descriptor associated with the logs-based metric. | any |
{} |
no |
name | The identifier of this resource. | string |
n/a | yes |
project | The ID of the project in which the resource belongs. If it is not provided, the provider project is used. | string |
null |
no |
value_extractor | 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. | string |
null |
no |
Name | Description |
---|---|
bucket_options | The bucketOptions of this metric. |
description | The description of this metric. |
filter | The advanced logs filter used to match log entries. |
id | The identifier for the resource with format {{name}}. |
label_extractors | The label extractor of this metric. |
metric_descriptor | The metric descriptor associated with the logs-based metric. |
name | The client-assigned metric identifier. |
project | The ID of the project in which the resource belongs. |
value_extractor | The valueExtractor of this metric. |