Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prometheus.py: add pool_name and image_name to subsystem_namespace_metadata #985

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions control/prometheus.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,18 @@ def _list_subsystems(self):

return {subsys.nqn: subsys for subsys in resp.subsystems}

@timer
def _list_namespaces(self, subsystem_list):
"""Fetch abbreviated namespace information used by the CLI"""
namespace_map = {}
for subsys in subsystem_list:
resp = self.gateway_rpc.list_namespaces(pb2.list_namespaces_req(subsystem=subsys.nqn))
if resp.status != 0:
logger.error(f"Exporter failed to execute list_namespaces: {resp.error_message}")
continue
namespace_map[subsys.nqn] = {ns.nsid: ns for ns in resp.namespaces}
return namespace_map

@timer
def _get_connection_map(self, subsystem_list):
"""Fetch connection information for all defined subsystems"""
Expand All @@ -211,6 +223,7 @@ def _get_data(self):
self.subsystems = self._get_subsystems()
self.subsystems_cli = self._list_subsystems()
self.connections = self._get_connection_map(self.subsystems)
self.namespaces = self._list_namespaces(self.subsystems)

@ttl
def collect(self):
Expand Down Expand Up @@ -369,7 +382,7 @@ def collect(self):
subsystem_namespace_metadata = GaugeMetricFamily(
f"{self.metric_prefix}_subsystem_namespace_metadata",
"Namespace information for the subsystem",
labels=["nqn", "nsid", "bdev_name", "anagrpid"])
labels=["nqn", "nsid", "bdev_name", "anagrpid", "pool_name", "image_name"])
host_connection_state = GaugeMetricFamily(
f"{self.metric_prefix}_host_connection_state",
"Host connection state 0=disconnected, 1=connected",
Expand Down Expand Up @@ -398,11 +411,15 @@ def collect(self):
subsystem_namespace_count.add_metric([nqn], len(subsys.namespaces))
subsystem_namespace_limit.add_metric([nqn], subsys.max_namespaces)
for ns in subsys.namespaces:
image = self.namespaces[nqn][ns.nsid].rbd_image_name
pool = self.namespaces[nqn][ns.nsid].rbd_pool_name
subsystem_namespace_metadata.add_metric([
nqn,
str(ns.nsid),
ns.bdev_name,
str(ns.anagrpid)
str(ns.anagrpid),
pool,
image,
], 1)

try:
Expand Down
Loading