alerta


Namealerta JSON
Version 8.5.0 PyPI version JSON
download
home_pagehttps://github.com/guardian/python-alerta
SummaryAlerta unified command-line tool and SDK
upload_time2021-04-18 20:09:10
maintainer
docs_urlNone
authorNick Satterly
requires_python>=3.6
licenseApache License 2.0
keywords alerta client unified command line tool sdk
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Alerta Command-Line Tool
========================

[![Actions Status](https://github.com/alerta/python-alerta-client/workflows/CI%20Tests/badge.svg)](https://github.com/alerta/python-alerta-client/actions)
 [![Slack chat](https://img.shields.io/badge/chat-on%20slack-blue?logo=slack)](https://slack.alerta.dev) [![Coverage Status](https://coveralls.io/repos/github/alerta/python-alerta-client/badge.svg?branch=master)](https://coveralls.io/github/alerta/python-alerta-client?branch=master)

Unified command-line tool, terminal GUI and python SDK for the Alerta monitoring system.

![screen shot](/docs/images/alerta-top-80x25.png?raw=true&v=1)

Related projects can be found on the Alerta Org Repo at <https://github.com/alerta/>.

Installation
------------

To install the Alerta CLI tool run::

    $ pip install alerta

Configuration
-------------

Options can be set in a configuration file, as environment variables or on the command line.
Profiles can be used to easily switch between different configuration settings.

| Option            | Config File | Environment Variable       | Optional Argument               | Default                   |
|-------------------|-------------|----------------------------|---------------------------------|---------------------------|
| file              | n/a         | ``ALERTA_CONF_FILE``       | n/a                             | ``~/.alerta.conf``        |
| profile           | profile     | ``ALERTA_DEFAULT_PROFILE`` | ``--profile PROFILE``           | None                      |
| endpoint          | endpoint    | ``ALERTA_ENDPOINT``        | ``--endpoint-url URL``          | ``http://localhost:8080`` |
| key               | key         | ``ALERTA_API_KEY``         | n/a                             | None                      |
| timezone          | timezone    | n/a                        | n/a                             | Europe/London             |
| SSL verify        | sslverify   | ``REQUESTS_CA_BUNDLE``     | n/a                             | verify SSL certificates   |
| SSL client cert   | sslcert     | n/a                        | n/a                             | None                      |
| SSL client key    | sslkey      | n/a                        | n/a                             | None                      |
| timeout           | timeout     | n/a                        | n/a                             | 5s TCP connection timeout |
| output            | output      | n/a                        | ``--output-format OUTPUT``      | simple                    |
| color             | color       | ``CLICOLOR``               | ``--color``, ``--no-color``     | color on                  |
| debug             | debug       | ``DEBUG``                  | ``--debug``                     | no debug                  |

Example
-------

Configuration file ``~/.alerta.conf``::

    [DEFAULT]
    timezone = Australia/Sydney
    # output = psql
    profile = production

    [profile production]
    endpoint = https://api.alerta.io
    key = demo-key

    [profile development]
    endpoint = https://localhost:8443
    sslverify = off
    timeout = 10.0
    debug = yes

Environment Variables
---------------------

Set environment variables to use production configuration settings by default::

    $ export ALERTA_CONF_FILE=~/.alerta.conf
    $ export ALERTA_DEFAULT_PROFILE=production

    $ alerta query

And to switch to development configuration settings when required use the ``--profile`` option::

    $ alerta --profile development query

Usage
-----

    $ alerta
    Usage: alerta [OPTIONS] COMMAND [ARGS]...

      Alerta client unified command-line tool.

    Options:
      --config-file <FILE>      Configuration file.
      --profile <PROFILE>       Configuration profile.
      --endpoint-url <URL>      API endpoint URL.
      --output-format <FORMAT>  Output format. eg. simple, grid, psql, presto, rst
      --color / --no-color      Color-coded output based on severity.
      --debug                   Debug mode.
      --help                    Show this message and exit.

    Commands:
      ack         Acknowledge alerts
      blackout    Suppress alerts
      blackouts   List alert suppressions
      close       Close alerts
      customer    Add customer lookup
      customers   List customer lookups
      delete      Delete alerts
      heartbeat   Send a heartbeat
      heartbeats  List heartbeats
      help        Show this help
      history     Show alert history
      key         Create API key
      keys        List API keys
      login       Login with user credentials
      logout      Clear login credentials
      perm        Add role-permission lookup
      perms       List role-permission lookups
      query       Search for alerts
      raw         Show alert raw data
      revoke      Revoke API key
      send        Send an alert
      status      Display status and metrics
      tag         Tag alerts
      token       Display current auth token
      unack       Un-acknowledge alerts
      untag       Untag alerts
      update      Update alert attributes
      uptime      Display server uptime
      user        Update user
      users       List users
      version     Display version info
      whoami      Display current logged in user

Python SDK
==========

The alerta client python package can also be used as a Python SDK.

Example
-------

    >>> from alertaclient.api import Client

    >>> client = Client(key='NGLxwf3f4-8LlYN4qLjVEagUPsysn0kb9fAkAs1l')
    >>> client.send_alert(environment='Production', service=['Web', 'Application'], resource='web01', event='HttpServerError', value='501', text='Web server unavailable.')
    Alert(id='42254ef8-7258-4300-aaec-a9ad7d3a84ff', environment='Production', resource='web01', event='HttpServerError', severity='normal', status='closed', customer=None)

    >>> [a.id for a in client.search([('resource','~we.*01'), ('environment!', 'Development')])]
    ['42254ef8-7258-4300-aaec-a9ad7d3a84ff']

    >>> client.heartbeat().serialize()['status']
    'ok'

License
-------

    Alerta monitoring system and console
    Copyright 2012-2020 Nick Satterly

    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.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/guardian/python-alerta",
    "name": "alerta",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "alerta client unified command line tool sdk",
    "author": "Nick Satterly",
    "author_email": "nick.satterly@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/58/09/41849fd6c71050fbe6069f3b494cc4dedeaee62af60b8a5091ae6b025e5b/alerta-8.5.0.tar.gz",
    "platform": "",
    "description": "Alerta Command-Line Tool\n========================\n\n[![Actions Status](https://github.com/alerta/python-alerta-client/workflows/CI%20Tests/badge.svg)](https://github.com/alerta/python-alerta-client/actions)\n [![Slack chat](https://img.shields.io/badge/chat-on%20slack-blue?logo=slack)](https://slack.alerta.dev) [![Coverage Status](https://coveralls.io/repos/github/alerta/python-alerta-client/badge.svg?branch=master)](https://coveralls.io/github/alerta/python-alerta-client?branch=master)\n\nUnified command-line tool, terminal GUI and python SDK for the Alerta monitoring system.\n\n![screen shot](/docs/images/alerta-top-80x25.png?raw=true&v=1)\n\nRelated projects can be found on the Alerta Org Repo at <https://github.com/alerta/>.\n\nInstallation\n------------\n\nTo install the Alerta CLI tool run::\n\n    $ pip install alerta\n\nConfiguration\n-------------\n\nOptions can be set in a configuration file, as environment variables or on the command line.\nProfiles can be used to easily switch between different configuration settings.\n\n| Option            | Config File | Environment Variable       | Optional Argument               | Default                   |\n|-------------------|-------------|----------------------------|---------------------------------|---------------------------|\n| file              | n/a         | ``ALERTA_CONF_FILE``       | n/a                             | ``~/.alerta.conf``        |\n| profile           | profile     | ``ALERTA_DEFAULT_PROFILE`` | ``--profile PROFILE``           | None                      |\n| endpoint          | endpoint    | ``ALERTA_ENDPOINT``        | ``--endpoint-url URL``          | ``http://localhost:8080`` |\n| key               | key         | ``ALERTA_API_KEY``         | n/a                             | None                      |\n| timezone          | timezone    | n/a                        | n/a                             | Europe/London             |\n| SSL verify        | sslverify   | ``REQUESTS_CA_BUNDLE``     | n/a                             | verify SSL certificates   |\n| SSL client cert   | sslcert     | n/a                        | n/a                             | None                      |\n| SSL client key    | sslkey      | n/a                        | n/a                             | None                      |\n| timeout           | timeout     | n/a                        | n/a                             | 5s TCP connection timeout |\n| output            | output      | n/a                        | ``--output-format OUTPUT``      | simple                    |\n| color             | color       | ``CLICOLOR``               | ``--color``, ``--no-color``     | color on                  |\n| debug             | debug       | ``DEBUG``                  | ``--debug``                     | no debug                  |\n\nExample\n-------\n\nConfiguration file ``~/.alerta.conf``::\n\n    [DEFAULT]\n    timezone = Australia/Sydney\n    # output = psql\n    profile = production\n\n    [profile production]\n    endpoint = https://api.alerta.io\n    key = demo-key\n\n    [profile development]\n    endpoint = https://localhost:8443\n    sslverify = off\n    timeout = 10.0\n    debug = yes\n\nEnvironment Variables\n---------------------\n\nSet environment variables to use production configuration settings by default::\n\n    $ export ALERTA_CONF_FILE=~/.alerta.conf\n    $ export ALERTA_DEFAULT_PROFILE=production\n\n    $ alerta query\n\nAnd to switch to development configuration settings when required use the ``--profile`` option::\n\n    $ alerta --profile development query\n\nUsage\n-----\n\n    $ alerta\n    Usage: alerta [OPTIONS] COMMAND [ARGS]...\n\n      Alerta client unified command-line tool.\n\n    Options:\n      --config-file <FILE>      Configuration file.\n      --profile <PROFILE>       Configuration profile.\n      --endpoint-url <URL>      API endpoint URL.\n      --output-format <FORMAT>  Output format. eg. simple, grid, psql, presto, rst\n      --color / --no-color      Color-coded output based on severity.\n      --debug                   Debug mode.\n      --help                    Show this message and exit.\n\n    Commands:\n      ack         Acknowledge alerts\n      blackout    Suppress alerts\n      blackouts   List alert suppressions\n      close       Close alerts\n      customer    Add customer lookup\n      customers   List customer lookups\n      delete      Delete alerts\n      heartbeat   Send a heartbeat\n      heartbeats  List heartbeats\n      help        Show this help\n      history     Show alert history\n      key         Create API key\n      keys        List API keys\n      login       Login with user credentials\n      logout      Clear login credentials\n      perm        Add role-permission lookup\n      perms       List role-permission lookups\n      query       Search for alerts\n      raw         Show alert raw data\n      revoke      Revoke API key\n      send        Send an alert\n      status      Display status and metrics\n      tag         Tag alerts\n      token       Display current auth token\n      unack       Un-acknowledge alerts\n      untag       Untag alerts\n      update      Update alert attributes\n      uptime      Display server uptime\n      user        Update user\n      users       List users\n      version     Display version info\n      whoami      Display current logged in user\n\nPython SDK\n==========\n\nThe alerta client python package can also be used as a Python SDK.\n\nExample\n-------\n\n    >>> from alertaclient.api import Client\n\n    >>> client = Client(key='NGLxwf3f4-8LlYN4qLjVEagUPsysn0kb9fAkAs1l')\n    >>> client.send_alert(environment='Production', service=['Web', 'Application'], resource='web01', event='HttpServerError', value='501', text='Web server unavailable.')\n    Alert(id='42254ef8-7258-4300-aaec-a9ad7d3a84ff', environment='Production', resource='web01', event='HttpServerError', severity='normal', status='closed', customer=None)\n\n    >>> [a.id for a in client.search([('resource','~we.*01'), ('environment!', 'Development')])]\n    ['42254ef8-7258-4300-aaec-a9ad7d3a84ff']\n\n    >>> client.heartbeat().serialize()['status']\n    'ok'\n\nLicense\n-------\n\n    Alerta monitoring system and console\n    Copyright 2012-2020 Nick Satterly\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n        http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "Alerta unified command-line tool and SDK",
    "version": "8.5.0",
    "split_keywords": [
        "alerta",
        "client",
        "unified",
        "command",
        "line",
        "tool",
        "sdk"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "5ddd57cd37955ae40d15a0079bc4a7b1",
                "sha256": "e9a511d0b1204be2955bbf1fa199d9a50aa031f84267703ffe13362d6a27e84a"
            },
            "downloads": -1,
            "filename": "alerta-8.5.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5ddd57cd37955ae40d15a0079bc4a7b1",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.6",
            "size": 87387,
            "upload_time": "2021-04-18T20:09:05",
            "upload_time_iso_8601": "2021-04-18T20:09:05.946248Z",
            "url": "https://files.pythonhosted.org/packages/ce/b5/fd50850a001e3c7e5f2e6aa3e73c16f00e11661baed8709b7c34fc5538f7/alerta-8.5.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "6bb9f04610a438b665e9b72e1a1237f7",
                "sha256": "628be2d4aee12c50b1c43bd685c06a15a498cbef33ca9cc970daaf34dfee029b"
            },
            "downloads": -1,
            "filename": "alerta-8.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "6bb9f04610a438b665e9b72e1a1237f7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 48199,
            "upload_time": "2021-04-18T20:09:10",
            "upload_time_iso_8601": "2021-04-18T20:09:10.257416Z",
            "url": "https://files.pythonhosted.org/packages/58/09/41849fd6c71050fbe6069f3b494cc4dedeaee62af60b8a5091ae6b025e5b/alerta-8.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-04-18 20:09:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "guardian",
    "error": "Could not fetch GitHub repository",
    "lcname": "alerta"
}
        
Elapsed time: 0.29458s