metrics
Creates, updates, deletes, gets or lists a metrics
resource.
Overview
Name | metrics |
Type | Resource |
Id | google.logging.metrics |
Fields
Name | Datatype | Description |
---|---|---|
name | string | Required. The client-assigned metric identifier. Examples: "errorcount", "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.This field is the [METRIC_ID] part of a metric resource name in the format "projects/PROJECT_ID/metrics/METRIC_ID". Example: If the resource name of a metric is "projects/my-project/metrics/nginx%2Frequests", this field's value is "nginx/requests". |
description | string | Optional. A description of this metric, which is used in documentation. The maximum length of the description is 8000 characters. |
bucketName | string | Optional. 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.For example:projects/my-project/locations/global/buckets/my-bucketIf empty, then the Log Metric is considered a non-Bucket Log Metric. |
bucketOptions | object | BucketOptions describes the bucket boundaries used to create a histogram for the distribution. The buckets can be in a linear sequence, an exponential sequence, or each bucket can be specified explicitly. BucketOptions does not include the number of values in each bucket.A bucket has an inclusive lower bound and exclusive upper bound for the values that are counted for that bucket. The upper bound of a bucket must be strictly greater than the lower bound. The sequence of N buckets for a distribution consists of an underflow bucket (number 0), zero or more finite buckets (number 1 through N - 2) and an overflow bucket (number N - 1). The buckets are contiguous: the lower bound of bucket i (i > 0) is the same as the upper bound of bucket i - 1. The buckets span the whole range of finite values: lower bound of the underflow bucket is -infinity and the upper bound of the overflow bucket is +infinity. The finite buckets are so-called because both bounds are finite. |
createTime | string | Output only. The creation timestamp of the metric.This field may not be present for older metrics. |
disabled | boolean | Optional. If set to True, then this metric is disabled and it does not generate any points. |
filter | string | Required. An advanced logs filter (https://cloud.google.com/logging/docs/view/advanced_filters) which is used to match log entries. Example: "resource.type=gae_app AND severity>=ERROR" The maximum length of the filter is 20000 characters. |
labelExtractors | object | 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 value_extractor field.The extracted value is converted to the type defined in the label descriptor. If either the extraction or the type conversion fails, the label will have a default value. The default value for a string label is an empty string, for an integer label its 0, and for a boolean label its false.Note that there are upper bounds on the maximum number of labels and the number of active time series that are allowed in a project. |
metricDescriptor | object | Defines a metric type and its schema. Once a metric descriptor is created, deleting or altering it stops data collection and makes the metric type's existing data unusable. |
resourceName | string | Output only. The resource name of the metric: "projects/[PROJECT_ID]/metrics/[METRIC_ID]" |
updateTime | string | Output only. The last update timestamp of the metric.This field may not be present for older metrics. |
valueExtractor | string | Optional. A value_extractor 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 arguments are: field: The name of the log entry field from which the value is to be extracted. 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.The result of the extraction must be convertible to a double type, as the distribution always records double values. If either the extraction or the conversion to double fails, then those values are not recorded in the distribution.Example: REGEXP_EXTRACT(jsonPayload.request, ".quantity=(\d+).") |
version | string | Deprecated. The API version that created or updated this metric. The v2 format is used by default and cannot be changed. |
Methods
Name | Accessible by | Required Params | Description |
---|---|---|---|
projects_metrics_get | SELECT | metricsId, projectsId | Gets a logs-based metric. |
projects_metrics_list | SELECT | projectsId | Lists logs-based metrics. |
projects_metrics_create | INSERT | projectsId | Creates a logs-based metric. |
projects_metrics_delete | DELETE | metricsId, projectsId | Deletes a logs-based metric. |
projects_metrics_update | REPLACE | metricsId, projectsId | Creates or updates a logs-based metric. |
SELECT
examples
Lists logs-based metrics.
SELECT
name,
description,
bucketName,
bucketOptions,
createTime,
disabled,
filter,
labelExtractors,
metricDescriptor,
resourceName,
updateTime,
valueExtractor,
version
FROM google.logging.metrics
WHERE projectsId = '{{ projectsId }}';
INSERT
example
Use the following StackQL query and manifest file to create a new metrics
resource.
- All Properties
- Manifest
/*+ create */
INSERT INTO google.logging.metrics (
projectsId,
name,
description,
filter,
bucketName,
disabled,
metricDescriptor,
valueExtractor,
labelExtractors,
bucketOptions,
version
)
SELECT
'{{ projectsId }}',
'{{ name }}',
'{{ description }}',
'{{ filter }}',
'{{ bucketName }}',
{{ disabled }},
'{{ metricDescriptor }}',
'{{ valueExtractor }}',
'{{ labelExtractors }}',
'{{ bucketOptions }}',
'{{ version }}'
;
- name: your_resource_model_name
props:
- name: name
value: string
- name: resourceName
value: string
- name: description
value: string
- name: filter
value: string
- name: bucketName
value: string
- name: disabled
value: boolean
- name: metricDescriptor
value:
- name: name
value: string
- name: type
value: string
- name: labels
value:
- - name: key
value: string
- name: valueType
value: string
- name: description
value: string
- name: metricKind
value: string
- name: valueType
value: string
- name: unit
value: string
- name: description
value: string
- name: displayName
value: string
- name: metadata
value:
- name: launchStage
value: string
- name: samplePeriod
value: string
- name: ingestDelay
value: string
- name: timeSeriesResourceHierarchyLevel
value:
- string
- name: launchStage
value: string
- name: monitoredResourceTypes
value:
- string
- name: valueExtractor
value: string
- name: labelExtractors
value: object
- name: bucketOptions
value:
- name: linearBuckets
value:
- name: numFiniteBuckets
value: integer
- name: width
value: number
- name: offset
value: number
- name: exponentialBuckets
value:
- name: numFiniteBuckets
value: integer
- name: growthFactor
value: number
- name: scale
value: number
- name: explicitBuckets
value:
- name: bounds
value:
- number
- name: createTime
value: string
- name: updateTime
value: string
- name: version
value: string
REPLACE
example
Replaces all fields in the specified metrics
resource.
/*+ update */
REPLACE google.logging.metrics
SET
name = '{{ name }}',
description = '{{ description }}',
filter = '{{ filter }}',
bucketName = '{{ bucketName }}',
disabled = true|false,
metricDescriptor = '{{ metricDescriptor }}',
valueExtractor = '{{ valueExtractor }}',
labelExtractors = '{{ labelExtractors }}',
bucketOptions = '{{ bucketOptions }}',
version = '{{ version }}'
WHERE
metricsId = '{{ metricsId }}'
AND projectsId = '{{ projectsId }}';
DELETE
example
Deletes the specified metrics
resource.
/*+ delete */
DELETE FROM google.logging.metrics
WHERE metricsId = '{{ metricsId }}'
AND projectsId = '{{ projectsId }}';