Skip to main content

Alerta unified command-line tool and SDK

Project description

Alerta Command-Line Tool

Actions Status Slack chat Coverage Status

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

screen shot

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-2024 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.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alerta-8.5.3.tar.gz (48.1 kB view details)

Uploaded Source

Built Distribution

alerta-8.5.3-py2.py3-none-any.whl (70.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file alerta-8.5.3.tar.gz.

File metadata

  • Download URL: alerta-8.5.3.tar.gz
  • Upload date:
  • Size: 48.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.9

File hashes

Hashes for alerta-8.5.3.tar.gz
Algorithm Hash digest
SHA256 78fbd3da272c82ffa2a396830d4af56617e8766e3096a87f8aa5ed3641614b5d
MD5 e5c9f4354b1e7a0f8fa3c56224440be9
BLAKE2b-256 8b7c9e68da39e85c7ecf0d355f72f4d33a49cf018fc859dab168af1f4e4f9ac1

See more details on using hashes here.

File details

Details for the file alerta-8.5.3-py2.py3-none-any.whl.

File metadata

  • Download URL: alerta-8.5.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 70.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.9

File hashes

Hashes for alerta-8.5.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fca2f2cd3f6d8cf68160767ef9f3b56222c7aced44658de365cde7e808fddddc
MD5 1f9ac56299ad1d36a9c39ca7b690aa62
BLAKE2b-256 afdc05cbacda0466ec1415ed13c0e2780908870ab2d51aae16b7f41a5fa40ab4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page