@@ -206,6 +206,8 @@ def select_projects(self, *args):
206
206
def select_resources (self , * args , ** kwargs ):
207
207
"""Copy the query and add filtering by resource labels.
208
208
209
+ See more documentation at: https://cloud.google.com/monitoring/api/v3/filters#comparisons.
210
+
209
211
Examples::
210
212
211
213
query = query.select_resources(zone='us-central1-a')
@@ -273,8 +275,14 @@ def select_metrics(self, *args, **kwargs):
273
275
274
276
metric.label.<label> = "<value>"
275
277
276
- However, by adding ``"_prefix"`` or ``"_suffix"`` to the keyword,
277
- you can specify a partial match.
278
+ However, by adding ``"_notequal"`` to the keyword, you can inequality:
279
+
280
+ ``<label>_notequal=<value>`` generates::
281
+
282
+ metric.label.<label> != <value>
283
+
284
+ By adding ``"_prefix"`` or ``"_suffix"`` to the keyword, you can specify
285
+ a partial match.
278
286
279
287
``<label>_prefix=<value>`` generates::
280
288
@@ -596,7 +604,15 @@ def _build_label_filter(category, *args, **kwargs):
596
604
597
605
suffix = None
598
606
if key .endswith (
599
- ("_prefix" , "_suffix" , "_greater" , "_greaterequal" , "_less" , "_lessequal" )
607
+ (
608
+ "_prefix" ,
609
+ "_suffix" ,
610
+ "_greater" ,
611
+ "_greaterequal" ,
612
+ "_less" ,
613
+ "_lessequal" ,
614
+ "_notequal" ,
615
+ )
600
616
):
601
617
key , suffix = key .rsplit ("_" , 1 )
602
618
@@ -617,6 +633,8 @@ def _build_label_filter(category, *args, **kwargs):
617
633
term = "{key} < {value}"
618
634
elif suffix == "lessequal" :
619
635
term = "{key} <= {value}"
636
+ elif suffix == "notequal" :
637
+ term = "{key} != {value}"
620
638
else :
621
639
term = '{key} = "{value}"'
622
640
0 commit comments