Skip to content
Snippets Groups Projects
Commit 848daa50 authored by Josef Němec's avatar Josef Němec
Browse files

Merge branch 'feat/server-info' into 'master'

Add custom_openstack_server_info and flavor_info metrics

See merge request !14
parents 21262461 ae535401
No related branches found
No related tags found
1 merge request!14Add custom_openstack_server_info and flavor_info metrics
Pipeline #313954 passed
......@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [1.4.0] - 2023-08-28
### Added
- New metrics custom_openstack_server_info and custom_openstack_flavor_info
## [1.3.0] - 2023-04-11
### Fix
- Adding HTTP + HTTPS port checking
......
......@@ -78,6 +78,12 @@ class AppMetrics:
self.openstack_project_info = Gauge("custom_openstack_project_info",
"Custom info for a project",
["project_id", "project_name", "domain_id", "project_tag"])
self.openstack_server_info = Gauge("custom_openstack_server_info",
"Custom info for a server",
["server_id", "server_name", "image_id", "flavor_name"])
self.openstack_flavor_info = Gauge("custom_openstack_flavor_info",
"Openstack flavor parameters",
["flavor_id", "flavor_name", "ram", "disk", "vcpus", "public", "ephemeral", "disabled"])
self.openstack_loadbalancer_status = Gauge("custom_openstack_loadbalancer_accessibility_status",
"LoadBalancer accessibility status", ["id", "status"])
self.openstack_ip_status = Gauge("custom_openstack_ip_accessibility_status",
......@@ -89,6 +95,8 @@ class AppMetrics:
while True:
self.fetch_fip_quota()
self.fetch_project_info()
self.fetch_server_info()
self.fetch_flavor_info()
self.fetch_ip_status()
self.fetch_loadbalancer_status()
time.sleep(self.polling_interval_seconds)
......@@ -131,6 +139,44 @@ class AppMetrics:
project_tag=""
).set(project['is_enabled'])
def fetch_server_info(self):
"""
Get metrics from application and refresh Prometheus metrics with
new values.
"""
# remove all statuses
self.openstack_server_info.clear()
for server in self.os_connection.compute.servers(True,True):
self.openstack_server_info.labels(
server_id=server['id'],
server_name=server['name'],
image_id=server['image']['id'],
flavor_name=server['flavor']['original_name']
).set(1)
def fetch_flavor_info(self):
"""
Get metrics from application and refresh Prometheus metrics with
new values.
"""
# remove all statuses
self.openstack_flavor_info.clear()
for flavor in self.os_connection.compute.flavors():
self.openstack_flavor_info.labels(
flavor_id=flavor['id'],
flavor_name=flavor['name'],
ram=flavor['ram'],
disk=flavor['disk'],
vcpus=flavor['vcpus'],
public=flavor['os-flavor-access:is_public'],
ephemeral=flavor['OS-FLV-EXT-DATA:ephemeral'],
disabled=flavor['OS-FLV-DISABLED:disabled']
).set(1)
# support function for ip status evaluation
@staticmethod
def get_ip_accessibility_status_ping(ip_address):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment