python-observabilityclient 0.5.0__py3-none-any.whl → 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- observabilityclient/tests/functional/test_cli.py +39 -81
- observabilityclient/tests/functional/test_python_api.py +2 -2
- observabilityclient/tests/unit/test_cli.py +6 -4
- observabilityclient/tests/unit/test_python_api.py +6 -23
- observabilityclient/tests/unit/test_utils.py +58 -0
- observabilityclient/utils/metric_utils.py +28 -2
- observabilityclient/v1/base.py +21 -2
- observabilityclient/v1/client.py +4 -2
- observabilityclient/v1/python_api.py +3 -3
- {python_observabilityclient-0.5.0.dist-info → python_observabilityclient-1.0.0.dist-info}/METADATA +1 -1
- {python_observabilityclient-0.5.0.dist-info → python_observabilityclient-1.0.0.dist-info}/RECORD +17 -17
- python_observabilityclient-1.0.0.dist-info/pbr.json +1 -0
- python_observabilityclient-0.5.0.dist-info/pbr.json +0 -1
- {python_observabilityclient-0.5.0.dist-info → python_observabilityclient-1.0.0.dist-info}/AUTHORS +0 -0
- {python_observabilityclient-0.5.0.dist-info → python_observabilityclient-1.0.0.dist-info}/LICENSE +0 -0
- {python_observabilityclient-0.5.0.dist-info → python_observabilityclient-1.0.0.dist-info}/WHEEL +0 -0
- {python_observabilityclient-0.5.0.dist-info → python_observabilityclient-1.0.0.dist-info}/entry_points.txt +0 -0
- {python_observabilityclient-0.5.0.dist-info → python_observabilityclient-1.0.0.dist-info}/top_level.txt +0 -0
|
@@ -14,98 +14,56 @@ from observabilityclient.tests.functional import base
|
|
|
14
14
|
import time
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
class
|
|
18
|
-
"""Functional tests for cli commands
|
|
17
|
+
class CliTestFunctionalRBACNOOP(base.CliTestCase):
|
|
18
|
+
"""Functional tests for cli commands testing RBAC option."""
|
|
19
19
|
|
|
20
20
|
def test_list(self):
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
name_list = [item.get('metric_name') for item in cmd_output]
|
|
26
|
-
self.assertIn(
|
|
27
|
-
'up',
|
|
28
|
-
name_list
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
def test_show(self):
|
|
32
|
-
cmd_output = self.openstack(
|
|
33
|
-
'metric show up --disable-rbac',
|
|
34
|
-
parse_output=True,
|
|
35
|
-
)
|
|
36
|
-
for metric in cmd_output:
|
|
37
|
-
self.assertEqual(
|
|
38
|
-
"up",
|
|
39
|
-
metric["__name__"]
|
|
21
|
+
for cmdstr in ('metric list', 'metric list --disable-rbac'):
|
|
22
|
+
cmd_output = self.openstack(
|
|
23
|
+
cmdstr,
|
|
24
|
+
parse_output=True,
|
|
40
25
|
)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
26
|
+
name_list = [item.get('metric_name') for item in cmd_output]
|
|
27
|
+
self.assertIn(
|
|
28
|
+
'ceilometer_image_size',
|
|
29
|
+
name_list
|
|
44
30
|
)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
'metric query up --disable-rbac',
|
|
49
|
-
parse_output=True,
|
|
50
|
-
)
|
|
51
|
-
for metric in cmd_output:
|
|
52
|
-
self.assertEqual(
|
|
53
|
-
"up",
|
|
54
|
-
metric["__name__"]
|
|
55
|
-
)
|
|
56
|
-
self.assertEqual(
|
|
57
|
-
"1",
|
|
58
|
-
metric["value"]
|
|
31
|
+
self.assertIn(
|
|
32
|
+
'up',
|
|
33
|
+
name_list
|
|
59
34
|
)
|
|
60
35
|
|
|
61
|
-
|
|
62
|
-
class CliTestFunctionalRBACEnabled(base.CliTestCase):
|
|
63
|
-
"""Functional tests for cli commands with enabled RBAC."""
|
|
64
|
-
|
|
65
|
-
def test_list(self):
|
|
66
|
-
cmd_output = self.openstack(
|
|
67
|
-
'metric list',
|
|
68
|
-
parse_output=True,
|
|
69
|
-
)
|
|
70
|
-
name_list = [item.get('metric_name') for item in cmd_output]
|
|
71
|
-
self.assertIn(
|
|
72
|
-
'ceilometer_image_size',
|
|
73
|
-
name_list
|
|
74
|
-
)
|
|
75
|
-
self.assertNotIn(
|
|
76
|
-
'up',
|
|
77
|
-
name_list
|
|
78
|
-
)
|
|
79
|
-
|
|
80
36
|
def test_show(self):
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
for metric in cmd_output:
|
|
86
|
-
self.assertEqual(
|
|
87
|
-
"ceilometer_image_size",
|
|
88
|
-
metric["__name__"]
|
|
89
|
-
)
|
|
90
|
-
self.assertEqual(
|
|
91
|
-
"sg-core",
|
|
92
|
-
metric["job"]
|
|
37
|
+
for cmdstr in ('metric show up', 'metric show up --disable-rbac'):
|
|
38
|
+
cmd_output = self.openstack(
|
|
39
|
+
cmdstr,
|
|
40
|
+
parse_output=True,
|
|
93
41
|
)
|
|
42
|
+
for metric in cmd_output:
|
|
43
|
+
self.assertEqual(
|
|
44
|
+
"up",
|
|
45
|
+
metric["__name__"]
|
|
46
|
+
)
|
|
47
|
+
self.assertEqual(
|
|
48
|
+
"1",
|
|
49
|
+
metric["value"]
|
|
50
|
+
)
|
|
94
51
|
|
|
95
52
|
def test_query(self):
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
for metric in cmd_output:
|
|
101
|
-
self.assertEqual(
|
|
102
|
-
"ceilometer_image_size",
|
|
103
|
-
metric["__name__"]
|
|
104
|
-
)
|
|
105
|
-
self.assertEqual(
|
|
106
|
-
"sg-core",
|
|
107
|
-
metric["job"]
|
|
53
|
+
for cmdstr in ('metric query up', 'metric query up --disable-rbac'):
|
|
54
|
+
cmd_output = self.openstack(
|
|
55
|
+
cmdstr,
|
|
56
|
+
parse_output=True,
|
|
108
57
|
)
|
|
58
|
+
for metric in cmd_output:
|
|
59
|
+
self.assertEqual(
|
|
60
|
+
"up",
|
|
61
|
+
metric["__name__"]
|
|
62
|
+
)
|
|
63
|
+
self.assertEqual(
|
|
64
|
+
"1",
|
|
65
|
+
metric["value"]
|
|
66
|
+
)
|
|
109
67
|
|
|
110
68
|
|
|
111
69
|
class CliTestFunctionalAdminCommands(base.CliTestCase):
|
|
@@ -52,7 +52,7 @@ class PythonAPITestFunctionalRBACEnabled(base.PythonAPITestCase):
|
|
|
52
52
|
for metric in ret:
|
|
53
53
|
self.assertEqual("ceilometer_image_size",
|
|
54
54
|
metric.labels["__name__"])
|
|
55
|
-
self.assertEqual("
|
|
55
|
+
self.assertEqual("custom",
|
|
56
56
|
metric.labels["job"])
|
|
57
57
|
|
|
58
58
|
def test_query(self):
|
|
@@ -62,7 +62,7 @@ class PythonAPITestFunctionalRBACEnabled(base.PythonAPITestCase):
|
|
|
62
62
|
for metric in ret:
|
|
63
63
|
self.assertEqual("ceilometer_image_size",
|
|
64
64
|
metric.labels["__name__"])
|
|
65
|
-
self.assertEqual("
|
|
65
|
+
self.assertEqual("custom", metric.labels["job"])
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
class PythonAPITestFunctionalAdminCommands(base.PythonAPITestCase):
|
|
@@ -43,8 +43,9 @@ class CliTest(testtools.TestCase):
|
|
|
43
43
|
return_value=self.client), \
|
|
44
44
|
mock.patch.object(self.client.query, 'list',
|
|
45
45
|
return_value=metric_names) as m:
|
|
46
|
+
# NOTE: disable-rbac option is NOOP, RBAC is disabled by default
|
|
46
47
|
ret1 = cli_list.take_action(test_parsed_args_enabled)
|
|
47
|
-
m.assert_called_with(disable_rbac=
|
|
48
|
+
m.assert_called_with(disable_rbac=True)
|
|
48
49
|
|
|
49
50
|
ret2 = cli_list.take_action(test_parsed_args_disabled)
|
|
50
51
|
m.assert_called_with(disable_rbac=True)
|
|
@@ -75,9 +76,9 @@ class CliTest(testtools.TestCase):
|
|
|
75
76
|
return_value=self.client), \
|
|
76
77
|
mock.patch.object(self.client.query, 'show',
|
|
77
78
|
return_value=prom_metric) as m:
|
|
78
|
-
|
|
79
|
+
# NOTE: disable-rbac option is NOOP, RBAC is disabled by default
|
|
79
80
|
ret1 = cli_show.take_action(test_parsed_args_enabled)
|
|
80
|
-
m.assert_called_with('metric_name', disable_rbac=
|
|
81
|
+
m.assert_called_with('metric_name', disable_rbac=True)
|
|
81
82
|
|
|
82
83
|
ret2 = cli_show.take_action(test_parsed_args_disabled)
|
|
83
84
|
m.assert_called_with('metric_name', disable_rbac=True)
|
|
@@ -113,8 +114,9 @@ class CliTest(testtools.TestCase):
|
|
|
113
114
|
mock.patch.object(self.client.query, 'query',
|
|
114
115
|
return_value=prom_metric) as m:
|
|
115
116
|
|
|
117
|
+
# NOTE: disable-rbac option is NOOP, RBAC is disabled by default
|
|
116
118
|
ret1 = cli_query.take_action(test_parsed_args_enabled)
|
|
117
|
-
m.assert_called_with(query, disable_rbac=
|
|
119
|
+
m.assert_called_with(query, disable_rbac=True)
|
|
118
120
|
|
|
119
121
|
ret2 = cli_query.take_action(test_parsed_args_disabled)
|
|
120
122
|
m.assert_called_with(query, disable_rbac=True)
|
|
@@ -40,33 +40,16 @@ class QueryManagerTest(testtools.TestCase):
|
|
|
40
40
|
self.client.query = self.manager
|
|
41
41
|
|
|
42
42
|
def test_list(self):
|
|
43
|
-
|
|
44
|
-
'data': [
|
|
45
|
-
{
|
|
46
|
-
'__name__': 'metric1',
|
|
47
|
-
'label1': 'foo'
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
'__name__': 'test42',
|
|
51
|
-
'anotherlabel': 'bar'
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
'__name__': 'abc2',
|
|
55
|
-
}
|
|
56
|
-
]
|
|
57
|
-
}
|
|
58
|
-
returned_by_prom_no_rbac = {'data': ['metric1', 'test42', 'abc2']}
|
|
43
|
+
returned_data = {'data': ['metric1', 'test42', 'abc2']}
|
|
59
44
|
expected = ['abc2', 'metric1', 'test42']
|
|
60
45
|
|
|
61
46
|
with mock.patch.object(prometheus_client.PrometheusAPIClient, '_get',
|
|
62
|
-
return_value=
|
|
47
|
+
return_value=returned_data):
|
|
63
48
|
ret1 = self.manager.list()
|
|
64
|
-
|
|
49
|
+
self.assertEqual(expected, ret1)
|
|
65
50
|
|
|
66
|
-
with mock.patch.object(prometheus_client.PrometheusAPIClient, '_get',
|
|
67
|
-
return_value=returned_by_prom_no_rbac):
|
|
68
51
|
ret2 = self.manager.list(disable_rbac=True)
|
|
69
|
-
|
|
52
|
+
self.assertEqual(expected, ret2)
|
|
70
53
|
|
|
71
54
|
def test_show(self):
|
|
72
55
|
query = 'some_metric'
|
|
@@ -90,7 +73,7 @@ class QueryManagerTest(testtools.TestCase):
|
|
|
90
73
|
with mock.patch.object(prometheus_client.PrometheusAPIClient, '_get',
|
|
91
74
|
return_value=returned_by_prom):
|
|
92
75
|
ret1 = self.manager.show(query)
|
|
93
|
-
self.rbac.append_rbac_labels.
|
|
76
|
+
self.rbac.append_rbac_labels.assert_not_called()
|
|
94
77
|
|
|
95
78
|
self.assertThat(ret1, expected_matcher)
|
|
96
79
|
self.assertThat(ret2, expected_matcher)
|
|
@@ -118,7 +101,7 @@ class QueryManagerTest(testtools.TestCase):
|
|
|
118
101
|
self.rbac.modify_query.assert_not_called()
|
|
119
102
|
|
|
120
103
|
ret2 = self.manager.query(query)
|
|
121
|
-
self.rbac.modify_query.
|
|
104
|
+
self.rbac.modify_query.assert_not_called()
|
|
122
105
|
|
|
123
106
|
self.assertThat(ret1, expected_matcher)
|
|
124
107
|
self.assertThat(ret2, expected_matcher)
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
import os
|
|
16
16
|
from unittest import mock
|
|
17
17
|
|
|
18
|
+
from keystoneauth1 import adapter
|
|
19
|
+
from keystoneauth1 import session
|
|
18
20
|
import testtools
|
|
19
21
|
|
|
20
22
|
from observabilityclient import prometheus_client
|
|
@@ -99,6 +101,62 @@ class GetPrometheusClientTest(testtools.TestCase):
|
|
|
99
101
|
self.assertRaises(metric_utils.ConfigurationError,
|
|
100
102
|
metric_utils.get_prometheus_client)
|
|
101
103
|
|
|
104
|
+
def test_get_prometheus_client_from_keystone_http(self):
|
|
105
|
+
prometheus_endpoint = "http://localhost:1234/prometheus"
|
|
106
|
+
keystone_session = session.Session()
|
|
107
|
+
with mock.patch.dict(os.environ, {}), \
|
|
108
|
+
mock.patch.object(metric_utils, 'get_config_file',
|
|
109
|
+
return_value=None), \
|
|
110
|
+
mock.patch.object(adapter.Adapter, 'get_endpoint',
|
|
111
|
+
return_value=prometheus_endpoint), \
|
|
112
|
+
mock.patch.object(prometheus_client.PrometheusAPIClient,
|
|
113
|
+
"__init__", return_value=None) as init_m, \
|
|
114
|
+
mock.patch.object(prometheus_client.PrometheusAPIClient,
|
|
115
|
+
"set_ca_cert") as ca_m:
|
|
116
|
+
metric_utils.get_prometheus_client(keystone_session)
|
|
117
|
+
init_m.assert_called_with(
|
|
118
|
+
"localhost:1234", keystone_session, "prometheus"
|
|
119
|
+
)
|
|
120
|
+
ca_m.assert_not_called()
|
|
121
|
+
|
|
122
|
+
def test_get_prometheus_client_from_keystone_https(self):
|
|
123
|
+
prometheus_endpoint = "https://localhost:1234/prometheus"
|
|
124
|
+
keystone_session = session.Session()
|
|
125
|
+
with mock.patch.dict(os.environ, {}), \
|
|
126
|
+
mock.patch.object(metric_utils, 'get_config_file',
|
|
127
|
+
return_value=None), \
|
|
128
|
+
mock.patch.object(adapter.Adapter, 'get_endpoint',
|
|
129
|
+
return_value=prometheus_endpoint), \
|
|
130
|
+
mock.patch.object(prometheus_client.PrometheusAPIClient,
|
|
131
|
+
"__init__", return_value=None) as init_m, \
|
|
132
|
+
mock.patch.object(prometheus_client.PrometheusAPIClient,
|
|
133
|
+
"set_ca_cert") as ca_m:
|
|
134
|
+
metric_utils.get_prometheus_client(keystone_session)
|
|
135
|
+
init_m.assert_called_with(
|
|
136
|
+
"localhost:1234", keystone_session, "prometheus"
|
|
137
|
+
)
|
|
138
|
+
ca_m.assert_called_with(True)
|
|
139
|
+
|
|
140
|
+
def test_get_prometheus_client_from_keystone_custom_ca(self):
|
|
141
|
+
prometheus_endpoint = "https://localhost:1234/prometheus"
|
|
142
|
+
keystone_session = session.Session()
|
|
143
|
+
config_data = 'ca_cert: "ca/path"'
|
|
144
|
+
config_file = mock.mock_open(read_data=config_data)("name", 'r')
|
|
145
|
+
with mock.patch.dict(os.environ, {}), \
|
|
146
|
+
mock.patch.object(metric_utils, 'get_config_file',
|
|
147
|
+
return_value=config_file), \
|
|
148
|
+
mock.patch.object(adapter.Adapter, 'get_endpoint',
|
|
149
|
+
return_value=prometheus_endpoint), \
|
|
150
|
+
mock.patch.object(prometheus_client.PrometheusAPIClient,
|
|
151
|
+
"__init__", return_value=None) as init_m, \
|
|
152
|
+
mock.patch.object(prometheus_client.PrometheusAPIClient,
|
|
153
|
+
"set_ca_cert") as ca_m:
|
|
154
|
+
metric_utils.get_prometheus_client(keystone_session)
|
|
155
|
+
init_m.assert_called_with(
|
|
156
|
+
"localhost:1234", keystone_session, "prometheus"
|
|
157
|
+
)
|
|
158
|
+
ca_m.assert_called_with("ca/path")
|
|
159
|
+
|
|
102
160
|
|
|
103
161
|
class FormatLabelsTest(testtools.TestCase):
|
|
104
162
|
def setUp(self):
|
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
|
|
15
15
|
import logging
|
|
16
16
|
import os
|
|
17
|
+
from urllib import parse
|
|
17
18
|
|
|
19
|
+
from keystoneauth1 import adapter
|
|
20
|
+
from keystoneauth1.exceptions import catalog as keystone_exception
|
|
18
21
|
import yaml
|
|
19
22
|
|
|
20
23
|
from observabilityclient.prometheus_client import PrometheusAPIClient
|
|
@@ -45,7 +48,7 @@ def get_config_file():
|
|
|
45
48
|
return None
|
|
46
49
|
|
|
47
50
|
|
|
48
|
-
def get_prometheus_client(session=None):
|
|
51
|
+
def get_prometheus_client(session=None, adapter_options={}):
|
|
49
52
|
host = None
|
|
50
53
|
port = None
|
|
51
54
|
ca_cert = None
|
|
@@ -63,6 +66,28 @@ def get_prometheus_client(session=None):
|
|
|
63
66
|
root_path = conf['root_path']
|
|
64
67
|
conf_file.close()
|
|
65
68
|
|
|
69
|
+
if session is not None and (host is None or port is None):
|
|
70
|
+
try:
|
|
71
|
+
endpoint = adapter.Adapter(
|
|
72
|
+
session=session, **adapter_options
|
|
73
|
+
).get_endpoint()
|
|
74
|
+
parsed_url = parse.urlparse(endpoint)
|
|
75
|
+
host = parsed_url.hostname
|
|
76
|
+
port = parsed_url.port if parsed_url.port is not None else 80
|
|
77
|
+
root_path = parsed_url.path.strip('/')
|
|
78
|
+
if parsed_url.scheme == "https" and ca_cert is None:
|
|
79
|
+
# NOTE(jwysogla): Use the default CA certs if the scheme
|
|
80
|
+
# is https, but keep the original value if already set,
|
|
81
|
+
# so that a custom certificate can be set in the config
|
|
82
|
+
# file, while the endpoint is retrieved from keystone.
|
|
83
|
+
ca_cert = True
|
|
84
|
+
except keystone_exception.EndpointNotFound:
|
|
85
|
+
# NOTE(jwysogla): Don't do anything here. It's still possible
|
|
86
|
+
# to get the correct endpoint configuration from the env vars.
|
|
87
|
+
# If that doesn't work, the same error message is part of the
|
|
88
|
+
# exception raised below.
|
|
89
|
+
pass
|
|
90
|
+
|
|
66
91
|
# NOTE(jwysogla): We allow to overide the prometheus.yaml by
|
|
67
92
|
# the environment variables
|
|
68
93
|
if 'PROMETHEUS_HOST' in os.environ:
|
|
@@ -75,7 +100,8 @@ def get_prometheus_client(session=None):
|
|
|
75
100
|
root_path = os.environ['PROMETHEUS_ROOT_PATH']
|
|
76
101
|
if host is None or port is None:
|
|
77
102
|
raise ConfigurationError("Can't find prometheus host and "
|
|
78
|
-
"port configuration
|
|
103
|
+
"port configuration and endpoint for service"
|
|
104
|
+
"prometheus not found.")
|
|
79
105
|
client = PrometheusAPIClient(f"{host}:{port}", session, root_path)
|
|
80
106
|
if ca_cert is not None:
|
|
81
107
|
client.set_ca_cert(ca_cert)
|
observabilityclient/v1/base.py
CHANGED
|
@@ -13,20 +13,39 @@
|
|
|
13
13
|
# under the License.
|
|
14
14
|
#
|
|
15
15
|
|
|
16
|
+
import argparse
|
|
17
|
+
import sys
|
|
18
|
+
|
|
16
19
|
from osc_lib.command import command
|
|
17
20
|
|
|
18
21
|
from observabilityclient.i18n import _
|
|
19
22
|
|
|
20
23
|
|
|
24
|
+
class DeprecatedNOOPAction(argparse.Action):
|
|
25
|
+
def __init__(self, *args, **kwargs):
|
|
26
|
+
kwargs['help'] = f"[DEPRECATED] {kwargs['help']}" \
|
|
27
|
+
if 'help' in kwargs else \
|
|
28
|
+
"[DEPRECATED]"
|
|
29
|
+
kwargs['required'] = False
|
|
30
|
+
kwargs['nargs'] = 0
|
|
31
|
+
super().__init__(*args, **kwargs)
|
|
32
|
+
|
|
33
|
+
def __call__(self, parser, namespace, values, option_string=None):
|
|
34
|
+
if option_string is not None:
|
|
35
|
+
print(f"Note: {option_string} is deprecated option, "
|
|
36
|
+
"has no effect and is a subject for removal "
|
|
37
|
+
"in future OpenStack release.", file=sys.stderr)
|
|
38
|
+
|
|
39
|
+
|
|
21
40
|
class ObservabilityBaseCommand(command.Command):
|
|
22
41
|
"""Base class for metric commands."""
|
|
23
42
|
|
|
24
43
|
def get_parser(self, prog_name):
|
|
25
44
|
parser = super().get_parser(prog_name)
|
|
26
|
-
# TODO(jwysogla): Should this be restricted somehow?
|
|
27
45
|
parser.add_argument(
|
|
28
46
|
'--disable-rbac',
|
|
29
|
-
action=
|
|
47
|
+
action=DeprecatedNOOPAction,
|
|
48
|
+
default=True,
|
|
30
49
|
help=_("Disable rbac injection")
|
|
31
50
|
)
|
|
32
51
|
return parser
|
observabilityclient/v1/client.py
CHANGED
|
@@ -28,7 +28,7 @@ class Client(object):
|
|
|
28
28
|
session_options = session_options or {}
|
|
29
29
|
adapter_options = adapter_options or {}
|
|
30
30
|
|
|
31
|
-
adapter_options.setdefault('service_type', "
|
|
31
|
+
adapter_options.setdefault('service_type', "prometheus")
|
|
32
32
|
|
|
33
33
|
if session is None:
|
|
34
34
|
session = keystoneauth1.session.Session(**session_options)
|
|
@@ -38,7 +38,9 @@ class Client(object):
|
|
|
38
38
|
|
|
39
39
|
self.session = session
|
|
40
40
|
|
|
41
|
-
self.prometheus_client = get_prometheus_client(
|
|
41
|
+
self.prometheus_client = get_prometheus_client(
|
|
42
|
+
session, adapter_options
|
|
43
|
+
)
|
|
42
44
|
self.query = python_api.QueryManager(self)
|
|
43
45
|
self.rbac = rbac.PromQLRbac(
|
|
44
46
|
self.prometheus_client,
|
|
@@ -17,7 +17,7 @@ from observabilityclient.v1 import base
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
class QueryManager(base.Manager):
|
|
20
|
-
def list(self, disable_rbac=
|
|
20
|
+
def list(self, disable_rbac=True):
|
|
21
21
|
"""List metric names.
|
|
22
22
|
|
|
23
23
|
:param disable_rbac: Disables rbac injection if set to True
|
|
@@ -34,7 +34,7 @@ class QueryManager(base.Manager):
|
|
|
34
34
|
unique_metric_names = list(set([m['__name__'] for m in metrics]))
|
|
35
35
|
return sorted(unique_metric_names)
|
|
36
36
|
|
|
37
|
-
def show(self, name, disable_rbac=
|
|
37
|
+
def show(self, name, disable_rbac=True):
|
|
38
38
|
"""Show current values for metrics of a specified name.
|
|
39
39
|
|
|
40
40
|
:param disable_rbac: Disables rbac injection if set to True
|
|
@@ -48,7 +48,7 @@ class QueryManager(base.Manager):
|
|
|
48
48
|
last_metric_query = f"last_over_time({query}[5m])"
|
|
49
49
|
return self.prom.query(last_metric_query)
|
|
50
50
|
|
|
51
|
-
def query(self, query, disable_rbac=
|
|
51
|
+
def query(self, query, disable_rbac=True):
|
|
52
52
|
"""Send a query to prometheus.
|
|
53
53
|
|
|
54
54
|
The query can be any PromQL query. Labels for enforcing
|
{python_observabilityclient-0.5.0.dist-info → python_observabilityclient-1.0.0.dist-info}/RECORD
RENAMED
|
@@ -6,26 +6,26 @@ observabilityclient/prometheus_client.py,sha256=yn0cOj08CUYLNydyh3sc1vTPGwplxZeM
|
|
|
6
6
|
observabilityclient/rbac.py,sha256=Rw2jyEl-xGb2U6wi7mDjJxTR9kGpIt8xOKOUOFvjq1Q,6327
|
|
7
7
|
observabilityclient/tests/functional/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
observabilityclient/tests/functional/base.py,sha256=SXbPiksFH7aER-zZjIWxz5nwCqq5f1MYWth1tlFLwcs,6523
|
|
9
|
-
observabilityclient/tests/functional/test_cli.py,sha256=
|
|
10
|
-
observabilityclient/tests/functional/test_python_api.py,sha256=
|
|
9
|
+
observabilityclient/tests/functional/test_cli.py,sha256=jwhgt8w0gq1CdDoaDKLV8SB_hQRmgnbMw9rRIyfcZLo,3944
|
|
10
|
+
observabilityclient/tests/functional/test_python_api.py,sha256=5TLFboJ7B__UZ9zfc6bVSxPTzV9KnnrwluTqLwnTZLs,3308
|
|
11
11
|
observabilityclient/tests/unit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
-
observabilityclient/tests/unit/test_cli.py,sha256=
|
|
12
|
+
observabilityclient/tests/unit/test_cli.py,sha256=N19Yo-PIdhlR4-tKQCKbtoetbknxZwl10zsEQSA1Leo,6191
|
|
13
13
|
observabilityclient/tests/unit/test_prometheus_client.py,sha256=iyAypBArQE2e7WGORwhelpoKdNAK1UD2SqZcs6p6ToQ,18982
|
|
14
|
-
observabilityclient/tests/unit/test_python_api.py,sha256=
|
|
14
|
+
observabilityclient/tests/unit/test_python_api.py,sha256=gMUcsvQISESY7p3NWsuoHk07I0phc74c-JC2vKRKfBI,4741
|
|
15
15
|
observabilityclient/tests/unit/test_rbac.py,sha256=9kntOcGUwz9uzG2S4uZUozOl_BMw7I9b0W8FCoaNvm4,6961
|
|
16
|
-
observabilityclient/tests/unit/test_utils.py,sha256=
|
|
16
|
+
observabilityclient/tests/unit/test_utils.py,sha256=6Y1sgYk-5bJeS0OEUUnjNpTsAbiPYY8zBn_BWwvYoec,11258
|
|
17
17
|
observabilityclient/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
|
-
observabilityclient/utils/metric_utils.py,sha256=
|
|
18
|
+
observabilityclient/utils/metric_utils.py,sha256=Rn4DeaOHgwW0WFJPcwjBqyYreQRYkzSAXFIKfMV2jew,5051
|
|
19
19
|
observabilityclient/v1/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
|
-
observabilityclient/v1/base.py,sha256=
|
|
20
|
+
observabilityclient/v1/base.py,sha256=keRgOIe7_yvE57fJRZ5O6s0GK6N4CqbGwhw24CmiAGE,2913
|
|
21
21
|
observabilityclient/v1/cli.py,sha256=ln7GsnbW95n90oFGw4zLiwHDjY0YHBxkRBzID-j6ZmA,4028
|
|
22
|
-
observabilityclient/v1/client.py,sha256=
|
|
23
|
-
observabilityclient/v1/python_api.py,sha256=
|
|
24
|
-
python_observabilityclient-0.
|
|
25
|
-
python_observabilityclient-0.
|
|
26
|
-
python_observabilityclient-0.
|
|
27
|
-
python_observabilityclient-0.
|
|
28
|
-
python_observabilityclient-0.
|
|
29
|
-
python_observabilityclient-0.
|
|
30
|
-
python_observabilityclient-0.
|
|
31
|
-
python_observabilityclient-0.
|
|
22
|
+
observabilityclient/v1/client.py,sha256=J0BWVJY8-IlsPTregtZ-w5MwSqzpVdE4aBd4EO8iDS8,1751
|
|
23
|
+
observabilityclient/v1/python_api.py,sha256=niW0NUWKK-Mdli72gWpP_tjGYEFr4RXc5J3giBkIkuA,3891
|
|
24
|
+
python_observabilityclient-1.0.0.dist-info/AUTHORS,sha256=uF42zVMEuwXhMW7eHDIzCpnu-RfapejbBNapd1-nRmc,532
|
|
25
|
+
python_observabilityclient-1.0.0.dist-info/LICENSE,sha256=qyh9xnj_IPtYWzClm5mZxCWRKTr2eUP_iLcU28DIvCw,11343
|
|
26
|
+
python_observabilityclient-1.0.0.dist-info/METADATA,sha256=mspVnIVKjwTxTnwgWfDF1wxng_sXYawjF4uGEOlJJ20,2998
|
|
27
|
+
python_observabilityclient-1.0.0.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
|
28
|
+
python_observabilityclient-1.0.0.dist-info/entry_points.txt,sha256=15rmai80pMRfBKZrk6yPNrRkAs2h63bwlcbQKq9fax4,424
|
|
29
|
+
python_observabilityclient-1.0.0.dist-info/pbr.json,sha256=YK4B_isOYwbQEIqmRFy2GYseqdIngtkBMAKKtlBB4BU,46
|
|
30
|
+
python_observabilityclient-1.0.0.dist-info/top_level.txt,sha256=Lf7Fwm3hfK-X1JNRy19rVlrMUOyQShBBPwsCU3pz6yw,20
|
|
31
|
+
python_observabilityclient-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"git_version": "21e4885", "is_release": true}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"git_version": "ab8ce8f", "is_release": true}
|
{python_observabilityclient-0.5.0.dist-info → python_observabilityclient-1.0.0.dist-info}/AUTHORS
RENAMED
|
File without changes
|
{python_observabilityclient-0.5.0.dist-info → python_observabilityclient-1.0.0.dist-info}/LICENSE
RENAMED
|
File without changes
|
{python_observabilityclient-0.5.0.dist-info → python_observabilityclient-1.0.0.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|