Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new resource, google_logging_metric #1531

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 163 additions & 0 deletions products/logging/api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# Copyright 2018 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
!ruby/object:Api::Product
name: Logging
display_name: Stackdriver Logging
versions:
- !ruby/object:Api::Product::Version
name: ga
base_url: https://logging.googleapis.com/v2/
scopes:
- https://www.googleapis.com/auth/cloud-platform
apis_required:
- !ruby/object:Api::Product::ApiReference
name: Stackdriver Logging API
url: https://console.cloud.google.com/apis/library/logging.googleapis.com/
objects:
- !ruby/object:Api::Resource
name: "Metric"
base_url: projects/{{project}}/metrics
self_link: "projects/{{project}}/metrics/{{name}}"
update_verb: :PUT
description: |
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.
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
"Official Documentation": "https://cloud.google.com/logging/docs/reference/v2/rest/v2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link 404's. We usually point this link to the overview for the product, such as https://cloud.google.com/logging/docs/apis

api: "https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/create"
properties:
- !ruby/object:Api::Type::String
name: name
description: |
The client-assigned metric identifier. Examples: "error_count", "nginx/requests".
required: true
- !ruby/object:Api::Type::String
name: description
description: |
A description of this metric, which is used in documentation. The maximum length of the description is 8000 characters.
required: false
- !ruby/object:Api::Type::String
name: filter
description: |
An advanced logs filter which is used to match log entries.
required: true
- !ruby/object:Api::Type::NestedObject
name: metricDescriptor
description: |
The 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.
required: true
properties:
- !ruby/object:Api::Type::Enum
name: valueType
description: |
Whether the measurement is an integer, a floating-point number, etc. Some combinations of metricKind and valueType might not be supported.Whether the measurement is an integer, a floating-point number, etc. Some combinations of metricKind and valueType might not be supported.
values:
- :BOOL
- :INT64
- :DOUBLE
- :STRING
- :DISTRIBUTION
- :MONEY
required: true
- !ruby/object:Api::Type::Enum
name: metricKind
description: |
Whether the metric records instantaneous values, changes to a value, etc. Some combinations of metricKind and valueType might not be supported.
values:
- :DELTA
required: true
- !ruby/object:Api::Type::Array
name: labels
description: |
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.
required: false
item_type: !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::String
name: key
description: |
The label key.
required: true
- !ruby/object:Api::Type::String
name: description
description: |
A human-readable description for the label.
required: false
- !ruby/object:Api::Type::Enum
name: valueType
description: |
The type of data that can be assigned to the label.
values:
- :BOOL
- :INT64
- :STRING
required: false
default_value: :STRING
- !ruby/object:Api::Type::KeyValuePairs
name: labelExtractors
description: |
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.
- !ruby/object:Api::Type::String
name: valueExtractor
description: |
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.
- !ruby/object:Api::Type::NestedObject
name: bucketOptions
description: |
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.
properties:
- !ruby/object:Api::Type::NestedObject
name: linearBuckets
description: |
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.
properties:
- !ruby/object:Api::Type::Integer
name: numFiniteBuckets
description: |
Must be greater than 0.
- !ruby/object:Api::Type::Integer
name: width
description: |
Must be greater than 0.
- !ruby/object:Api::Type::Double
name: offset
description: |
Lower bound of the first bucket.
- !ruby/object:Api::Type::NestedObject
name: exponentialBuckets
description: |
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.
properties:
- !ruby/object:Api::Type::Integer
name: numFiniteBuckets
description: |
Must be greater than 0.
- !ruby/object:Api::Type::Integer
name: growthFactor
description: |
Must be greater than 1.
- !ruby/object:Api::Type::Double
name: scale
description: |
Must be greater than 0.
- !ruby/object:Api::Type::NestedObject
name: explicit
description: |
Specifies a set of buckets with arbitrary widths.
properties:
- !ruby/object:Api::Type::Array
name: bounds
item_type: Api::Type::String
description: |
The values must be monotonically increasing.
36 changes: 36 additions & 0 deletions products/logging/terraform.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
--- !ruby/object:Provider::Terraform::Config
overrides: !ruby/object:Overrides::ResourceOverrides
Metric: !ruby/object:Overrides::Terraform::ResourceOverride
id_format: "{{name}}"
import_format: ["{{name}}"]
mutex: customMetric/{{project}}
examples:
- !ruby/object:Provider::Terraform::Examples
name: "logging_metric_basic"
primary_resource_id: "logging_metric"
vars:
metric_display_name: "My Custom Metric"
custom_code: !ruby/object:Provider::Terraform::CustomCode
custom_import: templates/terraform/custom_import/self_link_as_name.erb
post_create: templates/terraform/post_create/set_computed_name.erb
properties:
metricDescriptor.labels.valueType: !ruby/object:Overrides::Terraform::PropertyOverride
custom_flatten: 'templates/terraform/custom_flatten/default_if_empty.erb'

files: !ruby/object:Provider::Config::Files
# These files have templating (ERB) code that will be run.
# This is usually to add licensing info, autogeneration notices, etc.
compile:
<%= lines(indent(compile('provider/terraform/product~compile.yaml'), 4)) -%>
3 changes: 3 additions & 0 deletions templates/terraform/examples/logging_metric_basic.tf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resource "google_logging_metric" "<%= ctx[:primary_resource_id] %>" {
name = "<%= ctx[:vars]["display_name"] %>"
}