mirror of
https://github.com/ansible/awx.git
synced 2026-02-16 10:40:01 -03:30
Co-authored-by: Christopher Wang <cwang@ansible.com> Co-authored-by: Jake McDermott <jmcdermott@ansible.com> Co-authored-by: Jim Ladd <jladd@redhat.com> Co-authored-by: Elijah DeLee <kdelee@redhat.com> Co-authored-by: Alan Rominger <arominge@redhat.com> Co-authored-by: Yanis Guenane <yanis@guenane.org>
24 lines
772 B
Python
24 lines
772 B
Python
from prometheus_client.parser import text_string_to_metric_families
|
|
|
|
from awxkit.api.resources import resources
|
|
from . import base
|
|
from . import page
|
|
|
|
|
|
class Metrics(base.Base):
|
|
|
|
def get(self, **query_parameters):
|
|
request = self.connection.get(self.endpoint, query_parameters)
|
|
self.page_identity(request, ignore_json_errors=True)
|
|
parsed_metrics = text_string_to_metric_families(request.text)
|
|
data = {}
|
|
for family in parsed_metrics:
|
|
for sample in family.samples:
|
|
data[sample[0]] = {"labels": sample[1], "value": sample[2]}
|
|
request.json = lambda: data
|
|
return self.page_identity(request)
|
|
|
|
|
|
page.register_page([resources.metrics,
|
|
(resources.metrics, 'get')], Metrics)
|