]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/prometheus: escape special chars using r-string
authorKefu Chai <kchai@redhat.com>
Wed, 10 Feb 2021 07:47:31 +0000 (15:47 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 10 Feb 2021 15:12:30 +0000 (23:12 +0800)
so we don't need to worry about escaping the backslash anymore.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/pybind/mgr/prometheus/module.py

index ac586684a25c014f6aecad080f38a7db05543420..587dbd3ba25218e46f8abd9917a186b8c8611430 100644 (file)
@@ -851,7 +851,7 @@ class Module(MgrModule):
         # '*' can be used to indicate all pools or namespaces
         pools_string = cast(str, self.get_localized_module_option('rbd_stats_pools'))
         pool_keys = []
-        for x in re.split('[\s,]+', pools_string):
+        for x in re.split(r'[\s,]+', pools_string):
             if not x:
                 continue
 
@@ -940,7 +940,7 @@ class Module(MgrModule):
                     {'type': 'pool_id', 'regex': pool_id_regex},
                     {'type': 'namespace', 'regex': namespace_regex},
                     {'type': 'object_name',
-                     'regex': '^(?:rbd|journal)_data\.(?:([0-9]+)\.)?([^.]+)\.'},
+                     'regex': r'^(?:rbd|journal)_data\.(?:([0-9]+)\.)?([^.]+)\.'},
                 ],
                 'performance_counter_descriptors': list(counters_info),
             }
@@ -1089,7 +1089,7 @@ class Module(MgrModule):
         new_metrics = {}
         for metric_path in self.metrics.keys():
             # Address RGW sync perf. counters.
-            match = re.search('^data-sync-from-(.*)\.', metric_path)
+            match = re.search(r'^data-sync-from-(.*)\.', metric_path)
             if match:
                 new_path = re.sub('from-([^.]*)', 'from-zone', metric_path)
                 if new_path not in new_metrics: