diff --git a/service/bigquery/metrics.tf b/service/bigquery/metrics.tf index b9f84260..a17226df 100644 --- a/service/bigquery/metrics.tf +++ b/service/bigquery/metrics.tf @@ -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, diff --git a/service/cloudfunctions/metrics.tf b/service/cloudfunctions/metrics.tf index d07881d6..daaf1ee1 100644 --- a/service/cloudfunctions/metrics.tf +++ b/service/cloudfunctions/metrics.tf @@ -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, diff --git a/service/cloudsql/metrics.tf b/service/cloudsql/metrics.tf index 804764e8..12b90c17 100644 --- a/service/cloudsql/metrics.tf +++ b/service/cloudsql/metrics.tf @@ -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, @@ -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", @@ -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", diff --git a/service/compute/metrics.tf b/service/compute/metrics.tf index 864be43f..0f7af07f 100644 --- a/service/compute/metrics.tf +++ b/service/compute/metrics.tf @@ -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, diff --git a/service/loadbalancing/metrics.tf b/service/loadbalancing/metrics.tf index 9406b29c..788b9515 100644 --- a/service/loadbalancing/metrics.tf +++ b/service/loadbalancing/metrics.tf @@ -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, diff --git a/service/pubsub/metrics_subscriptions.tf b/service/pubsub/metrics_subscriptions.tf index d1d1a564..ce374004 100644 --- a/service/pubsub/metrics_subscriptions.tf +++ b/service/pubsub/metrics_subscriptions.tf @@ -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, diff --git a/service/pubsub/metrics_topic.tf b/service/pubsub/metrics_topic.tf index 86ee30c9..29470068 100644 --- a/service/pubsub/metrics_topic.tf +++ b/service/pubsub/metrics_topic.tf @@ -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, diff --git a/service/pubsub/services.tf b/service/pubsub/services.tf index ad90b52f..54572910 100644 --- a/service/pubsub/services.tf +++ b/service/pubsub/services.tf @@ -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, @@ -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, @@ -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, diff --git a/service/redis/metrics.tf b/service/redis/metrics.tf index 62bd7f04..aebc6df0 100644 --- a/service/redis/metrics.tf +++ b/service/redis/metrics.tf @@ -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, diff --git a/service/storage/metrics.tf b/service/storage/metrics.tf index 047f643d..f965e148 100644 --- a/service/storage/metrics.tf +++ b/service/storage/metrics.tf @@ -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,