diff --git a/.gitreview b/.gitreview new file mode 100644 index 0000000..ad2abfc --- /dev/null +++ b/.gitreview @@ -0,0 +1,4 @@ +[gerrit] +host=review.opendev.org +port=29418 +project=openstack/ironic-prometheus-exporter.git diff --git a/.zuul.yaml b/.zuul.yaml new file mode 100644 index 0000000..3b7dbbc --- /dev/null +++ b/.zuul.yaml @@ -0,0 +1,5 @@ +- project: + templates: + - check-requirements + - openstack-python-jobs + - openstack-python3-train-jobs diff --git a/README.md b/README.md deleted file mode 100644 index a690507..0000000 --- a/README.md +++ /dev/null @@ -1,71 +0,0 @@ -# Ironic Prometheus Exporter # - - -### Installation ### - -1 - Clone the repository in the machine where ironic is installed. -``` -$ git clone https://github.com/metal3-io/ironic-prometheus-exporter -``` -2 - Install the driver (may require sudo permisions) -``` -$ cd ironic-prometheus-exporter -$ python setup.py install -``` -3- Verify if the driver is installed -``` -$ pip install entry_point_inspector --user -$ epi group show oslo.messaging.notify.drivers - -``` -Output in case of a successful instalation: -`prometheus_exporter` is listed in the `Name` column and the `Error` column should be empty. -Output in case of an unsuccessful instalation: -`prometheus_exporter` is listed in the `Name` column and the `Error` column will have more information. - - -### Configuration ### - -After install the driver you will need to update the `ironic.conf` and add the below information. - -``` -[conductor] -send_sensor_data=true - -[oslo_messaging_notifications] -driver = prometheus_exporter -transport_url = fake:// -location=/tmp/ironic_prometheus_exporter -``` - - -### Running exporter application ### - -The Flask Application is responsible to merge all the metrics files present in the directory -set in `[oslo_messaging_notifications]/location`. - -**NOTE:** if you want to deploy in production please check the Flask [documentation](http://flask.pocoo.org/docs/dev/deploying/) - -To run the Flask Application follow the steps listed below: -1 - open the repository directory -``` -$ cd ironic-prometheus-exporter/ -``` -2- set the `FLASK_*` environment variables and the location of the `ironic.conf` file. -``` -$ export IRONIC_CONFIG=/etc/ironic/ironic.conf -$ export FLASK_APP=ironic_prometheus_exporter/app/exporter.py -$ export FLASK_RUN_HOST=$HOST_IP -$ export FLASK_RUN_PORT=5000 -``` -3- run the Flask Application -``` -$ python -m flask run & -``` - -**Running under uWSGI** -Reproduce the Steps 1 and 2 (You don't need to set `FLASK_APP` variable) and run the command below: -``` -$ uwsgi --socket $FLASK_RUN_HOST:$FLASK_RUN_PORT --protocol=http -w ironic_prometheus_exporter.app.wsgi - -``` diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..84786f7 --- /dev/null +++ b/README.rst @@ -0,0 +1,98 @@ +Ironic Prometheus Exporter +========================== + +Overview +-------- +Tool to expose hardware sensor data in the `Prometheus `_ format through an HTTP endpoint. + +The hardware sensor data come from bare metal machines deployed +using `OpenStack Bare Metal Service (ironic) `_. + +* License: Apache License, Version 2.0 +* Documentation: https://docs.openstack.org/ironic-prometheus-exporter/ +* Source: https://opendev.org/openstack/ironic-prometheus-exporter +* Bugs: https://storyboard.openstack.org/#!/project/openstack/ironic-prometheus-exporter + + +Installation +------------ + +1 - Install ironic-prometheus-exporter +:: + + $ pip install --user ironic-prometheus-exporter + +2- Verify if the driver is installed +:: + + $ pip install entry_point_inspector --user + $ epi group show oslo.messaging.notify.drivers + + +- Output in case of a successful instalation: `prometheus_exporter` is listed in the `Name` column and the `Error` column should be empty. +- Output in case of an unsuccessful instalation: `prometheus_exporter` is listed in the `Name` column and the `Error` column will have more information. + + +Configuration +------------- + +After install the driver you will need to update the `ironic.conf` and add the following information: + +:: + + [conductor] + send_sensor_data=true + + [oslo_messaging_notifications] + driver = prometheus_exporter + transport_url = fake:// + location=/tmp/ironic_prometheus_exporter + + + +Running exporter application +---------------------------- + +The Flask Application is responsible to merge all the metrics files present in the directory +set in `[oslo_messaging_notifications]/location`. + +.. note:: If you want to deploy in production please check the Flask `documentation `_ + +To run the Flask Application follow the steps listed below: +1 - open the repository directory +:: + + $ cd ironic-prometheus-exporter/ + +2- set the `FLASK_*` environment variables and the location of the `ironic.conf` file. +:: + + $ export IRONIC_CONFIG=/etc/ironic/ironic.conf + $ export FLASK_APP=ironic_prometheus_exporter/app/exporter.py + $ export FLASK_RUN_HOST=$HOST_IP + $ export FLASK_RUN_PORT=5000 + +3- run the Flask Application +:: + +$ python -m flask run & + + +**Running under uWSGI** + +Reproduce the Steps 1 and 2 (You don't need to set `FLASK_APP` variable) and run the command below: +:: + +$ uwsgi --plugin python --http-socket ${FLASK_RUN_HOST}:${FLASK_RUN_PORT} --module ironic_prometheus_exporter.app.wsgi:application + + +Contributing +------------ + +* Pull requests: `Gerrit + `_ + (see `developer's guide + `_) +* Bugs and RFEs: `StoryBoard + `_ + (please do NOT report bugs to Github) diff --git a/requirements.txt b/requirements.txt index 1e91946..01cde09 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,5 @@ pbr!=2.1.0,>=2.0.0 # Apache-2.0 stevedore>=1.20.0 # Apache-2.0 oslo.messaging>=9.4.0 # Apache-2.0 -uWSGI # Apache-2.0 -Flask>=0.12.3 -prometheus_client # Apache-2.0 +Flask>=1.0.0 # BSD +prometheus_client>=0.6.0 # Apache-2.0 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..c4ae1d3 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,26 @@ +[metadata] +name = ironic-prometheus-exporter +summary = Prometheus Exporter for Ironic Hardware Sensor data +description-file = README.rst +author = OpenStack +author-email = openstack-discuss@lists.openstack.org +home-page = https://opendev.org/openstack/ironic-prometheus-exporter +license = Apache-2 +classifier = + Environment :: Console + Environment :: OpenStack + Intended Audience :: System Administrators + Intended Audience :: Information Technology + License :: OSI Approved :: Apache Software License + Operating System :: OS Independent + Programming Language :: Python + Programming Language :: Python :: 2 + Programming Language :: Python :: 2.7 + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + +[entry_points] +oslo.messaging.notify.drivers = + prometheus_exporter = ironic_prometheus_exporter.messaging:PrometheusFileDriver + file_exporter = ironic_prometheus_exporter.messaging:SimpleFileDriver diff --git a/setup.py b/setup.py index 6ffa4f7..566d844 100644 --- a/setup.py +++ b/setup.py @@ -1,49 +1,29 @@ -import re +# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. -from setuptools import setup, find_packages +# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT +import setuptools +# In python < 2.7.4, a lazy loading of package `pbr` will break +# setuptools if some other modules registered functions in `atexit`. +# solution from: http://bugs.python.org/issue15881#msg170215 +try: + import multiprocessing # noqa +except ImportError: + pass -def parse_requirements(file_name): - requirements = [] - for line in open(file_name, 'r').read().split('\n'): - if re.match(r'(\s*#)|(\s*$)', line): - continue - if re.match(r'\s*-e\s+', line): - requirements.append(re.sub(r'\s*-e\s+.*#egg=(.*)$', r'\1', line)) - elif re.match(r'\s*-f\s+', line): - pass - else: - requirements.append(line) - - return requirements - - -setup( - name='ironic_prometheus_exporter', - version='1.0.0', - description='Prometheus Exporter for Ironic Hardware Sensor data', - url='', - author='Iury Gregory Melo Ferreira', - author_email='imelofer@redhat.com', - license='Apache 2.0', - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Intended Audience :: Developers', - 'Intended Audience :: Information Technology', - 'License :: OSI Approved :: Apache Software License', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', - ], - packages=find_packages(), - install_requires=parse_requirements('requirements.txt'), - entry_points={ - 'oslo.messaging.notify.drivers': [ - 'prometheus_exporter=\ - ironic_prometheus_exporter.messaging:PrometheusFileDriver', - 'file_exporter=\ - ironic_prometheus_exporter.messaging:SimpleFileDriver', - ], - }, -) +setuptools.setup( + setup_requires=['pbr>=2.0.0'], + pbr=True) diff --git a/verify_installation.py b/verify_installation.py deleted file mode 100644 index f3e0105..0000000 --- a/verify_installation.py +++ /dev/null @@ -1,13 +0,0 @@ -import stevedore - -driver_list = stevedore.ExtensionManager( - 'oslo.messaging.notify.drivers', - invoke_on_load=False, - propagate_map_exceptions=True -) - -if 'prometheus_exporter' in driver_list.names(): - print('prometheus_exporter driver found.') -else: - print('prometheus_exporter driver not found.') - print('Available drivers: %s' % driver_list.names())