Git Product home page Git Product logo

opsdis / monitor-exporter Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 4.0 131 KB

The monitor-exporter utilize OP5 Monitors API to fetch service based performance data and publish it in a way that lets prometheus scrape the performance data as metrics.

Home Page: https://www.opsdis.com

License: GNU General Public License v3.0

Python 99.30% Dockerfile 0.70%
monitor-exporter op5-monitor prometheus grafana

monitor-exporter's People

Contributors

fiddeb avatar lukegee avatar mike1356 avatar thenodon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

monitor-exporter's Issues

Adding in a Grafana Dashboard to Display Acquired Metrics.

In an effort to enhance my monitoring setup, I am seeking assistance in creating a Grafana dashboard template specifically tailored to display the Prometheus metrics collected using this script. I believe this would not only benefit me but also the broader community.

Thank you for considering this request, and I look forward to collaborating with the community on this exciting project!

Possible bug related to get_perfdata_value_unit

Possible typo on line 205 causing exception:

Apr 25 09:13:31 xx python[26934]: Traceback (most recent call last):
Apr 25 09:13:31 xx python[26934]: File "/opt/tcs/venv/lib/python3.9/site-packages/quart/app.py", line 1489, in handle_request
Apr 25 09:13:31 xx python[26934]: return await self.full_dispatch_request(request_context)
Apr 25 09:13:31 xx python[26934]: File "/opt/tcs/venv/lib/python3.9/site-packages/quart/app.py", line 1514, in full_dispatch_request
Apr 25 09:13:31 xx python[26934]: result = await self.handle_user_exception(error)
Apr 25 09:13:31 xx python[26934]: File "/opt/tcs/venv/lib/python3.9/site-packages/quart/app.py", line 964, in handle_user_exception
Apr 25 09:13:31 xx python[26934]: raise error
Apr 25 09:13:31 xx python[26934]: File "/opt/tcs/venv/lib/python3.9/site-packages/quart/app.py", line 1512, in full_dispatch_request
Apr 25 09:13:31 xx python[26934]: result = await self.dispatch_request(request_context)
Apr 25 09:13:31 xx python[26934]: File "/opt/tcs/venv/lib/python3.9/site-packages/quart/app.py", line 1557, in dispatch_request
Apr 25 09:13:31 xx python[26934]: return await self.ensure_async(handler)(**request_.view_args)
Apr 25 09:13:31 xx python[26934]: File "/opt/tcs/monitor-exporter/monitor_exporter/proxy.py", line 49, in get_metrics
Apr 25 09:13:31 xx python[26934]: await asyncio.get_event_loop().create_task(monitor_data.get_perfdata())
Apr 25 09:13:31 xx python[26934]: File "/opt/tcs/monitor-exporter/monitor_exporter/perfdata.py", line 146, in get_perfdata
Apr 25 09:13:31 xx python[26934]: normilized_value, prometheus_key_with_labels = self.create_metric(check_command, labels,
Apr 25 09:13:31 xx python[26934]: File "/opt/tcs/monitor-exporter/monitor_exporter/perfdata.py", line 171, in create_metric
Apr 25 09:13:31 xx python[26934]: perf_unit, perf_value, perf_warn, perf_crit = Perfdata.get_perfdata_value_unit(perf_data_value)
Apr 25 09:13:31 xx python[26934]: File "/opt/tcs/monitor-exporter/monitor_exporter/perfdata.py", line 205, in get_perfdata_value_unit
Apr 25 09:13:31 xx python[26934]: perf_crit = value['warn']
Apr 25 09:13:31 xx python[26934]: KeyError: 'warn'

Should be perf_crit = value['crit'] ?

perf_crit = value['warn']

Exception if perfdata contains a unit but the value is an empty string

[2022-04-26 13:58:06,783] ERROR in app: Exception on request GET /metrics
Traceback (most recent call last):
File "/home/mike/.local/lib/python3.9/site-packages/quart/app.py", line 1489, in handle_request
return await self.full_dispatch_request(request_context)
File "/home/mike/.local/lib/python3.9/site-packages/quart/app.py", line 1514, in full_dispatch_request
result = await self.handle_user_exception(error)
File "/home/mike/.local/lib/python3.9/site-packages/quart/app.py", line 964, in handle_user_exception
raise error
File "/home/mike/.local/lib/python3.9/site-packages/quart/app.py", line 1512, in full_dispatch_request
result = await self.dispatch_request(request_context)
File "/home/mike/.local/lib/python3.9/site-packages/quart/app.py", line 1557, in dispatch_request
return await self.ensure_async(handler)(**request_.view_args)
File "/home/mike/monitor-exporter-1.2.0/monitor_exporter/proxy.py", line 49, in get_metrics
await asyncio.get_event_loop().create_task(monitor_data.get_perfdata())
File "/home/mike/monitor-exporter-1.2.0/monitor_exporter/perfdata.py", line 147, in get_perfdata
normilized_value, prometheus_key_with_labels = self.create_metric(check_command, labels,
File "/home/mike/monitor-exporter-1.2.0/monitor_exporter/perfdata.py", line 174, in create_metric
normilized_value, unit = Perfdata.normalize_to_unit(perf_value, perf_unit)
File "/home/mike/monitor-exporter-1.2.0/monitor_exporter/perfdata.py", line 279, in normalize_to_unit
return value / 1000.0, 'seconds'
TypeError: unsupported operand type(s) for /: 'str' and 'float'

I added 2 rows at the top of normalize_to_unit in monitor_exporter/perfdata.py. Might be better to return the value None or 0 than ''?

def normalize_to_unit(value, unit):
    """Normalize the value to the unit returned.
    We use base-1000 for second-based units, and base-1024 for
    byte-based units. Sadly, the Nagios-Plugins specification doesn't
    disambiguate base-1000 (KB) and base-1024 (KiB).
    """

-> if value == '':
-> return value, ''
if unit == '%':
return value / 100, 'ratio'

The log level setting in config.yml doesn't affect uvicorn

Log level is set to level: WARNING in config.yml but uvicorn.acces is still logging at the INFO level. We get more than 2k rows every minute.
{"timestamp": "2022-04-29T07:16:14.912731Z", "level": "INFO", "name": "uvicorn.access", "message": "127.0.0.1:46514 - "GET /metrics?target=*** HTTP/1.1" 200"}

Requirement uvicorn is missing in requirements.txt

gunicorn --access-logfile /dev/null -w 4 -k uvicorn.workers.UvicornWorker "wsgi:create_app('./config.yml')"

Error: class uri 'uvicorn.workers.UvicornWorker' invalid or not found:

[Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gunicorn/util.py", line 135, in load_class
    mod = import_module('.'.join(components))
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'uvicorn'
]

50 service limit per host

When used in a system with OP5 monitor, only the first 50 services of a particular host are available at the /metrics endpoint.

To reproduce: Add more than 50 services to a host in monitor, then access /metrics?target=somehostname and compare the amount of unique service labels to the amount of services connected to that host in monitor.

OP5 monitor version: 7.3.17
monitor-exporter version: 0.0.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.