Alerta Docker Deployment Examples

repository·master·Indexed 41 days ago

https://github.com/alerta/docker-alerta

A collection of Docker Compose examples for deploying Alerta, a monitoring system that consolidates and de-duplicates alerts. Includes configurations for reverse proxies (Apache, Envoy, NGINX, Traefik), authentication providers (Keycloak, LDAP, SAML2, GitLab), database setups (PostgreSQL, MongoDB Replica Sets), and integrations with monitoring tools like Prometheus, Zabbix, and Nagios.

Tokens
4.7K
Snippets
24
Records
32
Agent score
48%

What's inside Alerta

  1. Enable and Configure Plugins

    master

    All built-in and contributed plugins are installed during the image build process. However, they are disabled by default. To enable specific plugins, you must list them in the PLUGINS environment variable.

    Example: To enable remote_ip, reject, heartbeat, blackout, slack, and prometheus:

    PLUGINS=remote_ip,reject,heartbeat,blackout,slack,prometheus

    Note: Custom plugins must be installed as an additional image layer.

    PLUGINS=remote_ip,reject,heartbeat,blackout,slack,prometheus
  2. Quickstart: Run Alerta with Docker

    master

    To run Alerta using Docker, you must first start a database container (MongoDB or Postgres) and then run the alerta-web container, linking it to the database.

    1. Start the database (e.g., MongoDB):

      docker run --name alerta-db -d mongo
    2. Start the Alerta web container: Set the DATABASE_URL and link the container using --link:

      export DATABASE_URL=mongodb://db:27017/monitoring
      docker run --name alerta-web -e DATABASE_URL=$DATABASE_URL --link alerta-db:db -d -p <port>:8080 alerta/alerta-web

    Access Points:

    • API Endpoint: http://<docker>:<port>/api
    • Web Console: http://<docker>:<port>/
    export DATABASE_URL=mongodb://db:27017/monitoring
    docker run --name alerta-web -e DATABASE_URL=$DATABASE_URL --link alerta-db:db -d -p <port>:8080 alerta/alerta-web
  3. Configure Google OAuth2 Authentication

    master

    To use Google OAuth2, you must create a client ID and secret in the Google Developer Console.

    1. Set credentials as environment variables:

      export CLIENT_ID=your_client_id
      export CLIENT_SECRET=your_client_secret
    2. Run the container with the Google provider:

      docker run --name alerta-web -e AUTH_PROVIDER=google -e CLIENT_ID=$CLIENT_ID -e CLIENT_SECRET=$CLIENT_SECRET -d -p <port>:8080 alerta/alerta-web
    3. Enforce Authentication (Optional): By default, Google login is optional. To require users to log in, add -e AUTH_REQUIRED=True.

    4. Restrict Domains (Optional): Use ALLOWED_EMAIL_DOMAIN=example.com to restrict logins to a specific domain.

    docker run --name alerta-web -e AUTH_PROVIDER=google -e CLIENT_ID=$CLIENT_ID -e CLIENT_SECRET=$CLIENT_SECRET -d -p <port>:8080 alerta/alerta-web
  4. Explore Alerta monitoring stack examples

    master

    The docker-alerta repository provides several docker-compose based examples for deploying Alerta in different monitoring environments and authentication scenarios. You can use these examples as templates for your own deployments.

    Authentication Examples:

    • GitLab authentication
    • Keycloak authentication
    • LDAP authentication

    Monitoring Integration Examples:

    • Icinga
    • Nagios
    • Netdata
    • Prometheus/Alertmanager
    • Sensu
    • Zabbix
    • SNMP Trap forwarder
  5. Run Alerta with LDAP authentication

    master

    This example demonstrates how to run Alerta integrated with an LDAP server for authentication.

    Prerequisites

    Before running, you must ensure your host can resolve host.docker.internal. Add the following entry to your /etc/hosts file:

    127.0.0.1 host.docker.internal

    Execution

    To launch both the Alerta and the LDAP containers, use Docker Compose:

    docker-compose up

    Once the containers are running, access the Alerta login page at: http://local.alerta.io:8000/login

    Default Credentials:

    • Username: leela
    • Password: leela
  6. Initialize a MongoDB Replica Set for Alerta

    master

    When using the MongoDB Replica Set example for Alerta, you must manually initiate the replica set after the containers have started.

    1. Access an interactive shell in one of the MongoDB containers using docker exec.
    2. Run the rs.initiate() command with the configuration defining the replica set ID (rs0) and the host members (db0, db1, and db2).
    # 1. Enter the mongo container
    docker exec -ti mongo_db0_1 mongo
    
    # 2. Inside the mongo shell, run:
    rs.initiate(
        {
            _id: "rs0",
            version: 1,
            members: [
                { _id: 0, host : "db0:27017" },
                { _id: 1, host : "db1:27017" },
                { _id: 2, host : "db2:27017" }
            ]
        }
    )
  7. Deploy Alerta with Docker Compose

    master

    You can use docker-compose to orchestrate Alerta and a Postgres database together.

    Example docker-compose.yml:

    version: '2.1'
    services:
      web:
        image: alerta/alerta-web
        ports:
          - "8080:8080"
        depends_on:
          - db
        environment:
          - DEBUG=1
          - DATABASE_URL=postgres://postgres:postgres@db:5432/monitoring
          - AUTH_REQUIRED=True
          - ADMIN_USERS=admin@alerta.io,devops@alerta.io
          - ADMIN_KEY=demo-key
          - PLUGINS=reject,blackout,normalise,enhance
        restart: always
      db:
        image: postgres
        volumes:
          - ./pg-data:/var/lib/postgresql/data
        environment:
          - POSTGRES_DB=monitoring
          - POSTGRES_USER=postgres
          - POSTGRES_PASSWORD=postgres
        restart: always

    Run the stack with:

    docker-compose up
    docker-compose up
  8. Deploy Alerta with Traefik Reverse Proxy

    master

    This example demonstrates how to use Traefik to proxy the Alerta Web UI and Alerta API using non-root URL sub-paths. The setup includes the following containers:

    • traefik reverse proxy
    • webui (custom built image)
    • api (official docker image)
    • db (postgres image)
    $ cd examples/traefik
    $ docker-compose build
    $ docker-compose up -d
  9. Run the Custom Webhook Example

    master

    To run the demonstration of extending the official Alerta image with a custom webhook, use the provided Docker Compose configuration. This setup builds a custom image based on the official Alerta image and launches the necessary containers.

    $ cd examples/webhook
    $ docker-compose build
    $ docker-compose up
  10. Deploy Alerta with Apache Reverse Proxy

    master

    This example demonstrates how to use Apache httpd as a reverse proxy to serve both the Alerta Web UI and the Alerta API on a non-root URL sub-path. The setup uses the following containers:

    • apache: httpd acting as the reverse proxy.
    • webui: A custom-built image for the Alerta Web UI.
    • api: The official Alerta API Docker image.
    • db: A PostgreSQL database image.
    $ cd examples/apache
    $ docker-compose build
    $ docker-compose up -d
  11. Deploy Alerta with Keycloak Authentication

    master

    This example demonstrates how to run Alerta integrated with Keycloak for OpenID Connect (OIDC) authentication. The setup involves three main containers:

    1. Alerta web: The Alerta application.
    2. Postgres database: The backend database for Alerta.
    3. Keycloak: The identity and access management provider.

    To deploy this setup, ensure your environment is configured to allow the containers to communicate via the host loopback, then use Docker Compose to launch the services.

    $ docker-compose up
  12. Run the Alerta SAML2 IdP Example

    master

    This example demonstrates how to run Alerta with a SAML2 Identity Provider (IdP).

    Prerequisite: You must add the following entry to your /etc/hosts file for the networking to function correctly:

    127.0.0.1 host.docker.internal

    Steps to run:

    1. Use docker-compose to start the services:
      docker-compose up
    2. Access the Alerta login page at: http://local.alerta.io:8080/login
    3. Use the following credentials to test:
      • Username: user1
      • Password: user1pass
    docker-compose up