Skip to content
Merged
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
1 change: 1 addition & 0 deletions service/bigquery/metrics.tf
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ resource "observe_dataset" "bigquery_metrics" {
stage {
pipeline = <<-EOF
interface "metric", metric:metric, value:value
set_dataset_alias "gcp_bigquery"
${join("\n\n",
[for metric, options in local.merged_metrics_definitions :
indent(2,
Expand Down
39 changes: 1 addition & 38 deletions service/cloudfunctions/metrics.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,47 +45,10 @@ resource "observe_dataset" "cloud_functions_metrics" {
EOF
}

# The terraform below dynamically writes set_metric statements in opal
# This loops through the local.metrics_definitions map using for
# [for metric, options in local.metrics_definitions :

# metric is the key (avg_ttl) and options is the value (all the stuff between {})
/* Example metric in local.metrics_definitions
avg_ttl = {
type = "gauge"
description = <<-EOF
Average TTL for keys in this database.
EOF
launchStage = "GA"
rollup = "avg"
aggregate = "sum"
metricCategory = "none"
google_metric_path = "redis.googleapis.com/keyspace/avg_ttl"
label = "Average TTL"
unit = "ms"
metricBin = "keyspace"
valuetype = "DOUBLE"

}
*/

# We filter the outer for loop checking whether options.launchStage is in the array defined by var.metric_launch_stages
# in the inner for loop we iterate through the fields in the options objects and check if the field is in the array defined by var.metric_interface_fields
## and if so
/* Example output
set_metric options(
aggregate: "sum",
description: "Average TTL for keys in this database.\n",
rollup: "avg",
type: "gauge",
unit: "ms"
), "avg_ttl"

*/

stage {
pipeline = <<-EOF
interface "metric", metric:metric, value:value
set_dataset_alias "gcp_function"
${join("\n\n",
[for metric, options in local.merged_metrics_definitions :
indent(2,
Expand Down
3 changes: 3 additions & 0 deletions service/cloudsql/metrics.tf
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ resource "observe_dataset" "cloud_sql_metrics" {
stage {
pipeline = <<-EOF
interface "metric", metric:metric, value:value
set_dataset_alias "gcp_sql"
${join("\n\n",
[for metric, options in local.merged_metrics_definitions :
indent(2,
Expand Down Expand Up @@ -115,6 +116,7 @@ resource "observe_dataset" "cloud_sql_metrics_combo" {
make_col combo_metric: "all_database_network_connections"

interface "metric", metric:combo_metric, value:value
set_dataset_alias "gcp_sql_comb"
set_metric options(
aggregate: "sum",
description: "Combination of network connection metrics.\n",
Expand Down Expand Up @@ -207,6 +209,7 @@ resource "observe_dataset" "cloud_sql_metrics_wide" {
stage {
pipeline = <<-EOF
interface "metric", metric:metric, value:value
set_dataset_alias "gcp_sql_wide"
set_metric options(
aggregate: "sum",
description: "Percentage of disk quota used\n",
Expand Down
1 change: 1 addition & 0 deletions service/compute/metrics.tf
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ resource "observe_dataset" "compute_metrics" {
stage {
pipeline = <<-EOF
interface "metric", metric:metric, value:value
set_dataset_alias "gcp_compute"
${join("\n\n",
[for metric, options in local.merged_metrics_definitions :
indent(2,
Expand Down
1 change: 1 addition & 0 deletions service/loadbalancing/metrics.tf
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ resource "observe_dataset" "load_balancing_metrics" {
stage {
pipeline = <<-EOF
interface "metric", metric:metric, value:value
set_dataset_alias "gcp_lb"
${join("\n\n",
[for metric, options in local.merged_metrics_definitions :
indent(2,
Expand Down
1 change: 1 addition & 0 deletions service/pubsub/metrics_subscriptions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ resource "observe_dataset" "pubsub_subscription_metrics" {
stage {
pipeline = <<-EOF
interface "metric", metric:metric, value:value
set_dataset_alias "gcp_pubsub_sub"
${join("\n\n",
[for metric, options in local.merged_metrics_definitions :
indent(2,
Expand Down
1 change: 1 addition & 0 deletions service/pubsub/metrics_topic.tf
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ resource "observe_dataset" "pubsub_topic_metrics" {
stage {
pipeline = <<-EOF
interface "metric", metric:metric, value:value
set_dataset_alias "gcp_pubsub_topic"
${join("\n\n",
[for metric, options in local.merged_metrics_definitions :
indent(2,
Expand Down
40 changes: 3 additions & 37 deletions service/pubsub/services.tf
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ resource "observe_dataset" "pubsub_service_api_metrics" {
stage {
pipeline = <<-EOF
interface "metric", metric:metric, value:value
set_dataset_alias "gcp_pubsub_api"
${join("\n\n",
[for metric, options in local.service_metrics_definitions :
indent(2,
Expand All @@ -129,47 +130,11 @@ if(contains(var.metric_launch_stages, options.launchStage) && options.metricBin

EOF
}
# The terraform below dynamically writes set_metric statements in opal
# This loops through the local.metrics_definitions map using for
# [for metric, options in local.metrics_definitions :

# metric is the key (avg_ttl) and options is the value (all the stuff between {})
/* Example metric in local.metrics_definitions
avg_ttl = {
type = "gauge"
description = <<-EOF
Average TTL for keys in this database.
EOF
launchStage = "GA"
rollup = "avg"
aggregate = "sum"
metricCategory = "none"
google_metric_path = "redis.googleapis.com/keyspace/avg_ttl"
label = "Average TTL"
unit = "ms"
metricBin = "keyspace"
valuetype = "DOUBLE"

}
*/

# We filter the outer for loop checking whether options.launchStage is in the array defined by var.metric_launch_stages
# in the inner for loop we iterate through the fields in the options objects and check if the field is in the array defined by var.metric_interface_fields
## and if so
/* Example output
set_metric options(
aggregate: "sum",
description: "Average TTL for keys in this database.\n",
rollup: "avg",
type: "gauge",
unit: "ms"
), "avg_ttl"

*/

stage {
pipeline = <<-EOF
interface "metric", metric:metric, value:value
set_dataset_alias "gcp_pubsub_api"
${join("\n\n",
[for metric, options in local.merged_metrics_definitions_service :
indent(2,
Expand Down Expand Up @@ -255,6 +220,7 @@ resource "observe_dataset" "pubsub_service_quota_metrics" {
stage {
pipeline = <<-EOF
interface "metric", metric:metric, value:value
set_dataset_alias "gcp_pubsub_quota"
${join("\n\n",
[for metric, options in local.merged_metrics_definitions_service :
indent(2,
Expand Down
1 change: 1 addition & 0 deletions service/redis/metrics.tf
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ resource "observe_dataset" "redis_metrics" {
stage {
pipeline = <<-EOF
interface "metric", metric:metric, value:value
set_dataset_alias "gcp_redis"
${join("\n\n",
[for metric, options in local.merged_metrics_definitions :
indent(2,
Expand Down
1 change: 1 addition & 0 deletions service/storage/metrics.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ resource "observe_dataset" "storage_metrics" {
stage {
pipeline = <<-EOF
interface "metric", metric:metric, value:value
set_dataset_alias "gcp_storage"
${join("\n\n",
[for metric, options in local.merged_metrics_definitions :
indent(2,
Expand Down