@@ -93,7 +93,9 @@ def MetricDict(value):
9393 # (NONE, NUMBOOL, NOTNUMBOOL, FLOOR, CEIL).
9494 # Defaults to NONE
9595 Required ('mutate' , default = 'NONE' ):
96- In (['NONE' , 'NUMBOOL' , 'NOTNUMBOOL' , 'FLOOR' , 'CEIL' ]),
96+ In (['NONE' , 'NUMBOOL' , 'NOTNUMBOOL' , 'FLOOR' , 'CEIL' , 'MAP' ]),
97+ # Map dict used if mutate == 'MAP'
98+ Optional ('mutate_map' ): dict ,
9799 # Collector-specific args. Should be overriden by schema provided for
98100 # the given collector
99101 Optional ('extra_args' ): dict ,
@@ -270,6 +272,22 @@ def check_duplicates(metric_name, metric):
270272 return metric
271273
272274
275+ def validate_map_mutator (metric_name , metric ):
276+ """Validates MAP mutator"""
277+ mutate = metric .get ('mutate' )
278+ mutate_map = metric .get ('mutate_map' )
279+
280+ if mutate == 'MAP' and mutate_map is None :
281+ raise InvalidConfiguration (
282+ 'Metric {} uses MAP mutator but mutate_map is missing: {}' .format (
283+ metric_name , metric ))
284+
285+ if mutate != 'MAP' and mutate_map is not None :
286+ raise InvalidConfiguration (
287+ 'Metric {} not using MAP mutator but mutate_map is present: '
288+ '{}' .format (metric_name , metric ))
289+
290+
273291def validate_conf (conf ):
274292 """Validates the provided configuration."""
275293 collector = get_collector_without_invoke ()
@@ -278,4 +296,5 @@ def validate_conf(conf):
278296 if 'alt_name' not in metric .keys ():
279297 metric ['alt_name' ] = metric_name
280298 check_duplicates (metric_name , metric )
299+ validate_map_mutator (metric_name , metric )
281300 return output
0 commit comments