python-observabilityclient 1.1.0__tar.gz → 1.3.0__tar.gz
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.
- python_observabilityclient-1.3.0/.pre-commit-config.yaml +36 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/.zuul.yaml +1 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/AUTHORS +1 -0
- python_observabilityclient-1.3.0/CONTRIBUTING.rst +17 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/ChangeLog +18 -0
- python_observabilityclient-1.3.0/PKG-INFO +92 -0
- python_observabilityclient-1.3.0/README.rst +62 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/doc/requirements.txt +1 -1
- python_observabilityclient-1.3.0/doc/source/api.rst +39 -0
- python_observabilityclient-1.3.0/doc/source/conf.py +123 -0
- python_observabilityclient-1.3.0/doc/source/contributing.rst +4 -0
- python_observabilityclient-1.3.0/doc/source/index.rst +26 -0
- python_observabilityclient-1.3.0/doc/source/installation.rst +7 -0
- python_observabilityclient-1.3.0/doc/source/shell.rst +38 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/observabilityclient/plugin.py +3 -3
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/observabilityclient/prometheus_client.py +3 -4
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/observabilityclient/rbac.py +2 -3
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/observabilityclient/tests/functional/base.py +1 -1
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/observabilityclient/tests/unit/test_cli.py +1 -1
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/observabilityclient/tests/unit/test_prometheus_client.py +4 -4
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/observabilityclient/tests/unit/test_python_api.py +1 -1
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/observabilityclient/tests/unit/test_rbac.py +1 -1
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/observabilityclient/tests/unit/test_utils.py +9 -9
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/observabilityclient/utils/metric_utils.py +3 -3
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/observabilityclient/v1/base.py +1 -1
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/observabilityclient/v1/client.py +1 -1
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/observabilityclient/v1/python_api.py +1 -1
- python_observabilityclient-1.3.0/pyproject.toml +49 -0
- python_observabilityclient-1.3.0/python_observabilityclient.egg-info/PKG-INFO +92 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/python_observabilityclient.egg-info/SOURCES.txt +10 -1
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/python_observabilityclient.egg-info/entry_points.txt +3 -0
- python_observabilityclient-1.3.0/python_observabilityclient.egg-info/pbr.json +1 -0
- python_observabilityclient-1.3.0/releasenotes/source/2025.2.rst +6 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/releasenotes/source/index.rst +1 -0
- python_observabilityclient-1.3.0/setup.cfg +7 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/test-requirements.txt +1 -0
- python_observabilityclient-1.3.0/tox.ini +86 -0
- python_observabilityclient-1.1.0/PKG-INFO +0 -82
- python_observabilityclient-1.1.0/README.md +0 -52
- python_observabilityclient-1.1.0/pyproject.toml +0 -3
- python_observabilityclient-1.1.0/python_observabilityclient.egg-info/PKG-INFO +0 -82
- python_observabilityclient-1.1.0/python_observabilityclient.egg-info/pbr.json +0 -1
- python_observabilityclient-1.1.0/setup.cfg +0 -45
- python_observabilityclient-1.1.0/tox.ini +0 -92
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/.coveragerc +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/LICENSE +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/observabilityclient/__init__.py +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/observabilityclient/client.py +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/observabilityclient/i18n.py +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/observabilityclient/tests/functional/__init__.py +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/observabilityclient/tests/functional/test_cli.py +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/observabilityclient/tests/functional/test_python_api.py +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/observabilityclient/tests/unit/__init__.py +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/observabilityclient/utils/__init__.py +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/observabilityclient/v1/__init__.py +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/observabilityclient/v1/cli.py +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/python_observabilityclient.egg-info/dependency_links.txt +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/python_observabilityclient.egg-info/not-zip-safe +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/python_observabilityclient.egg-info/requires.txt +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/python_observabilityclient.egg-info/top_level.txt +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/releasenotes/notes/add-root-path-192ac0e6ea99b84f.yaml +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/releasenotes/notes/allow-for-providing-metric-names-list-for-rbac-e46a4fd0df3fad73.yaml +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/releasenotes/notes/allow-for-specifying-rbac-label-name-f99084757cde5f19.yaml +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/releasenotes/notes/change-aetos-service-type-37a53a86f4975803.yaml +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/releasenotes/notes/disable-config-overrides-for-keystone-discovered-endpoints-0b36ad382f029fa0.yaml +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/releasenotes/notes/fix-ipv6-escaping-faef776565954baa.yaml +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/releasenotes/notes/refactor-rbac-967ed5edcc1ef2a4.yaml +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/releasenotes/notes/remove-py38-acd461c4350f0dca.yaml +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/releasenotes/notes/remove-py39-a3f911847e0075b6.yaml +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/releasenotes/notes/send-token-only-when-communicating-with-aetos-21299ccc710f6473.yaml +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/releasenotes/source/2025.1.rst +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/releasenotes/source/_static/.placeholder +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/releasenotes/source/conf.py +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/releasenotes/source/unreleased.rst +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/requirements.txt +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/setup.py +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/tools/fix_ca_bundle.sh +0 -0
- {python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/tools/install_deps.sh +0 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
3
|
+
rev: v6.0.0
|
|
4
|
+
hooks:
|
|
5
|
+
- id: trailing-whitespace
|
|
6
|
+
# Replaces or checks mixed line ending
|
|
7
|
+
- id: mixed-line-ending
|
|
8
|
+
args: ['--fix', 'lf']
|
|
9
|
+
exclude: '.*\.(svg)$'
|
|
10
|
+
# Forbid files which have a UTF-8 byte-order marker
|
|
11
|
+
- id: fix-byte-order-marker
|
|
12
|
+
# Checks that non-binary executables have a proper shebang
|
|
13
|
+
- id: check-executables-have-shebangs
|
|
14
|
+
# Check for files that contain merge conflict strings.
|
|
15
|
+
- id: check-merge-conflict
|
|
16
|
+
# Check for debugger imports and py37+ breakpoint()
|
|
17
|
+
# calls in python source
|
|
18
|
+
- id: debug-statements
|
|
19
|
+
- id: check-yaml
|
|
20
|
+
files: .*\.(yaml|yml)$
|
|
21
|
+
- repo: https://opendev.org/openstack/hacking
|
|
22
|
+
rev: 7.0.0
|
|
23
|
+
hooks:
|
|
24
|
+
- id: hacking
|
|
25
|
+
additional_dependencies: []
|
|
26
|
+
- repo: https://github.com/asottile/pyupgrade
|
|
27
|
+
rev: v3.20.0
|
|
28
|
+
hooks:
|
|
29
|
+
- id: pyupgrade
|
|
30
|
+
args: [--py310-plus]
|
|
31
|
+
- repo: https://github.com/openstack/bashate
|
|
32
|
+
rev: 2.1.1
|
|
33
|
+
hooks:
|
|
34
|
+
- id: bashate
|
|
35
|
+
args: ['-v', '-iE006']
|
|
36
|
+
exclude: '.tox/.*'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
If you would like to contribute to the development of OpenStack, you must
|
|
2
|
+
follow the steps in this page:
|
|
3
|
+
|
|
4
|
+
https://docs.openstack.org/infra/manual/developers.html
|
|
5
|
+
|
|
6
|
+
If you already have a good understanding of how the system works and your
|
|
7
|
+
OpenStack accounts are set up, you can skip to the development workflow
|
|
8
|
+
section of this documentation to learn how changes to OpenStack should be
|
|
9
|
+
submitted for review via the Gerrit tool:
|
|
10
|
+
|
|
11
|
+
https://docs.openstack.org/infra/manual/developers.html#development-workflow
|
|
12
|
+
|
|
13
|
+
Pull requests submitted through GitHub will be ignored.
|
|
14
|
+
|
|
15
|
+
Bugs should be filed on Launchpad, not GitHub:
|
|
16
|
+
|
|
17
|
+
https://storyboard.openstack.org/#!/project/openstack/python-observabilityclient
|
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
CHANGES
|
|
2
2
|
=======
|
|
3
3
|
|
|
4
|
+
1.3.0
|
|
5
|
+
-----
|
|
6
|
+
|
|
7
|
+
* Convert README to rst
|
|
8
|
+
* [tox] Use the recommended coverage configuration
|
|
9
|
+
* Migrate setup configuration to pyproject.toml
|
|
10
|
+
* Reduce the amount of flake8 excludes
|
|
11
|
+
* Use pre-commit for pep8 checks
|
|
12
|
+
* Fix tox.ini styling
|
|
13
|
+
* Add documentation
|
|
14
|
+
* Remove basepython
|
|
15
|
+
* Update master for stable/2025.2
|
|
16
|
+
|
|
17
|
+
1.2.0
|
|
18
|
+
-----
|
|
19
|
+
|
|
20
|
+
* Fix PrometheusAPIClient set\_client\_cert
|
|
21
|
+
|
|
4
22
|
1.1.0
|
|
5
23
|
-----
|
|
6
24
|
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-observabilityclient
|
|
3
|
+
Version: 1.3.0
|
|
4
|
+
Summary: OpenStack Observability Client
|
|
5
|
+
Author-email: OpenStack <openstack-discuss@lists.openstack.org>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Classifier: Environment :: Console
|
|
8
|
+
Classifier: Environment :: OpenStack
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Intended Audience :: Information Technology
|
|
11
|
+
Classifier: Intended Audience :: System Administrators
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown; charset=UTF-8
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: osc-lib>=1.0.1
|
|
25
|
+
Requires-Dist: keystoneauth1>=1.0.0
|
|
26
|
+
Requires-Dist: cliff>=1.14.0
|
|
27
|
+
Requires-Dist: PyYAML>5.1
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
Dynamic: requires-dist
|
|
30
|
+
|
|
31
|
+
==========================
|
|
32
|
+
python-observabilityclient
|
|
33
|
+
==========================
|
|
34
|
+
|
|
35
|
+
.. image:: https://governance.openstack.org/tc/badges/python-observabilityclient.svg
|
|
36
|
+
|
|
37
|
+
.. Change things from this point on
|
|
38
|
+
|
|
39
|
+
observabilityclient is an OpenStackClient (OSC) plugin implementation that
|
|
40
|
+
implements commands for management of Prometheus.
|
|
41
|
+
|
|
42
|
+
-----------
|
|
43
|
+
Development
|
|
44
|
+
-----------
|
|
45
|
+
|
|
46
|
+
Install your OpenStack environment and patch your ``openstack`` client
|
|
47
|
+
application using python.
|
|
48
|
+
|
|
49
|
+
.. code:: console
|
|
50
|
+
git clone https://opendev.org/openstack/python-observabilityclient.git
|
|
51
|
+
cd python-observabilityclient
|
|
52
|
+
sudo pip install .
|
|
53
|
+
|
|
54
|
+
-----
|
|
55
|
+
Usage
|
|
56
|
+
-----
|
|
57
|
+
|
|
58
|
+
Use ``openstack metric query somequery`` to query for metrics in prometheus.
|
|
59
|
+
|
|
60
|
+
To use the python api do the following:
|
|
61
|
+
|
|
62
|
+
.. code:: python
|
|
63
|
+
from observabilityclient import client
|
|
64
|
+
|
|
65
|
+
c = client.Client(
|
|
66
|
+
'1', keystone_client.get_session(conf),
|
|
67
|
+
adapter_options={
|
|
68
|
+
'interface': conf.service_credentials.interface,
|
|
69
|
+
'region_name': conf.service_credentials.region_name})
|
|
70
|
+
c.query.query("somequery")
|
|
71
|
+
|
|
72
|
+
----------------
|
|
73
|
+
List of commands
|
|
74
|
+
----------------
|
|
75
|
+
|
|
76
|
+
* ``openstack metric list`` - lists all metrics
|
|
77
|
+
* ``openstack metric show`` - shows current values of a metric
|
|
78
|
+
* ``openstack metric query`` - queries prometheus and outputs the result
|
|
79
|
+
* ``openstack metric delete`` - deletes some metrics
|
|
80
|
+
* ``openstack metric snapshot`` - takes a snapshot of the current data
|
|
81
|
+
* ``openstack metric clean-tombstones`` - cleans the tsdb tombstones
|
|
82
|
+
|
|
83
|
+
------------------------------------------------
|
|
84
|
+
List of functions provided by the python library
|
|
85
|
+
------------------------------------------------
|
|
86
|
+
|
|
87
|
+
* ``c.query.list`` - lists all metrics
|
|
88
|
+
* ``c.query.show`` - shows current values of a metric
|
|
89
|
+
* ``c.query.query`` - queries prometheus and outputs the result
|
|
90
|
+
* ``c.query.delete`` - deletes some metrics
|
|
91
|
+
* ``c.query.snapshot`` - takes a snapshot of the current data
|
|
92
|
+
* ``c.query.clean-tombstones`` - cleans the tsdb tombstones
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
==========================
|
|
2
|
+
python-observabilityclient
|
|
3
|
+
==========================
|
|
4
|
+
|
|
5
|
+
.. image:: https://governance.openstack.org/tc/badges/python-observabilityclient.svg
|
|
6
|
+
|
|
7
|
+
.. Change things from this point on
|
|
8
|
+
|
|
9
|
+
observabilityclient is an OpenStackClient (OSC) plugin implementation that
|
|
10
|
+
implements commands for management of Prometheus.
|
|
11
|
+
|
|
12
|
+
-----------
|
|
13
|
+
Development
|
|
14
|
+
-----------
|
|
15
|
+
|
|
16
|
+
Install your OpenStack environment and patch your ``openstack`` client
|
|
17
|
+
application using python.
|
|
18
|
+
|
|
19
|
+
.. code:: console
|
|
20
|
+
git clone https://opendev.org/openstack/python-observabilityclient.git
|
|
21
|
+
cd python-observabilityclient
|
|
22
|
+
sudo pip install .
|
|
23
|
+
|
|
24
|
+
-----
|
|
25
|
+
Usage
|
|
26
|
+
-----
|
|
27
|
+
|
|
28
|
+
Use ``openstack metric query somequery`` to query for metrics in prometheus.
|
|
29
|
+
|
|
30
|
+
To use the python api do the following:
|
|
31
|
+
|
|
32
|
+
.. code:: python
|
|
33
|
+
from observabilityclient import client
|
|
34
|
+
|
|
35
|
+
c = client.Client(
|
|
36
|
+
'1', keystone_client.get_session(conf),
|
|
37
|
+
adapter_options={
|
|
38
|
+
'interface': conf.service_credentials.interface,
|
|
39
|
+
'region_name': conf.service_credentials.region_name})
|
|
40
|
+
c.query.query("somequery")
|
|
41
|
+
|
|
42
|
+
----------------
|
|
43
|
+
List of commands
|
|
44
|
+
----------------
|
|
45
|
+
|
|
46
|
+
* ``openstack metric list`` - lists all metrics
|
|
47
|
+
* ``openstack metric show`` - shows current values of a metric
|
|
48
|
+
* ``openstack metric query`` - queries prometheus and outputs the result
|
|
49
|
+
* ``openstack metric delete`` - deletes some metrics
|
|
50
|
+
* ``openstack metric snapshot`` - takes a snapshot of the current data
|
|
51
|
+
* ``openstack metric clean-tombstones`` - cleans the tsdb tombstones
|
|
52
|
+
|
|
53
|
+
------------------------------------------------
|
|
54
|
+
List of functions provided by the python library
|
|
55
|
+
------------------------------------------------
|
|
56
|
+
|
|
57
|
+
* ``c.query.list`` - lists all metrics
|
|
58
|
+
* ``c.query.show`` - shows current values of a metric
|
|
59
|
+
* ``c.query.query`` - queries prometheus and outputs the result
|
|
60
|
+
* ``c.query.delete`` - deletes some metrics
|
|
61
|
+
* ``c.query.snapshot`` - takes a snapshot of the current data
|
|
62
|
+
* ``c.query.clean-tombstones`` - cleans the tsdb tombstones
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
The :mod:`observabilityclient` Python API
|
|
2
|
+
=========================================
|
|
3
|
+
|
|
4
|
+
.. module:: observabilityclient
|
|
5
|
+
:synopsis: A client for the Prometheus API.
|
|
6
|
+
|
|
7
|
+
.. currentmodule:: observabilityclient
|
|
8
|
+
|
|
9
|
+
Usage
|
|
10
|
+
-----
|
|
11
|
+
|
|
12
|
+
To use observabilityclient in a project::
|
|
13
|
+
|
|
14
|
+
>>> from observabilityclient import client
|
|
15
|
+
>>> obs_client = client.Client('1', session, adapter_options=adapter_opts)
|
|
16
|
+
>>> obs_client.query.list()
|
|
17
|
+
|
|
18
|
+
To have queries scoped to a single project (for restricting unprivileged
|
|
19
|
+
access to metrics from other projects)::
|
|
20
|
+
|
|
21
|
+
>>> # Assuming you have client created following previous example
|
|
22
|
+
>>> from observabilityclient import rbac as obsc_rbac
|
|
23
|
+
>>> promQLRbac = obsc_rbac.PromQLRbac(
|
|
24
|
+
>>> obs_client.prometheus_client,
|
|
25
|
+
>>> project_id
|
|
26
|
+
>>> )
|
|
27
|
+
>>> scoped_query = promQLRbac.modify_query(query)
|
|
28
|
+
|
|
29
|
+
Reference
|
|
30
|
+
---------
|
|
31
|
+
|
|
32
|
+
For more information, see the reference:
|
|
33
|
+
|
|
34
|
+
.. toctree::
|
|
35
|
+
:maxdepth: 2
|
|
36
|
+
|
|
37
|
+
ref/v1/index
|
|
38
|
+
ref/index
|
|
39
|
+
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
2
|
+
# you may not use this file except in compliance with the License.
|
|
3
|
+
# You may obtain a copy of the License at
|
|
4
|
+
#
|
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
#
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
10
|
+
# implied.
|
|
11
|
+
# See the License for the specific language governing permissions and
|
|
12
|
+
# limitations under the License.
|
|
13
|
+
|
|
14
|
+
import os
|
|
15
|
+
import sys
|
|
16
|
+
|
|
17
|
+
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
18
|
+
ROOT = os.path.abspath(os.path.join(BASE_DIR, "..", ".."))
|
|
19
|
+
|
|
20
|
+
sys.path.insert(0, ROOT)
|
|
21
|
+
sys.path.insert(0, BASE_DIR)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def gen_ref(ver, title, names):
|
|
25
|
+
refdir = os.path.join(BASE_DIR, "ref")
|
|
26
|
+
pkg = "observabilityclient"
|
|
27
|
+
if ver:
|
|
28
|
+
pkg = f"{pkg}.{ver}"
|
|
29
|
+
refdir = os.path.join(refdir, ver)
|
|
30
|
+
if not os.path.exists(refdir):
|
|
31
|
+
os.makedirs(refdir)
|
|
32
|
+
idxpath = os.path.join(refdir, "index.rst")
|
|
33
|
+
with open(idxpath, "w") as idx:
|
|
34
|
+
idx.write(("%(title)s\n"
|
|
35
|
+
"%(signs)s\n"
|
|
36
|
+
"\n"
|
|
37
|
+
".. toctree::\n"
|
|
38
|
+
" :maxdepth: 1\n"
|
|
39
|
+
"\n") % {"title": title, "signs": "=" * len(title)})
|
|
40
|
+
for name in names:
|
|
41
|
+
idx.write(" %s\n" % name)
|
|
42
|
+
rstpath = os.path.join(refdir, "%s.rst" % name)
|
|
43
|
+
with open(rstpath, "w") as rst:
|
|
44
|
+
rst.write(("%(title)s\n"
|
|
45
|
+
"%(signs)s\n"
|
|
46
|
+
"\n"
|
|
47
|
+
".. automodule:: %(pkg)s.%(name)s\n"
|
|
48
|
+
" :members:\n"
|
|
49
|
+
" :undoc-members:\n"
|
|
50
|
+
" :show-inheritance:\n"
|
|
51
|
+
" :noindex:\n")
|
|
52
|
+
% {"title": " ".join([n.capitalize()
|
|
53
|
+
for n in name.split("_")]),
|
|
54
|
+
"signs": "=" * len(name),
|
|
55
|
+
"pkg": pkg, "name": name})
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
gen_ref("v1", "Version 1 API", ["client", "python_api"])
|
|
59
|
+
gen_ref("", "rbac", ["rbac"])
|
|
60
|
+
|
|
61
|
+
# -- General configuration ----------------------------------------------------
|
|
62
|
+
|
|
63
|
+
# Add any Sphinx extension module names here, as strings. They can be
|
|
64
|
+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
|
65
|
+
extensions = [
|
|
66
|
+
'sphinx.ext.autodoc',
|
|
67
|
+
'openstackdocstheme',
|
|
68
|
+
# 'sphinx.ext.intersphinx',
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
# autodoc generation is a bit aggressive and a nuisance when doing heavy
|
|
72
|
+
# text edit cycles.
|
|
73
|
+
# execute "export SPHINX_DEBUG=1" in your terminal to disable
|
|
74
|
+
|
|
75
|
+
# The suffix of source filenames.
|
|
76
|
+
source_suffix = '.rst'
|
|
77
|
+
|
|
78
|
+
# The master toctree document.
|
|
79
|
+
master_doc = 'index'
|
|
80
|
+
|
|
81
|
+
# openstackdocstheme options
|
|
82
|
+
openstackdocs_repo_name = 'openstack/python-observabilityclient'
|
|
83
|
+
openstackdocs_bug_project = 'python-observabilityclient'
|
|
84
|
+
openstackdocs_bug_tag = ''
|
|
85
|
+
copyright = '2025, OpenStack Foundation'
|
|
86
|
+
|
|
87
|
+
# If true, '()' will be appended to :func: etc. cross-reference text.
|
|
88
|
+
add_function_parentheses = True
|
|
89
|
+
|
|
90
|
+
# If true, the current module name will be prepended to all description
|
|
91
|
+
# unit titles (such as .. function::).
|
|
92
|
+
add_module_names = True
|
|
93
|
+
|
|
94
|
+
# The name of the Pygments (syntax highlighting) style to use.
|
|
95
|
+
pygments_style = 'native'
|
|
96
|
+
|
|
97
|
+
# -- Options for HTML output --------------------------------------------------
|
|
98
|
+
|
|
99
|
+
# The theme to use for HTML and HTML Help pages. Major themes that come with
|
|
100
|
+
# Sphinx are currently 'default' and 'sphinxdoc'.
|
|
101
|
+
# html_theme_path = ["."]
|
|
102
|
+
# html_theme = '_theme'
|
|
103
|
+
# html_static_path = ['static']
|
|
104
|
+
html_theme = 'openstackdocs'
|
|
105
|
+
|
|
106
|
+
# Add any paths that contain custom themes here, relative to this directory.
|
|
107
|
+
# html_theme_path = ['_theme']
|
|
108
|
+
|
|
109
|
+
# Output file base name for HTML help builder.
|
|
110
|
+
htmlhelp_basename = 'observabilityclientdoc'
|
|
111
|
+
|
|
112
|
+
# Grouping the document tree into LaTeX files. List of tuples
|
|
113
|
+
# (source start file, target name, title, author, documentclass
|
|
114
|
+
# [howto/manual]).
|
|
115
|
+
latex_documents = [
|
|
116
|
+
('index',
|
|
117
|
+
'observabilityclient.tex',
|
|
118
|
+
'observabilityclient Documentation',
|
|
119
|
+
'OpenStack Foundation', 'manual'),
|
|
120
|
+
]
|
|
121
|
+
|
|
122
|
+
# Example configuration for intersphinx: refer to the Python standard library.
|
|
123
|
+
# intersphinx_mapping = {'http://docs.python.org/': None}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Python bindings to the Prometheus API
|
|
2
|
+
=====================================
|
|
3
|
+
This is an OpenStackClient (OSC) plugin that implements commands for
|
|
4
|
+
management of Prometheus.
|
|
5
|
+
There's :doc:`a Python API <api>` (the :mod:`observabilityclient` module),
|
|
6
|
+
and a :doc:`command-line client <shell>`.
|
|
7
|
+
Each implements the same subset of Prometheus API.
|
|
8
|
+
|
|
9
|
+
Contents
|
|
10
|
+
--------
|
|
11
|
+
|
|
12
|
+
.. toctree::
|
|
13
|
+
:maxdepth: 2
|
|
14
|
+
|
|
15
|
+
installation
|
|
16
|
+
shell
|
|
17
|
+
api
|
|
18
|
+
contributing
|
|
19
|
+
|
|
20
|
+
Indices and tables
|
|
21
|
+
------------------
|
|
22
|
+
|
|
23
|
+
* :ref:`genindex`
|
|
24
|
+
* :ref:`modindex`
|
|
25
|
+
* :ref:`search`
|
|
26
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
The :program:`observabilityclient` openstack client extension
|
|
2
|
+
=============================================================
|
|
3
|
+
|
|
4
|
+
.. program:: observabilityclient
|
|
5
|
+
.. highlight:: bash
|
|
6
|
+
|
|
7
|
+
The :program:`observabilityclient` openstack client extension interacts with Prometheus API
|
|
8
|
+
from the command line. It supports the same subset of Prometheus API as the
|
|
9
|
+
observabilityclient python API.
|
|
10
|
+
|
|
11
|
+
.. warning::
|
|
12
|
+
|
|
13
|
+
This client commands conflict with the gnocchiclient commands.
|
|
14
|
+
Make sure to have only one of these clients installed at a time
|
|
15
|
+
|
|
16
|
+
All shell commands take the form::
|
|
17
|
+
|
|
18
|
+
openstack metric <command> [arguments...]
|
|
19
|
+
|
|
20
|
+
Run :program:`openstack metric --help` to get a full list of all possible commands,
|
|
21
|
+
and run :program:`openstack metric <command> --help` to get detailed help for that
|
|
22
|
+
command.
|
|
23
|
+
|
|
24
|
+
Examples
|
|
25
|
+
--------
|
|
26
|
+
|
|
27
|
+
List all accessible metrics::
|
|
28
|
+
|
|
29
|
+
openstack metric list
|
|
30
|
+
|
|
31
|
+
Show details of the ceilometer_cpu metric::
|
|
32
|
+
|
|
33
|
+
openstack metric show ceilometer_cpu
|
|
34
|
+
|
|
35
|
+
Send any PromQL query::
|
|
36
|
+
|
|
37
|
+
openstack metric query 'ceilometer_cpu{counter="cpu",job="ceilometer"} + on (counter, job) sum by (counter) (ceilometer_memory{label="baz",counter="NS",pod="POD"})'
|
|
38
|
+
|
{python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/observabilityclient/plugin.py
RENAMED
|
@@ -59,7 +59,7 @@ def build_option_parser(parser):
|
|
|
59
59
|
parser.add_argument(
|
|
60
60
|
'--os-observability-api-version',
|
|
61
61
|
metavar='<observability-api-version>',
|
|
62
|
-
help='Observability Plugin API version, default='
|
|
63
|
-
+
|
|
64
|
-
|
|
62
|
+
help='Observability Plugin API version, default=' +
|
|
63
|
+
DEFAULT_API_VERSION +
|
|
64
|
+
' (Env: OS_OSCPLUGIN_API_VERSION)')
|
|
65
65
|
return parser
|
|
@@ -45,14 +45,14 @@ class PrometheusAPIClientError(Exception):
|
|
|
45
45
|
return self.__str__()
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
class PrometheusMetric
|
|
48
|
+
class PrometheusMetric:
|
|
49
49
|
def __init__(self, input):
|
|
50
50
|
self.timestamp = input['value'][0]
|
|
51
51
|
self.labels = input['metric']
|
|
52
52
|
self.value = input['value'][1]
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
class PrometheusAPIClient
|
|
55
|
+
class PrometheusAPIClient:
|
|
56
56
|
def __init__(self, host, session=None, root_path=""):
|
|
57
57
|
self._host = host
|
|
58
58
|
if not self._host.endswith('/'):
|
|
@@ -70,8 +70,7 @@ class PrometheusAPIClient(object):
|
|
|
70
70
|
self._session.verify = ca_cert
|
|
71
71
|
|
|
72
72
|
def set_client_cert(self, client_cert, client_key):
|
|
73
|
-
self._session.cert = client_cert
|
|
74
|
-
self._session.key = client_key
|
|
73
|
+
self._session.cert = (client_cert, client_key)
|
|
75
74
|
|
|
76
75
|
def set_basic_auth(self, auth_user, auth_password):
|
|
77
76
|
self._session.auth = (auth_user, auth_password)
|
{python_observabilityclient-1.1.0 → python_observabilityclient-1.3.0}/observabilityclient/rbac.py
RENAMED
|
@@ -17,7 +17,7 @@ import re
|
|
|
17
17
|
from observabilityclient.utils.metric_utils import format_labels
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
class PromQLRbac
|
|
20
|
+
class PromQLRbac:
|
|
21
21
|
def __init__(self, prom_api_client, project_id, project_label='project'):
|
|
22
22
|
self.client = prom_api_client
|
|
23
23
|
|
|
@@ -40,8 +40,7 @@ class PromQLRbac(object):
|
|
|
40
40
|
|
|
41
41
|
def _find_label_value_end(self, query, start, quote_char):
|
|
42
42
|
end = start
|
|
43
|
-
while (end == start or
|
|
44
|
-
query[end - 1] == '\\'):
|
|
43
|
+
while (end == start or query[end - 1] == '\\'):
|
|
45
44
|
# Looking for first unescaped quotes
|
|
46
45
|
end = query.find(quote_char, end + 1)
|
|
47
46
|
# returns the quote position or -1
|
|
@@ -58,23 +58,23 @@ class MetricListMatcher(testtools.Matcher):
|
|
|
58
58
|
|
|
59
59
|
class PrometheusAPIClientTestBase(testtools.TestCase):
|
|
60
60
|
def setUp(self):
|
|
61
|
-
super(
|
|
61
|
+
super().setUp()
|
|
62
62
|
|
|
63
|
-
class GoodResponse
|
|
63
|
+
class GoodResponse:
|
|
64
64
|
def __init__(self):
|
|
65
65
|
self.status_code = 200
|
|
66
66
|
|
|
67
67
|
def json(self):
|
|
68
68
|
return {"status": "success"}
|
|
69
69
|
|
|
70
|
-
class BadResponse
|
|
70
|
+
class BadResponse:
|
|
71
71
|
def __init__(self):
|
|
72
72
|
self.status_code = 500
|
|
73
73
|
|
|
74
74
|
def json(self):
|
|
75
75
|
return {"status": "error", "error": "test_error"}
|
|
76
76
|
|
|
77
|
-
class NoContentResponse
|
|
77
|
+
class NoContentResponse:
|
|
78
78
|
def __init__(self):
|
|
79
79
|
self.status_code = 204
|
|
80
80
|
|
|
@@ -26,7 +26,7 @@ from observabilityclient.v1 import python_api
|
|
|
26
26
|
|
|
27
27
|
class QueryManagerTest(testtools.TestCase):
|
|
28
28
|
def setUp(self):
|
|
29
|
-
super(
|
|
29
|
+
super().setUp()
|
|
30
30
|
self.client = mock.Mock()
|
|
31
31
|
prom_client = prometheus_client.PrometheusAPIClient("somehost")
|
|
32
32
|
self.client.prometheus_client = prom_client
|
|
@@ -21,7 +21,7 @@ from observabilityclient import rbac
|
|
|
21
21
|
|
|
22
22
|
class PromQLRbacTest(testtools.TestCase):
|
|
23
23
|
def setUp(self):
|
|
24
|
-
super(
|
|
24
|
+
super().setUp()
|
|
25
25
|
self.project_id = "project123"
|
|
26
26
|
self.rbac = rbac.PromQLRbac(mock.Mock(), mock.Mock())
|
|
27
27
|
self.rbac.labels = {
|