Skip to content

Commit f95cf3d

Browse files
author
Joe Welsh
authored
feat: add support for Metrics Explorer (#182)
1 parent 722a56c commit f95cf3d

File tree

10 files changed

+14
-75
lines changed

10 files changed

+14
-75
lines changed

service/bigquery/metrics.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ resource "observe_dataset" "bigquery_metrics" {
7676
stage {
7777
pipeline = <<-EOF
7878
interface "metric", metric:metric, value:value
79+
set_dataset_alias "gcp_bigquery"
7980
${join("\n\n",
8081
[for metric, options in local.merged_metrics_definitions :
8182
indent(2,

service/cloudfunctions/metrics.tf

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -45,47 +45,10 @@ resource "observe_dataset" "cloud_functions_metrics" {
4545
EOF
4646
}
4747

48-
# The terraform below dynamically writes set_metric statements in opal
49-
# This loops through the local.metrics_definitions map using for
50-
# [for metric, options in local.metrics_definitions :
51-
52-
# metric is the key (avg_ttl) and options is the value (all the stuff between {})
53-
/* Example metric in local.metrics_definitions
54-
avg_ttl = {
55-
type = "gauge"
56-
description = <<-EOF
57-
Average TTL for keys in this database.
58-
EOF
59-
launchStage = "GA"
60-
rollup = "avg"
61-
aggregate = "sum"
62-
metricCategory = "none"
63-
google_metric_path = "redis.googleapis.com/keyspace/avg_ttl"
64-
label = "Average TTL"
65-
unit = "ms"
66-
metricBin = "keyspace"
67-
valuetype = "DOUBLE"
68-
69-
}
70-
*/
71-
72-
# We filter the outer for loop checking whether options.launchStage is in the array defined by var.metric_launch_stages
73-
# 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
74-
## and if so
75-
/* Example output
76-
set_metric options(
77-
aggregate: "sum",
78-
description: "Average TTL for keys in this database.\n",
79-
rollup: "avg",
80-
type: "gauge",
81-
unit: "ms"
82-
), "avg_ttl"
83-
84-
*/
85-
8648
stage {
8749
pipeline = <<-EOF
8850
interface "metric", metric:metric, value:value
51+
set_dataset_alias "gcp_function"
8952
${join("\n\n",
9053
[for metric, options in local.merged_metrics_definitions :
9154
indent(2,

service/cloudsql/metrics.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ resource "observe_dataset" "cloud_sql_metrics" {
7474
stage {
7575
pipeline = <<-EOF
7676
interface "metric", metric:metric, value:value
77+
set_dataset_alias "gcp_sql"
7778
${join("\n\n",
7879
[for metric, options in local.merged_metrics_definitions :
7980
indent(2,
@@ -115,6 +116,7 @@ resource "observe_dataset" "cloud_sql_metrics_combo" {
115116
make_col combo_metric: "all_database_network_connections"
116117
117118
interface "metric", metric:combo_metric, value:value
119+
set_dataset_alias "gcp_sql_comb"
118120
set_metric options(
119121
aggregate: "sum",
120122
description: "Combination of network connection metrics.\n",
@@ -207,6 +209,7 @@ resource "observe_dataset" "cloud_sql_metrics_wide" {
207209
stage {
208210
pipeline = <<-EOF
209211
interface "metric", metric:metric, value:value
212+
set_dataset_alias "gcp_sql_wide"
210213
set_metric options(
211214
aggregate: "sum",
212215
description: "Percentage of disk quota used\n",

service/compute/metrics.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ resource "observe_dataset" "compute_metrics" {
107107
stage {
108108
pipeline = <<-EOF
109109
interface "metric", metric:metric, value:value
110+
set_dataset_alias "gcp_compute"
110111
${join("\n\n",
111112
[for metric, options in local.merged_metrics_definitions :
112113
indent(2,

service/loadbalancing/metrics.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ resource "observe_dataset" "load_balancing_metrics" {
110110
stage {
111111
pipeline = <<-EOF
112112
interface "metric", metric:metric, value:value
113+
set_dataset_alias "gcp_lb"
113114
${join("\n\n",
114115
[for metric, options in local.merged_metrics_definitions :
115116
indent(2,

service/pubsub/metrics_subscriptions.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ resource "observe_dataset" "pubsub_subscription_metrics" {
9494
stage {
9595
pipeline = <<-EOF
9696
interface "metric", metric:metric, value:value
97+
set_dataset_alias "gcp_pubsub_sub"
9798
${join("\n\n",
9899
[for metric, options in local.merged_metrics_definitions :
99100
indent(2,

service/pubsub/metrics_topic.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ resource "observe_dataset" "pubsub_topic_metrics" {
8989
stage {
9090
pipeline = <<-EOF
9191
interface "metric", metric:metric, value:value
92+
set_dataset_alias "gcp_pubsub_topic"
9293
${join("\n\n",
9394
[for metric, options in local.merged_metrics_definitions :
9495
indent(2,

service/pubsub/services.tf

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ resource "observe_dataset" "pubsub_service_api_metrics" {
119119
stage {
120120
pipeline = <<-EOF
121121
interface "metric", metric:metric, value:value
122+
set_dataset_alias "gcp_pubsub_api"
122123
${join("\n\n",
123124
[for metric, options in local.service_metrics_definitions :
124125
indent(2,
@@ -129,47 +130,11 @@ if(contains(var.metric_launch_stages, options.launchStage) && options.metricBin
129130
130131
EOF
131132
}
132-
# The terraform below dynamically writes set_metric statements in opal
133-
# This loops through the local.metrics_definitions map using for
134-
# [for metric, options in local.metrics_definitions :
135-
136-
# metric is the key (avg_ttl) and options is the value (all the stuff between {})
137-
/* Example metric in local.metrics_definitions
138-
avg_ttl = {
139-
type = "gauge"
140-
description = <<-EOF
141-
Average TTL for keys in this database.
142-
EOF
143-
launchStage = "GA"
144-
rollup = "avg"
145-
aggregate = "sum"
146-
metricCategory = "none"
147-
google_metric_path = "redis.googleapis.com/keyspace/avg_ttl"
148-
label = "Average TTL"
149-
unit = "ms"
150-
metricBin = "keyspace"
151-
valuetype = "DOUBLE"
152-
153-
}
154-
*/
155-
156-
# We filter the outer for loop checking whether options.launchStage is in the array defined by var.metric_launch_stages
157-
# 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
158-
## and if so
159-
/* Example output
160-
set_metric options(
161-
aggregate: "sum",
162-
description: "Average TTL for keys in this database.\n",
163-
rollup: "avg",
164-
type: "gauge",
165-
unit: "ms"
166-
), "avg_ttl"
167-
168-
*/
169133

170134
stage {
171135
pipeline = <<-EOF
172136
interface "metric", metric:metric, value:value
137+
set_dataset_alias "gcp_pubsub_api"
173138
${join("\n\n",
174139
[for metric, options in local.merged_metrics_definitions_service :
175140
indent(2,
@@ -255,6 +220,7 @@ resource "observe_dataset" "pubsub_service_quota_metrics" {
255220
stage {
256221
pipeline = <<-EOF
257222
interface "metric", metric:metric, value:value
223+
set_dataset_alias "gcp_pubsub_quota"
258224
${join("\n\n",
259225
[for metric, options in local.merged_metrics_definitions_service :
260226
indent(2,

service/redis/metrics.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ resource "observe_dataset" "redis_metrics" {
107107
stage {
108108
pipeline = <<-EOF
109109
interface "metric", metric:metric, value:value
110+
set_dataset_alias "gcp_redis"
110111
${join("\n\n",
111112
[for metric, options in local.merged_metrics_definitions :
112113
indent(2,

service/storage/metrics.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ resource "observe_dataset" "storage_metrics" {
8686
stage {
8787
pipeline = <<-EOF
8888
interface "metric", metric:metric, value:value
89+
set_dataset_alias "gcp_storage"
8990
${join("\n\n",
9091
[for metric, options in local.merged_metrics_definitions :
9192
indent(2,

0 commit comments

Comments
 (0)