From: Kefu Chai Date: Mon, 22 Feb 2021 05:53:42 +0000 (+0800) Subject: mgr/influx: use "N/A" for unknown hostname X-Git-Tag: v16.2.7~94^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F43368%2Fhead;p=ceph.git mgr/influx: use "N/A" for unknown hostname in theory, there is chance that get_metadata() returns None, so let use "N/A" in this case. Signed-off-by: Kefu Chai (cherry picked from commit e457ca50011f70cf01a62323998af233a484f338) --- diff --git a/src/pybind/mgr/influx/module.py b/src/pybind/mgr/influx/module.py index e54ca1f0024..0f43ac0bb87 100644 --- a/src/pybind/mgr/influx/module.py +++ b/src/pybind/mgr/influx/module.py @@ -251,6 +251,10 @@ class Module(MgrModule): for daemon, counters in self.get_all_perf_counters().items(): svc_type, svc_id = daemon.split(".", 1) metadata = self.get_metadata(svc_type, svc_id) + if metadata is not None: + hostname = metadata['hostname'] + else: + hostname = 'N/A' for path, counter_info in counters.items(): if counter_info['type'] & self.PERFCOUNTER_HISTOGRAM: @@ -263,7 +267,7 @@ class Module(MgrModule): "tags": { "ceph_daemon": daemon, "type_instance": path, - "host": metadata['hostname'], + "host": hostname, "fsid": self.get_fsid() }, "time": now,