@@ -170,6 +170,63 @@ be a positive float value. If not defined, the default is 0.8.`,
170
170
The metric cannot have negative values.
171
171
172
172
The metric must have a value type of INT64 or DOUBLE.` ,
173
+ },
174
+ "filter" : {
175
+ Type : schema .TypeString ,
176
+ Optional : true ,
177
+ Description : `A filter string to be used as the filter string for
178
+ a Stackdriver Monitoring TimeSeries.list API call.
179
+ This filter is used to select a specific TimeSeries for
180
+ the purpose of autoscaling and to determine whether the metric
181
+ is exporting per-instance or per-group data.
182
+
183
+ You can only use the AND operator for joining selectors.
184
+ You can only use direct equality comparison operator (=) without
185
+ any functions for each selector.
186
+ You can specify the metric in both the filter string and in the
187
+ metric field. However, if specified in both places, the metric must
188
+ be identical.
189
+
190
+ The monitored resource type determines what kind of values are
191
+ expected for the metric. If it is a gce_instance, the autoscaler
192
+ expects the metric to include a separate TimeSeries for each
193
+ instance in a group. In such a case, you cannot filter on resource
194
+ labels.
195
+
196
+ If the resource type is any other value, the autoscaler expects
197
+ this metric to contain values that apply to the entire autoscaled
198
+ instance group and resource label filtering can be performed to
199
+ point autoscaler at the correct TimeSeries to scale upon.
200
+ This is called a per-group metric for the purpose of autoscaling.
201
+
202
+ If not specified, the type defaults to gce_instance.
203
+
204
+ You should provide a filter that is selective enough to pick just
205
+ one TimeSeries for the autoscaled group or for each of the instances
206
+ (if you are using gce_instance resource type). If multiple
207
+ TimeSeries are returned upon the query execution, the autoscaler
208
+ will sum their respective values to obtain its scaling value.` ,
209
+ Default : "resource.type = gce_instance" ,
210
+ },
211
+ "single_instance_assignment" : {
212
+ Type : schema .TypeFloat ,
213
+ Optional : true ,
214
+ Description : `If scaling is based on a per-group metric value that represents the
215
+ total amount of work to be done or resource usage, set this value to
216
+ an amount assigned for a single instance of the scaled group.
217
+ The autoscaler will keep the number of instances proportional to the
218
+ value of this metric, the metric itself should not change value due
219
+ to group resizing.
220
+
221
+ For example, a good metric to use with the target is
222
+ 'pubsub.googleapis.com/subscription/num_undelivered_messages'
223
+ or a custom metric exporting the total number of requests coming to
224
+ your instances.
225
+
226
+ A bad example would be a metric exporting an average or median
227
+ latency, since this value can't include a chunk assignable to a
228
+ single instance, it could be better used with utilization_target
229
+ instead.` ,
173
230
},
174
231
"target" : {
175
232
Type : schema .TypeFloat ,
@@ -890,9 +947,11 @@ func flattenComputeAutoscalerAutoscalingPolicyMetric(v interface{}, d *schema.Re
890
947
continue
891
948
}
892
949
transformed = append (transformed , map [string ]interface {}{
893
- "name" : flattenComputeAutoscalerAutoscalingPolicyMetricName (original ["metric" ], d , config ),
894
- "target" : flattenComputeAutoscalerAutoscalingPolicyMetricTarget (original ["utilizationTarget" ], d , config ),
895
- "type" : flattenComputeAutoscalerAutoscalingPolicyMetricType (original ["utilizationTargetType" ], d , config ),
950
+ "name" : flattenComputeAutoscalerAutoscalingPolicyMetricName (original ["metric" ], d , config ),
951
+ "single_instance_assignment" : flattenComputeAutoscalerAutoscalingPolicyMetricSingleInstanceAssignment (original ["singleInstanceAssignment" ], d , config ),
952
+ "target" : flattenComputeAutoscalerAutoscalingPolicyMetricTarget (original ["utilizationTarget" ], d , config ),
953
+ "type" : flattenComputeAutoscalerAutoscalingPolicyMetricType (original ["utilizationTargetType" ], d , config ),
954
+ "filter" : flattenComputeAutoscalerAutoscalingPolicyMetricFilter (original ["filter" ], d , config ),
896
955
})
897
956
}
898
957
return transformed
@@ -901,6 +960,10 @@ func flattenComputeAutoscalerAutoscalingPolicyMetricName(v interface{}, d *schem
901
960
return v
902
961
}
903
962
963
+ func flattenComputeAutoscalerAutoscalingPolicyMetricSingleInstanceAssignment (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
964
+ return v
965
+ }
966
+
904
967
func flattenComputeAutoscalerAutoscalingPolicyMetricTarget (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
905
968
return v
906
969
}
@@ -909,6 +972,10 @@ func flattenComputeAutoscalerAutoscalingPolicyMetricType(v interface{}, d *schem
909
972
return v
910
973
}
911
974
975
+ func flattenComputeAutoscalerAutoscalingPolicyMetricFilter (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
976
+ return v
977
+ }
978
+
912
979
func flattenComputeAutoscalerAutoscalingPolicyLoadBalancingUtilization (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
913
980
if v == nil {
914
981
return nil
@@ -1217,6 +1284,13 @@ func expandComputeAutoscalerAutoscalingPolicyMetric(v interface{}, d tpgresource
1217
1284
transformed ["metric" ] = transformedName
1218
1285
}
1219
1286
1287
+ transformedSingleInstanceAssignment , err := expandComputeAutoscalerAutoscalingPolicyMetricSingleInstanceAssignment (original ["single_instance_assignment" ], d , config )
1288
+ if err != nil {
1289
+ return nil , err
1290
+ } else if val := reflect .ValueOf (transformedSingleInstanceAssignment ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1291
+ transformed ["singleInstanceAssignment" ] = transformedSingleInstanceAssignment
1292
+ }
1293
+
1220
1294
transformedTarget , err := expandComputeAutoscalerAutoscalingPolicyMetricTarget (original ["target" ], d , config )
1221
1295
if err != nil {
1222
1296
return nil , err
@@ -1231,6 +1305,13 @@ func expandComputeAutoscalerAutoscalingPolicyMetric(v interface{}, d tpgresource
1231
1305
transformed ["utilizationTargetType" ] = transformedType
1232
1306
}
1233
1307
1308
+ transformedFilter , err := expandComputeAutoscalerAutoscalingPolicyMetricFilter (original ["filter" ], d , config )
1309
+ if err != nil {
1310
+ return nil , err
1311
+ } else if val := reflect .ValueOf (transformedFilter ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1312
+ transformed ["filter" ] = transformedFilter
1313
+ }
1314
+
1234
1315
req = append (req , transformed )
1235
1316
}
1236
1317
return req , nil
@@ -1240,6 +1321,10 @@ func expandComputeAutoscalerAutoscalingPolicyMetricName(v interface{}, d tpgreso
1240
1321
return v , nil
1241
1322
}
1242
1323
1324
+ func expandComputeAutoscalerAutoscalingPolicyMetricSingleInstanceAssignment (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1325
+ return v , nil
1326
+ }
1327
+
1243
1328
func expandComputeAutoscalerAutoscalingPolicyMetricTarget (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1244
1329
return v , nil
1245
1330
}
@@ -1248,6 +1333,10 @@ func expandComputeAutoscalerAutoscalingPolicyMetricType(v interface{}, d tpgreso
1248
1333
return v , nil
1249
1334
}
1250
1335
1336
+ func expandComputeAutoscalerAutoscalingPolicyMetricFilter (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1337
+ return v , nil
1338
+ }
1339
+
1251
1340
func expandComputeAutoscalerAutoscalingPolicyLoadBalancingUtilization (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1252
1341
l := v .([]interface {})
1253
1342
if len (l ) == 0 || l [0 ] == nil {
0 commit comments