### Install MongoDB Source: https://github.com/alerta/alerta-docs/blob/master/source/quick-start.md Installs MongoDB on Debian/Ubuntu systems and starts the MongoDB service. Ensure MongoDB is running before proceeding with Alerta installation. ```bash $ sudo apt-get install -y mongodb-org $ sudo mongod -f /etc/mongod.conf & ``` -------------------------------- ### Install Dependencies and Serve Docs Locally Source: https://github.com/alerta/alerta-docs/blob/master/README.md Install project dependencies and start a local web server to view the documentation. The website updates automatically on file changes. ```bash pip install -r requirements.txt make livehtml >> browse to http://localhost:8000 ``` -------------------------------- ### Example Request to List API Keys Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example using curl to send a GET request to list all API keys. ```bash $ curl http://localhost:8080/keys \ -H 'Authorization: Key demo-key' ``` -------------------------------- ### Install Alerta Server Source: https://github.com/alerta/alerta-docs/blob/master/source/quick-start.md Installs the Alerta server using pip and starts the server. The server will run on http://127.0.0.1:8080/ by default. ```bash $ pip3 install alerta-server $ alertad run --port 8080 ``` -------------------------------- ### Plugin Setup Script Source: https://github.com/alerta/alerta-docs/blob/master/source/gettingstarted/tutorial-3-plugins.md A standard `setup.py` file for packaging and installing an Alerta plugin using setuptools. It defines package metadata and registers the plugin using `entry_points`. ```python from setuptools import setup, find_packages version = '0.0.1' setup( name="alerta-transient", version=version, description='Example Alerta plugin for transient flapping alerts', url='https://github.com/alerta/alerta-contrib', license='Apache License 2.0', author='Your name', author_email='your.name@example.com', packages=find_packages(), py_modules=['alerta_transient'], install_requires=[], include_package_data=True, zip_safe=True, entry_points={ 'alerta.plugins': [ 'transient = alerta_transient:TransientAlert' ] } ) ``` -------------------------------- ### Example Request to Retrieve an API Key Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example using curl to send a GET request to retrieve a specific API key. ```bash $ curl http://localhost:8080/key/_Jwm-qaGa0kBM9R1CyyQn-0qxLtBtij4ToQf6beL \ -H 'Authorization: Key demo-key' ``` -------------------------------- ### Example Request to List Blackouts Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Demonstrates how to use curl to send a GET request to list all blackout periods. ```bash $ curl http://localhost:8080/blackouts \ -H 'Authorization: Key demo-key' ``` -------------------------------- ### Alerta Configuration File Example Source: https://github.com/alerta/alerta-docs/blob/master/source/cli.md Example of an Alerta configuration file showing default and profile-specific settings. ```ini [DEFAULT] timezone = Australia/Sydney output = json [profile development] endpoint = https://localhost:8443 key = demo-key sslverify = off timeout = 10.0 debug = yes ``` -------------------------------- ### Install Alerta CLI from Git repository Source: https://github.com/alerta/alerta-docs/blob/master/source/cli.md Install the Alerta client tool by cloning the git repository and using pip. ```bash $ git clone https://github.com/alerta/python-alerta-client.git $ cd python-alerta-client $ pip install . ``` -------------------------------- ### List All Users Example Request Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example cURL request to fetch all users. The Authorization header is mandatory. ```bash $ curl http://localhost:8080/users \ -H 'Authorization: Key demo-key' ``` -------------------------------- ### Install Routing Plugin Source: https://github.com/alerta/alerta-docs/blob/master/source/gettingstarted/tutorial-3-plugins.md Command to install the developed routing plugin. Ensure uWSGI is restarted after installation. ```bash $ sudo python setup.py install ``` -------------------------------- ### Alerta Management Properties Example Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example response showing WSGI and Werkzeug server properties. ```default 200 OK ``` ```default wsgi.version: (1, 0) wsgi.url_scheme: http wsgi.input: <_io.BufferedReader name=10> wsgi.errors: <_io.TextIOWrapper name='' mode='w' encoding='utf-8'> wsgi.multithread: True wsgi.multiprocess: False wsgi.run_once: False werkzeug.server.shutdown: .shutdown_server at 0x11232a430> werkzeug.socket: SERVER_SOFTWARE: Werkzeug/2.0.2 REQUEST_METHOD: GET SCRIPT_NAME: PATH_INFO: /management/properties ``` -------------------------------- ### Install Alerta Server and CLI Source: https://github.com/alerta/alerta-docs/blob/master/source/gettingstarted/tutorial-1-deploy-alerta.md Installs the Alerta server, command-line tool, and uWSGI into a Python 3 virtual environment located at /opt/alerta. ```bash cd /opt python3 -m venv alerta alerta/bin/pip install --upgrade pip wheel alerta-server alerta uwsgi pymongo ``` -------------------------------- ### Get management manifest response Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example response for the management manifest endpoint, showing build details. ```json { "build": "PROD", "date": "2021-11-22T23:46:52Z", "release": "8.6.2", "revision": "ecfe6ff2295ddc1a01be5aaeeef7dd9159fdfcf9" } ``` -------------------------------- ### Install Alerta Python SDK from GitHub Source: https://github.com/alerta/alerta-docs/blob/master/source/development.md Install the Alerta Python SDK directly from the master branch on GitHub. Use this for the latest development version. ```bash $ pip install git+https://github.com/alerta/python-alerta-client.git@master ``` -------------------------------- ### Install Alerta Python SDK Source: https://github.com/alerta/alerta-docs/blob/master/source/development.md Install the Alerta Python SDK using pip. This is the standard method for adding the client library to your project. ```bash $ pip install alerta ``` -------------------------------- ### Install Alerta CLI Source: https://github.com/alerta/alerta-docs/blob/master/source/quick-start.md Installs the Alerta command-line interface tool using pip. ```bash $ pip3 install alerta ``` -------------------------------- ### Example API Key Creation Response Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md This is an example of a successful response when creating a new API key. ```json { "data": { "count": 0, "customer": null, "expireTime": "2019-01-27T22:18:42.245Z", "href": "http://localhost:8080/key/_Jwm-qaGa0kBM9R1CyyQn-0qxLtBtij4ToQf6beL", "id": "ca931aec-4e56-496f-a8d6-be11d93ddaed", "key": "_Jwm-qaGa0kBM9R1CyyQn-0qxLtBtij4ToQf6beL", "lastUsedTime": null, "scopes": [ "write" ], "text": "API key for external system", "type": "read-write", "user": "admin@alerta.io" }, "key": "_Jwm-qaGa0kBM9R1CyyQn-0qxLtBtij4ToQf6beL", "status": "ok" } ``` -------------------------------- ### Show Help Information Source: https://github.com/alerta/alerta-docs/blob/master/source/cli.md Displays comprehensive help, including options, commands, and example filters. ```bash $ alerta help ``` -------------------------------- ### Example Request to Retrieve a Blackout Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Demonstrates how to use curl to send a GET request to fetch details of a specific blackout period using its ID. ```bash $ curl http://localhost:8080/blackout/79d12b79-45b9-4419-80e4-1f6c17478eb6 \ -H 'Authorization: Key demo-key' ``` -------------------------------- ### List All Groups Example Request Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example cURL request to list all available groups. The Authorization header is necessary. ```bash $ curl http://localhost:8080/groups \ -H 'Authorization: Key demo-key' ``` -------------------------------- ### Install nagios-alerta Package Source: https://github.com/alerta/alerta-docs/blob/master/source/gettingstarted/tutorial-8-integration-nagios.md Install the integration package on your Nagios server using pip. ```default $ pip install nagios-alerta ``` -------------------------------- ### List All Users Example Response Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example successful response when listing all users, showing user details and pagination information. ```json { "domains": [ "*" ], "groups": [ "*" ], "orgs": [ "*" ], "status": "ok", "time": "2017-01-02T00:24:00.393Z", "total": 2, "users": [ { "createTime": "2017-01-01T23:49:38.486Z", "email_verified": false, "id": "b91811e7-52dd-4a8f-adae-b4d5c628d6f8", "login": "jane.doe@example.org", "name": "Jane Doe", "provider": "basic", "role": "user", "text": "demo user" }, { "createTime": "2017-01-02T00:23:24.487Z", "email_verified": true, "id": "166b41d6-849f-440d-ba30-1a5345d86fb6", "login": "joe.bloggs@example.com", "name": "Joe Bloggs", "provider": "basic", "role": "user", "text": "demo user" } ] } ``` -------------------------------- ### Example Response Listing API Keys Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md This is an example of a successful response when listing API keys, showing details for multiple keys. ```json { "keys": [ { "count": 0, "customer": null, "expireTime": "2019-01-27T22:18:42.245Z", "href": "http://localhost:8080/key/_Jwm-qaGa0kBM9R1CyyQn-0qxLtBtij4ToQf6beL", "id": "ca931aec-4e56-496f-a8d6-be11d93ddaed", "key": "_Jwm-qaGa0kBM9R1CyyQn-0qxLtBtij4ToQf6beL", "lastUsedTime": null, "scopes": [ "write" ], "text": "API key for external system", "type": "read-write", "user": "admin@alerta.io" }, { "count": 21, "customer": null, "expireTime": "2019-01-27T19:22:27.120Z", "href": "http://localhost:8080/key/demo-key", "id": "532c9b59-9e90-40d4-8a3b-887362a79e9c", "key": "demo-key", "lastUsedTime": "2018-01-27T22:19:04.113Z", "scopes": [ "admin", "write", "read" ], "text": "Admin key created by alertad script", "type": "read-write", "user": "foo@foobar.com" } ], "status": "ok", "total": 2 } ``` -------------------------------- ### Example Request to Create an API Key Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example using curl to send a POST request to create an API key with specified user and scopes. ```bash $ curl -XPOST http://localhost:8080/key \ -H 'Authorization: Key demo-key' \ -H 'Content-type: application/json' \ -d '{ "user": "admin@alerta.io", "scopes": ["write"], "text": "API key for external system" }' ``` -------------------------------- ### Manage uWSGI Service Source: https://github.com/alerta/alerta-docs/blob/master/source/gettingstarted/tutorial-1-deploy-alerta.md Starts the uWSGI service, checks its status, and enables it to start automatically on system boot. ```console sudo systemctl start uwsgi sudo systemctl status uwsgi sudo systemctl enable uwsgi ``` -------------------------------- ### Install zabbix-alerta Package Source: https://github.com/alerta/alerta-docs/blob/master/source/gettingstarted/tutorial-8-integration-zabbix.md Install the zabbix-alerta integration package using pip. This command should be run on your Zabbix server. ```bash $ pip install zabbix-alerta ``` -------------------------------- ### Install python-ldap Package Source: https://github.com/alerta/alerta-docs/blob/master/source/authentication.md Installs the required python-ldap package for LDAP authentication. ```default $ pip install python-ldap ``` -------------------------------- ### Example API Response Tags Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md An example JSON response detailing tag counts and environments. ```json { "status": "ok", "tags": [ { "count": 2, "environment": "Production", "tag": "linux" }, { "count": 1, "environment": "Production", "tag": "dc2" }, { "count": 1, "environment": "Production", "tag": "hp" }, { "count": 2, "environment": "Production", "tag": "dell" }, { "count": 2, "environment": "Production", "tag": "dc1" }, { "count": 2, "environment": "Production", "tag": "linux2.6" } ], "total": 6 } ``` -------------------------------- ### Install MongoDB 4.0 Source: https://github.com/alerta/alerta-docs/blob/master/source/gettingstarted/tutorial-1-deploy-alerta.md Installs the MongoDB 4.0 repository and the MongoDB server package on Ubuntu. Ensure you have root privileges. ```bash sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4 echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list sudo apt-get update sudo apt-get install -y mongodb-org ``` -------------------------------- ### Create Permission Response Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example response for creating a permission, showing the assigned ID and details. ```json { "id": "40c2daee-1d77-44d5-b62d-e3e446396cef", "permission": { "id": "40c2daee-1d77-44d5-b62d-e3e446396cef", "match": "alerta_ops", "scopes": [ "read", "write", "admin:keys" ] }, "status": "ok" } ``` -------------------------------- ### Install Python 3 Dependencies Source: https://github.com/alerta/alerta-docs/blob/master/source/gettingstarted/tutorial-1-deploy-alerta.md Installs essential Python 3 packages required for Alerta, including pip, setuptools, and development headers. ```bash sudo apt-get install -y python3 python3-setuptools python3-pip python3-dev python3-venv sudo apt-get install -y nginx uwsgi-plugin-python3 ``` -------------------------------- ### Example Response for Environments Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md This JSON structure shows the response for listing environments, detailing each environment and its alert count. ```json { "environments": [ { "count": 2, "environment": "Production" } ], "status": "ok", "total": 1 } ``` -------------------------------- ### Install Alerta Web UI Source: https://github.com/alerta/alerta-docs/blob/master/source/gettingstarted/tutorial-1-deploy-alerta.md Downloads and extracts the latest Alerta web UI release to the /var/www/html directory. ```bash wget https://github.com/alerta/alerta-webui/releases/latest/download/alerta-webui.tar.gz tar zxvf alerta-webui.tar.gz cp -a dist /var/www/html ``` -------------------------------- ### Create Customer Response Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example response for creating a customer, showing the assigned ID and details. ```json { "customer": { "customer": "Example Corp.", "id": "289ca657-ea2c-4775-9e07-cc96844cc717", "match": "example.com" }, "id": "289ca657-ea2c-4775-9e07-cc96844cc717", "status": "ok" } ``` -------------------------------- ### Check Installed Python Packages Source: https://github.com/alerta/alerta-docs/blob/master/source/gettingstarted/tutorial-9-troubleshooting.md Use 'pip list' and grep to verify that required Alerta plugins are installed in the Python environment. ```default $ pip list | grep alerta ``` -------------------------------- ### Install PySAML2 for SAML 2.0 Authentication Source: https://github.com/alerta/alerta-docs/blob/master/source/authentication.md Install the PySAML2 library on the Alerta server to enable SAML 2.0 authentication. This is a prerequisite for configuring SAML. ```bash pip install PySAML2 ``` -------------------------------- ### List User Groups Example Request Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example cURL request to list groups for a given user ID. Ensure the Authorization header is included. ```bash $ curl http://localhost:8080/user/0a35bfd8-1175-4cd2-96f6-eda9861fd15d/groups \ -H 'Authorization: Key demo-key' ``` -------------------------------- ### Curl Request for Environments Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example cURL command to list all environments, including an authorization header. ```bash $ curl http://localhost:8080/environments \ -H 'Authorization: Key demo-key' ``` -------------------------------- ### Build and Deploy Documentation Source: https://github.com/alerta/alerta-docs/blob/master/README.md Build the static HTML documentation and prepare it for deployment by committing and pushing changes. ```bash make html git add . git commit -m '...' git push ``` -------------------------------- ### Get Group Example Request Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example cURL request to fetch a group by its ID. Ensure the Authorization header is provided. ```bash $ curl http://localhost:8080/group/5c0c5c8e-1b2a-3c4d-5e6f-7a8b9c0d1e2f \ -H 'Authorization: Key demo-key' ``` -------------------------------- ### Create Group Example Request Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example cURL request to create a new group. Includes Authorization and Content-type headers, and a JSON payload with group name and text. ```bash $ curl -XPOST http://localhost:8080/group \ -H 'Authorization: Key demo-key' \ -H 'Content-type: application/json' \ -d '{ "name": "alerta_ops", "text": "Operations team" }' ``` -------------------------------- ### Alerta Configuration with API Key Source: https://github.com/alerta/alerta-docs/blob/master/source/cli.md Example of an Alerta configuration profile specifying an API key for authentication. ```ini [profile production] endpoint = https://api.alerta.io key = LMvzLsfJyGpSuLmaB9kp-8gCl4I3YZkV4i7IGb6S ``` -------------------------------- ### Example Response for Creating a Blackout Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Shows a successful HTTP status code for creating a blackout. ```text 201 CREATED ``` -------------------------------- ### List Customers Response Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example response for listing customers, showing multiple customer objects with their IDs, names, and match patterns. ```json { "customers": [ { "customer": "Example Corp.", "id": "289ca657-ea2c-4775-9e07-cc96844cc717", "match": "example.com" }, { "customer": "Example Org.", "id": "90f4e211-c815-4112-9e1a-6e53de5a59c6", "match": "example.org" } ], "status": "ok", "time": "2017-01-02T01:21:38.958Z", "total": 2 } ``` -------------------------------- ### User Creation Response Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example of a successful response when creating a new user, which includes an authentication token. ```json { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI4Y2IwYjYyNC0zY2Q3LTQ1YjktOThhNS01ZGZhYzVmMDE2NmMiLCJyb2xlcyI6WyJ1c2VyIl0sImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6ODA4MC8iLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJqb2UuYmxvZ2dzQGV4YW1wbGUuY29tIiwibmFtZSI6IkpvZSBCbG9nZ3MiLCJlbWFpbCI6ImpvZS5ibG9nZ3NAZXhhbXBsZS5jb20iLCJzY29wZSI6InJlYWQgd3JpdGUiLCJqdGkiOiI2ODlhMmY3Yy0zNTJlLTQ5M2ItYWZjYi1iOWUwOTE3ODAyMDgiLCJleHAiOjE1MTMxODIxNDcsInByb3ZpZGVyIjoiYmFzaWMiLCJpYXQiOjE1MTE5NzI1NDcsIm5iZiI6MTUxMTk3MjU0NywiYXVkIjoiaHR0cDovL2xvY2FsaG9zdDo4MDgwLyJ9.c5jpr8YksoJmoZ6KUwsYP5fgwZr-jdA4W3JUCbv1vXU" } ``` -------------------------------- ### Setup File for Routing Plugin Source: https://github.com/alerta/alerta-docs/blob/master/source/gettingstarted/tutorial-3-plugins.md Defines the package metadata and entry points for the Alerta routing plugin. Copy this code into 'setup.py'. ```python from setuptools import setup, find_packages version = '0.0.1' setup( name="alerta-routing", version=version, description='Alerta routing rules for plugins', url='https://github.com/alerta/alerta-contrib', license='Apache License 2.0', author='Your name', author_email='your.name@example.com', packages=find_packages(), py_modules=['routing'], install_requires=[], include_package_data=True, zip_safe=True, entry_points={ 'alerta.routing': [ 'rules = routing:rules' ] } ) ``` -------------------------------- ### Get User Attributes Example Request Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example cURL request to fetch attributes for the current user. Includes the necessary Authorization header. ```bash $ curl http://localhost:8080/user/me/attributes \ -H 'Authorization: Key demo-key' ``` -------------------------------- ### Create Alert Request Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example of a POST request to create a new alert. Includes mandatory and optional fields. ```bash $ curl -XPOST http://localhost:8080/alert \ -H 'Authorization: Key demo-key' \ -H 'Content-type: application/json' \ -d '{ "attributes": { "region": "EU" }, "correlate": [ "HttpServerError", "HttpServerOK" ], "environment": "Production", "event": "HttpServerError", "group": "Web", "origin": "curl", "resource": "web01", "service": [ "example.com" ], "severity": "major", "tags": [ "dc1" ], "text": "Site is down.", "type": "exceptionAlert", "value": "Bad Gateway (501)" }' ``` -------------------------------- ### Retrieve Alert Request Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example of a GET request to retrieve a specific alert by its ID. ```bash $ curl http://localhost:8080/alert/17d8e7ea-b3ba-4bb1-9c5a-29e60865f258 \ -H 'Authorization: Key demo-key' ``` -------------------------------- ### Example Response for Services Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md This JSON structure represents the response for listing services, showing service details, environment, and alert counts. ```json { "services": [ { "count": 2, "environment": "Production", "service": "example.com" } ], "status": "ok", "total": 1 } ``` -------------------------------- ### Keycloak OIDC JSON Configuration Source: https://github.com/alerta/alerta-docs/blob/master/source/authentication.md Example JSON output from Keycloak for OIDC client installation, containing realm, auth-server-url, resource, and credentials. ```default { "realm": "master", "auth-server-url": "https://keycloak.example.org/auth", "ssl-required": "external", "resource": "alerta-ui", "credentials": { "secret": "418bbf31-aef-33d1-a471-322a60276879" }, "use-resource-role-mappings": true } ``` -------------------------------- ### Curl Request for Services Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example cURL command to list services for a specific environment, including an authorization header. ```bash $ curl http://localhost:8080/services?environment=Production \ -H 'Authorization: Key demo-key' ``` -------------------------------- ### Launch Alerta and Postgres with Docker Compose Source: https://github.com/alerta/alerta-docs/blob/master/source/gettingstarted/tutorial-10-docker.md Command to start all services defined in the docker-compose.yaml file. Ensure the docker-compose.yaml file is in your current directory. ```bash $ docker-compose up ``` -------------------------------- ### Alerta Configuration File Content Source: https://github.com/alerta/alerta-docs/blob/master/source/gettingstarted/tutorial-10-docker.md Example of an `alertad.conf` file demonstrating how to set various Alerta configuration options. Note that strings must be quoted and lists are Python-style. ```python DEBUG=True DATABASE_URL='postgres://alerta:al3rt8@db:5432/alerta' AUTH_REQUIRED=True ADMIN_USERS=['alice','bob','charlotte','dave'] ADMIN_PASSWORD='Pa55w0rd' ADMIN_KEY='docker-api-key' PLUGINS=['reject','heartbeat','blackout','normalise'] ``` -------------------------------- ### List Permissions Response Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example response for listing permissions, showing multiple permission objects with their IDs, match patterns, and scopes. ```json { "permissions": [ { "id": "5b726183-019f-4add-b6dc-caba87e873f7", "match": "alerta_ro", "scopes": [ "read" ] }, { "id": "f4c91af3-5222-4201-9da0-02c40122f4c4", "match": "alerta_rw", "scopes": [ "read", "write" ] }, { "id": "1f84f919-c07a-4bd1-93b0-26e28871257f", "match": "alerta_ops", "scopes": [ "read", "write", "admin:keys" ] } ], "status": "ok", "time": "2017-07-29T21:42:30.500Z", "total": 3 } ``` -------------------------------- ### Example Heartbeat Response Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md This is an example of a successful response when retrieving heartbeat information. ```json { "heartbeats": [ { "attributes": { "environment": "Production", "group": "Network", "service": [ "Core", "HA" ], "severity": "major" }, "createTime": "2020-06-07T20:31:58.244Z", "customer": null, "href": "http://localhost:8080/heartbeat/ea2f41e3-16c4-412f-aaf2-874e3c4c771b", "id": "ea2f41e3-16c4-412f-aaf2-874e3c4c771b", "latency": 0, "maxLatency": 2000, "origin": "cluster05", "receiveTime": "2020-06-07T20:31:58.244Z", "since": 136, "status": "expired", "tags": [ "db05", "dc2" ], "timeout": 120, "type": "Heartbeat" } ], "status": "ok", "total": 1 } ``` -------------------------------- ### Example Alert Response Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md This is an example of a successful response when querying for alert counts. ```json { "severityCounts": { "critical": 1, "major": 1 }, "status": "ok", "statusCounts": { "ack": 1, "open": 1 }, "total": 2 } ``` -------------------------------- ### Configure uWSGI Server Source: https://github.com/alerta/alerta-docs/blob/master/source/gettingstarted/tutorial-1-deploy-alerta.md Sets up the uWSGI configuration file (/etc/uwsgi.ini) to mount the Alerta API, log to syslog, and use a Unix socket. ```ini [uwsgi] chdir = /var/www mount = /api=wsgi.py callable = app manage-script-name = true env = BASE_URL=/api master = true processes = 5 logger = syslog:alertad socket = /tmp/uwsgi.sock chmod-socket = 664 uid = www-data gid = www-data vacuum = true die-on-term = true ``` -------------------------------- ### Example Alerta API Response Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md This is an example of a successful response when retrieving alerts from the Alerta API. ```json { "alerts": [ { "attributes": { "flapping": false, "incidentKey": "1234abcd", "ip": "10.1.1.1", "notify": true }, "correlate": [ "HttpServerError", "HttpServerOK" ], "createTime": "2018-01-27T21:00:12.999Z", "customer": null, "duplicateCount": 0, "environment": "Production", "event": "HttpServerError", "group": "Web", "history": [ { "event": "HttpServerError", "href": "http://localhost:8080/alert/17d8e7ea-b3ba-4bb1-9c5a-29e60865f258", "id": "17d8e7ea-b3ba-4bb1-9c5a-29e60865f258", "severity": "major", "status": null, "text": "Site is down.", "type": "severity", "updateTime": "2018-01-27T21:00:12.999Z", "value": "Bad Gateway (501)" }, { "event": "HttpServerError", "href": "http://localhost:8080/alert/17d8e7ea-b3ba-4bb1-9c5a-29e60865f258", "id": "17d8e7ea-b3ba-4bb1-9c5a-29e60865f258", "severity": null, "status": "ack", "text": "disk needs replacing.", "type": "status", "updateTime": "2018-01-27T21:04:42.412Z", "value": null } ], "href": "http://localhost:8080/alert/17d8e7ea-b3ba-4bb1-9c5a-29e60865f258", "id": "17d8e7ea-b3ba-4bb1-9c5a-29e60865f258", "lastReceiveId": "17d8e7ea-b3ba-4bb1-9c5a-29e60865f258", "lastReceiveTime": "2018-01-27T21:00:13.070Z", "origin": "curl", "previousSeverity": "indeterminate", "rawData": null, "receiveTime": "2018-01-27T21:00:13.070Z", "repeat": false, "resource": "web01", "service": [ "example.com" ], "severity": "major", "status": "ack", "tags": [ "dc1", "linux", "linux2.6", "dell" ], "text": "Site is down.", "timeout": 86400, "trendIndication": "moreSevere", "type": "exceptionAlert", "value": "Bad Gateway (501)" } ], "autoRefresh": true, "lastTime": "2018-01-27T21:00:13.070Z", "more": false, "page": 1, "pageSize": 1000, "pages": 1, "severityCounts": { "major": 1 }, "status": "ok", "statusCounts": { "ack": 1 }, "total": 1 } ``` -------------------------------- ### Example Request to Create a Blackout Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Demonstrates how to use curl to send a POST request to create a blackout period with specified environment, service, and group. ```bash $ curl -XPOST http://localhost:8080/blackout \ -H 'Authorization: Key demo-key' \ -H 'Content-type: application/json' \ -d '{ "environment": "Production", "service": ["example.com"], "group": "Web" }' ``` -------------------------------- ### Example Alerta API Response Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md This is an example of a successful API response when retrieving alert details. ```json { "alert": { "attributes": { "flapping": false, "ip": "127.0.0.1", "notify": true, "region": "EU" }, "correlate": [ "HttpServerError", "HttpServerOK" ], "createTime": "2018-01-27T21:00:12.999Z", "customer": null, "duplicateCount": 0, "environment": "Production", "event": "HttpServerError", "group": "Web", "history": [ { "event": "HttpServerError", "href": "http://localhost:8080/alert/17d8e7ea-b3ba-4bb1-9c5a-29e60865f258", "id": "17d8e7ea-b3ba-4bb1-9c5a-29e60865f258", "severity": "major", "status": null, "text": "Site is down.", "type": "severity", "updateTime": "2018-01-27T21:00:12.999Z", "value": "Bad Gateway (501)" } ], "href": "http://localhost:8080/alert/17d8e7ea-b3ba-4bb1-9c5a-29e60865f258", "id": "17d8e7ea-b3ba-4bb1-9c5a-29e60865f258", "lastReceiveId": "17d8e7ea-b3ba-4bb1-9c5a-29e60865f258", "lastReceiveTime": "2018-01-27T21:00:13.070Z", "origin": "curl", "previousSeverity": "indeterminate", "rawData": null, "receiveTime": "2018-01-27T21:00:13.070Z", "repeat": false, "resource": "web01", "service": [ "example.com" ], "severity": "major", "status": "open", "tags": [ "dc1" ], "text": "Site is down.", "timeout": 86400, "trendIndication": "moreSevere", "type": "exceptionAlert", "value": "Bad Gateway (501)" }, "status": "ok", "total": 1 } ``` -------------------------------- ### Install GeoIP Plugin Source: https://github.com/alerta/alerta-docs/blob/master/source/gettingstarted/tutorial-3-plugins.md Install the geoip plugin using pip. This enables geolocation lookups for alerts. ```bash sudo pip install git+https://github.com/alerta/alerta-contrib.git#subdirectory=plugins/geoip ``` -------------------------------- ### User Signup via CLI Source: https://github.com/alerta/alerta-docs/blob/master/source/authentication.md Command to sign up a new user using the Alerta CLI. ```default $ alerta signup --name "Joe Bloggs" --email joe@example.com --password secret ``` -------------------------------- ### Example Request to Delete a Heartbeat Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example using curl to send a DELETE request to the heartbeat endpoint. ```bash $ curl -XDELETE http://localhost:8080/heartbeat/e0582765-ee64-4944-8a94-1869a079d81f \ -H 'Authorization: Key demo-key' ``` -------------------------------- ### Configure Basic Auth Settings Source: https://github.com/alerta/alerta-docs/blob/master/source/configuration.md Set up realm, enable self-service sign-up, and define allowed email domains for basic authentication. ```python AUTH_PROVIDER = 'basic' BASIC_AUTH_REALM = 'Monitoring' SIGNUP_ENABLED = True ALLOWED_EMAIL_DOMAINS = ['alerta.io', 'alerta.dev'] ``` -------------------------------- ### Login with User Credentials Source: https://github.com/alerta/alerta-docs/blob/master/source/cli.md Command to log in with user credentials. ```bash > login Login with user credentials ``` -------------------------------- ### Install MyST-Parser Source: https://github.com/alerta/alerta-docs/blob/master/source/examples/myst-parser.md Install the myst-parser package using pip. This command is used to add the parser to your Python environment. ```bash pip install myst-parser ``` -------------------------------- ### Install Enchant Dependency Source: https://github.com/alerta/alerta-docs/blob/master/README.md Install the 'enchant' library, which is a dependency for the spelling extension. This command is for macOS using Homebrew. ```bash brew install enchant ``` -------------------------------- ### Run Alerta with Enabled Plugins Source: https://github.com/alerta/alerta-docs/blob/master/source/gettingstarted/tutorial-10-docker.md Enable specific Alerta plugins at container launch by setting the `PLUGINS` environment variable. This example enables 'reject', 'heartbeat', 'blackout', and 'normalise'. ```bash $ docker run --name alerta-web \ -e DATABASE_URL=$DATABASE_URL \ -e ADMIN_USERS=alice,bob,charlotte,dave \ -e ADMIN_PASSWORD=Pa55w0rd \ -e ADMIN_KEY=docker-api-key \ -e PLUGINS=reject,heartbeat,blackout,normalise \ --link alerta-db:db -d -p 8080:8080 alerta/alerta-web ``` -------------------------------- ### Manage MongoDB Service Source: https://github.com/alerta/alerta-docs/blob/master/source/gettingstarted/tutorial-1-deploy-alerta.md Starts the MongoDB server, checks its status, and configures it to start automatically on system reboot. ```bash sudo systemctl start mongod sudo systemctl status mongod sudo systemctl enable mongod ``` -------------------------------- ### Run Alerta Web Container Source: https://github.com/alerta/alerta-docs/blob/master/source/gettingstarted/tutorial-10-docker.md Starts the Alerta web container, linking it to the PostgreSQL database. The DATABASE_URL environment variable must be set to connect to the database. ```bash $ export DATABASE_URL=postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@db:5432/alerta $ docker run --name alerta-web \ -e DATABASE_URL=$DATABASE_URL \ --link alerta-db:db -d -p 8080:8080 alerta/alerta-web ``` -------------------------------- ### Base Plugin Class Implementation Source: https://github.com/alerta/alerta-docs/blob/master/source/gettingstarted/tutorial-3-plugins.md Demonstrates the required methods for a basic Alerta plugin: `pre_receive`, `post_receive`, and `status_change`. The `__init__` method is optional but shown here for completeness. ```python class ExamplePlugin(PluginBase): def __init__(self, name=None): # plugin-specific init goes here # if not required, leave "__init__()" out completely super(ExamplePlugin, self).__init__(name) def pre_receive(self, alert): # reject or modify an alert before it hits the database return alert def post_receive(self, alert): # after alert saved in database, forward alert to external systems return def status_change(self, alert, status, text): # triggered by external status changes, used by integrations return ``` -------------------------------- ### Create Customer Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Creates a new customer lookup to match user logins to customer names. Requires customer name and a match pattern. ```bash $ curl -XPOST http://localhost:8080/customer \ -H 'Authorization: Key demo-key' \ -H 'Content-type: application/json' \ -d '{ "customer": "Example Corp.", "match": "example.com" }' ``` -------------------------------- ### Delete Group Example Request Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example cURL request to delete a group. Note the use of -XDELETE and the required Authorization header. ```bash $ curl -XDELETE http://localhost:8080/group/5c0c5c8e-1b2a-3c4d-5e6f-7a8b9c0d1e2f \ -H 'Authorization: Key demo-key' ``` -------------------------------- ### Delete User Example Request Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example cURL request to delete a user. Note the use of -XDELETE and the required Authorization header. ```bash $ curl -XDELETE http://localhost:8080/user/166b41d6-849f-440d-ba30-1a5345d86fb6 \ -H 'Authorization: Key demo-key' ``` -------------------------------- ### Example Request to Delete an API Key Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example using curl to send a DELETE request to delete a specific API key. ```bash $ curl -XDELETE http://localhost:8080/key/532c9b59-9e90-40d4-8a3b-887362a79e9cO8rhJSKrdfQWXqRhvSwJQJRZg9yU0s2Z4VLP4855 \ -H 'Authorization: Key demo-key' ``` -------------------------------- ### Use Dummy Endpoint for Testing Source: https://github.com/alerta/alerta-docs/blob/master/source/federated.md Utilize a dummy endpoint like httpbin.org/anything for testing purposes. ```bash https://httpbin.org/anything ``` -------------------------------- ### Example JSON Response for Creating a Blackout Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md An example JSON response confirming the creation of a blackout period, including its details and ID. ```json { "blackout": { "customer": null, "duration": 3600, "endTime": "2018-01-27T22:10:31.705Z", "environment": "Production", "event": null, "group": "Web", "href": "http://localhost:8080/blackout/79d12b79-45b9-4419-80e4-1f6c17478eb6", "id": "79d12b79-45b9-4419-80e4-1f6c17478eb6", "priority": 3, "remaining": 3599, "resource": null, "service": [ "example.com" ], "startTime": "2018-01-27T21:10:31.705Z", "status": "active", "tags": [] }, "id": "79d12b79-45b9-4419-80e4-1f6c17478eb6", "status": "ok" } ``` -------------------------------- ### List API Keys CLI Command Source: https://github.com/alerta/alerta-docs/blob/master/source/cli.md Lists all available API keys. ```bash $ alerta keys ``` -------------------------------- ### Configure zabbix-alerta Source: https://github.com/alerta/alerta-docs/blob/master/source/gettingstarted/tutorial-8-integration-zabbix.md Create a configuration file for zabbix-alerta to specify the Alerta endpoint, API key, and environment. This file should be placed at /etc/alerta/zabbix-alerta.conf. ```ini [alerta] endpoint = http://alerta.example.com:8080/api key = your-api-key-here environment = Production ``` -------------------------------- ### Authentication Settings Source: https://github.com/alerta/alerta-docs/blob/master/source/configuration.md Enable authentication and configure user roles, scopes, and multi-tenancy. ```python AUTH_REQUIRED = True ADMIN_USERS = ['admin@alerta.io', 'devops@example.com'] DEFAULT_ADMIN_ROLE = 'ops' ADMIN_ROLES = ['ops', 'devops', 'coolkids'] USER_DEFAULT_SCOPES = ['read', 'write:alerts'] CUSTOMER_VIEWS = True ``` -------------------------------- ### List Group Members Example Request Source: https://github.com/alerta/alerta-docs/blob/master/source/api/reference.md Example cURL request to list members of a specific group. Ensure the Authorization header is included. ```bash $ curl http://localhost:8080/group/5c0c5c8e-1b2a-3c4d-5e6f-7a8b9c0d1e2f/users \ -H 'Authorization: Key demo-key' ``` -------------------------------- ### Basic Routing Plugin Source: https://github.com/alerta/alerta-docs/blob/master/source/gettingstarted/tutorial-3-plugins.md Implements the default behavior by returning all configured plugins in their listed order. Copy this code into 'routing.py'. ```python def rules(alert, plugins): print(plugins) return plugins.values() ``` -------------------------------- ### Example: Alert on Stale Heartbeat Source: https://github.com/alerta/alerta-docs/blob/master/source/cli.md Demonstrates how to set up an alert for a specific origin that is missed or slow, and then trigger a major alert if the heartbeat is stale. ```bash $ alerta heartbeat -O system1 -T environment:Infra -T group:Network --timeout 10 (wait >10 seconds) $ alerta heartbeats --alert --severity major ```