{"id":15070045,"url":"https://github.com/aborgt/pylertalertmanager","last_synced_at":"2025-04-05T06:04:59.946Z","repository":{"id":62581336,"uuid":"130286249","full_name":"ABORGT/PylertAlertManager","owner":"ABORGT","description":"A python library for prometheus's alertmanager","archived":false,"fork":false,"pushed_at":"2024-09-30T22:37:39.000Z","size":87,"stargazers_count":34,"open_issues_count":7,"forks_count":16,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-05T06:04:48.822Z","etag":null,"topics":["alertmanager","kuberenetes-alertmanager","prometheus","prometheus-alerts","python","python2","python3"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ABORGT.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-20T00:16:53.000Z","updated_at":"2024-09-30T22:37:43.000Z","dependencies_parsed_at":"2024-05-16T00:03:43.101Z","dependency_job_id":"b77f14dc-09bb-4774-af17-81a6d792db41","html_url":"https://github.com/ABORGT/PylertAlertManager","commit_stats":{"total_commits":52,"total_committers":10,"mean_commits":5.2,"dds":0.6923076923076923,"last_synced_commit":"4add45ea252452eb898a834d2f47a796a02d8bf0"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ABORGT%2FPylertAlertManager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ABORGT%2FPylertAlertManager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ABORGT%2FPylertAlertManager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ABORGT%2FPylertAlertManager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ABORGT","download_url":"https://codeload.github.com/ABORGT/PylertAlertManager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247294538,"owners_count":20915340,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alertmanager","kuberenetes-alertmanager","prometheus","prometheus-alerts","python","python2","python3"],"created_at":"2024-09-25T01:46:43.943Z","updated_at":"2025-04-05T06:04:59.930Z","avatar_url":"https://github.com/ABORGT.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PylertAlertManager\n\nPylertAlertManager aims to be an easy-to-use interface for interacting with the Alert Manager API.\n\n\n### Getting Started\n\nThe latest stable release is available from PyPI:\n\n```\npip install pylertalertmanager\n```\n\nOtherwise you can install from git:\n\n```\npip install git+https://github.com/ABORGT/PylertAlertManager.git\n```\n\n### Usage\nHere we cover some basic usage examples to get folks off and running. We are importing json here just to pretty print our objects. Additionally, we have an Alert Manager instance running in docker to target.\n```python\n\u003e\u003e\u003e import json\n\u003e\u003e\u003e from alertmanager import AlertManager\n\u003e\u003e\u003e from alertmanager import Alert\n\u003e\u003e\u003e\n\u003e\u003e\u003e # Provide some test data to be converted into an Alert object.\n\u003e\u003e\u003e test_data = {\n...     \"labels\": {\n...         \"alertname\": \"TestAlert\",\n...         \"instance\": \"TestInstance\",\n...         \"severity\": \"critical\"\n...     },\n...     \"annotations\": {\n...         \"description\": \"This is a test alert\",\n...         \"info\": \"Test Alert\",\n...         \"summary\": \"A simple Test alert\"\n...     }\n... }\n\u003e\u003e\u003e# Run the from_dict method on our test_data.\n\u003e\u003e\u003e test_alert = Alert.from_dict(test_data)\n\u003e\u003e\u003e type(test_alert)\n\u003cclass 'alertmanager.alertmanager.Alert'\u003e\n\u003e\u003e\u003e\n\u003e\u003e\u003e # Add an annotation with the add_annotation method.\n\u003e\u003e\u003e test_alert.add_annotation('test_annotation', 'this is a test annotation')\n\u003e\u003e\u003e print(json.dumps(test_alert, indent=4))\n{\n    \"labels\": {\n        \"alertname\": \"TestAlert\",\n        \"instance\": \"TestInstance\",\n        \"severity\": \"critical\"\n    },\n    \"annotations\": {\n        \"description\": \"This is a test alert\",\n        \"info\": \"Test Alert\",\n        \"summary\": \"A simple Test alert\",\n        \"test_annotation\": \"this is a test annotation\"\n    }\n}\n\u003e\u003e\u003e # Add a label with the add_label method.\n\u003e\u003e\u003e test_alert.add_label('test_label', 'this is a test label')\n\u003e\u003e\u003e print(json.dumps(test_alert, indent=4))\n{\n    \"labels\": {\n        \"alertname\": \"TestAlert\",\n        \"instance\": \"TestInstance\",\n        \"severity\": \"critical\",\n        \"test_label\": \"this is a test label\"\n    },\n    \"annotations\": {\n        \"description\": \"This is a test alert\",\n        \"info\": \"Test Alert\",\n        \"summary\": \"A simple Test alert\",\n        \"test_annotation\": \"this is a test annotation\"\n    }\n}\n\u003e\u003e\u003e # Specify an Alert Manager host to connect to.\n\u003e\u003e\u003e host = 'http://127.0.0.1'\n\u003e\u003e\u003e a_manager = AlertManager(host=host)\n\u003e\u003e\u003e\n\u003e\u003e\u003e # Post an alert to our Alert Manager.\n\u003e\u003e\u003e a_manager.post_alerts(test_alert)\n\u003cBox: {'status': 'success'}\u003e\n\u003e\u003e\u003e # Return a list of alerts from our Alert Manager.\n\u003e\u003e\u003e alerts = a_manager.get_alerts()\n\u003e\u003e\u003e print(json.dumps(alerts, indent=4))\n[\n    {\n        \"labels\": {\n            \"alertname\": \"TestAlert\",\n            \"instance\": \"TestInstance\",\n            \"severity\": \"critical\",\n            \"test_label\": \"this is a test label\"\n        },\n        \"annotations\": {\n            \"description\": \"This is a test alert\",\n            \"info\": \"Test Alert\",\n            \"summary\": \"A simple Test alert\",\n            \"test_annotation\": \"this is a test annotation\"\n        },\n        \"startsAt\": \"2018-11-08T16:25:02.327027475Z\",\n        \"endsAt\": \"2018-11-08T16:30:02.327027475Z\",\n        \"generatorURL\": \"\",\n        \"status\": {\n            \"state\": \"unprocessed\",\n            \"silencedBy\": [],\n            \"inhibitedBy\": []\n        },\n        \"receivers\": [\n            \"team-X-mails\"\n        ],\n        \"fingerprint\": \"e6b119b9ce57e0c4\"\n    }\n]\n\n\u003e\u003e\u003e # Return a list of silences from our Alert Manager\n\u003e\u003e\u003e silences = alert_manager.get_silences()\n\u003e\u003e\u003e print(json.dumps(silences, indent=4))\n[\n    {\n        \"id\": \"ed21ca94-383a-4a04-b759-ed817c8a8029\",\n        \"matchers\": [\n            {\n                \"name\": \"foo\",\n                \"value\": \"bar\",\n                \"isRegex\": false\n            }\n        ],\n        \"startsAt\": \"2020-02-18T08:56:33.5429772Z\",\n        \"endsAt\": \"2020-02-18T09:08:01.206791Z\",\n        \"updatedAt\": \"2020-02-18T09:08:01.206791Z\",\n        \"createdBy\": \"\",\n        \"status\": {\n            \"state\": \"expired\"\n        }\n    }\n]\n\n\u003e\u003e\u003e # Filter our silences by matchers\n\u003e\u003e\u003e silences = alert_manager.get_silences(filter={\"foo\": \"bar\"})\n\u003e\u003e\u003e print(json.dumps(silences, indent=4))\n[\n    {\n        \"id\": \"ed21ca94-383a-4a04-b759-ed817c8a8029\",\n        \"matchers\": [\n            {\n                \"name\": \"foo\",\n                \"value\": \"bar\",\n                \"isRegex\": false\n            }\n        ],\n        \"startsAt\": \"2020-02-18T08:56:33.5429772Z\",\n        \"endsAt\": \"2020-02-18T09:08:01.206791Z\",\n        \"updatedAt\": \"2020-02-18T09:08:01.206791Z\",\n        \"createdBy\": \"\",\n        \"status\": {\n            \"state\": \"expired\"\n        }\n    }\n]\n\n\n```\n## Running the tests\n\nTODO: Add tests\n\n## Contributing\n1. Fork it.\n2. Create a branch describing either the issue or feature you're working.\n3. Making changes, committing along the way.\n4. Follow PEP8, except where ridiculous.\n5. Include tests for any functionality changes.\n6. Push the changes and create a pull request :D.\n\n## Built With\n\n* [Python3](https://www.python.org/downloads/) - Beautiful language.\n\n## Authors\n\n* **Tyler Coil** - [Other Projects](https://github.com/kamori)\n* **Justin Palmer** - [Other Projects](https://github.com/jpavlav)\n\n## Acknowledgments\n\n* Kenneth Reitz -\u003e [setup](https://github.com/kennethreitz/setup.py) - Thanks!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faborgt%2Fpylertalertmanager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faborgt%2Fpylertalertmanager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faborgt%2Fpylertalertmanager/lists"}