Skip to main content

PyConvertAlert

PyConvertAlert makes it easy to take an arbitrary alert from some kind of alerting system (Uptime Robot, Rackspace Intelligence) and convert it into an Alert Manager (Prometheus) alert.

Getting Started

The latest stable release is available from PyPI:

pip install pyconvertalert

Otherwise you can install from git:

pip install git+https://github.com/jpavlav/PyConvertAlert

Usage

>>> from pyconvertalert import Converter
>>>
>>> test_lookup_dict_1 = {
...     "values": [
...         {
...             "people": [
...                 {
...                     "email": "jim@jim.com",
...                     "phone": "111-111-1111"
...                 }
...             ]
...         }
...     ]
... }
>>>
>>>
>>> test_mapper_dict_1 = {
...     "labels": {
...         "email_address": "email",
...         "phone_number": "phone"
...     }
... }
>>> convert = Converter(mapper=test_mapper_dict_1)
>>> convert.convert_it(test_lookup_dict_1)
{'labels': {'email_address': 'jim@jim.com', 'phone_number': '111-111-1111'}}

Further Usage

In some cases, there will be more than one key that matches a lookup. In this case, the value returned in our converted dict will be a list containing all of the values that match this key. In order to handle a situation where we need to be more specific, it is possible to specify a list of keys to drill down on a specific value. Here is an example:

>>> test_lookup_dict_2 = {
...     "flowers": [
...         {
...             "best_flower": {
...                 "name": "Orchid",
...                 "scientific_name": "Orchidaceae"
...             },
...             "wild_flower": {
...                 "name": "Gold Yarrow",
...                 "scientific_name": "Achillea filipendulinaa"
...             }
...         }
...     ]
... }
>>>
>>> test_mapper_dict_2 = {
...     "labels": {
...         "best_flower_name": ['best_flower', 'name'],
...         "best_flower_scientific_name": ['best_flower',
...                                         'scientific_name']
...     }
... }
>>>
>>>
>>> convert = Converter(mapper=test_mapper_dict_2)
>>> convert.convert_it(test_lookup_dict_2)
{'labels': {'best_flower_name': 'Orchid', 'best_flower_scientific_name': 'Orchidaceae'}}

Above, we see that we were able to get the 'best_flower' 'scientific_name' by specifying a list of keys to search through. We first return the value from the key 'best_flower', then return the value from the key 'name'.

Running the tests

Should be as simple as:

python -m unittest test_py_convert_alert.py

Contributing

  1. Fork it.
  2. Create a branch describing either the issue or feature you're working.
  3. Making changes, committing along the way.
  4. Follow PEP8, except where ridiculous.
  5. Include tests for any functionality changes.
  6. Push the changes and create a pull request :D.

Built With

Authors

  • Justin Palmer - Urrverything - Me

Acknowledgments

  • Kenneth Reitz -> setup - Thanks!
  • Kamori -> Cool Guy - Thanks to you as well!

Metadata

Release files for pyconvertalert 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyconvertalert 0.1.1
File Size Uploaded Provenance
pyconvertalert-0.1.1.tar.gz 6.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pyconvertalert 0.1.1
File Interpreter ABI Platform
pyconvertalert-0.1.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 13.8 kB

Release files / pyconvertalert-0.1.1.tar.gz

Download URL pyconvertalert-0.1.1.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d2801513fd94986b2eaeaa31c16c31e8b9c491974f77725644bf3738efe38ffa
BLAKE2b-256 checksum
How to use checksums
722f6f19a0d7f04060e5123352f46d41ee1ea32c3486b3f6fd3b0926c3f46d87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5

Release files / pyconvertalert-0.1.1-py2.py3-none-any.whl

Download URL pyconvertalert-0.1.1-py2.py3-none-any.whl
Size 7.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
84e63de42f7e8b8e05c929c6d65b56d22a1a93097339ced7abc5fbed88dd4fda
BLAKE2b-256 checksum
How to use checksums
5b4a26b82a57f8207e635f53629cd434634c02fb04fc6b5d0d34ca54a916f900
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5

Security for pyconvertalert 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page