Gatus Health Dashboard

repository·master·Indexed 11 days ago

https://github.com/twin/gatus

A developer-oriented health dashboard that proactively monitors services using HTTP, ICMP, TCP, and DNS protocols. Gatus evaluates service health based on customizable conditions such as status codes, response times, and body content, providing visual status tracking and integrated alerting for providers like Slack, Teams, PagerDuty, and Discord.

Tokens
40.3K
Snippets
121
Records
145
Agent score
95%

What's inside Gatus

  1. Overview of Gatus features and capabilities

    master

    Gatus is a developer-oriented health dashboard designed to monitor services proactively. Unlike metric-based monitoring (like Prometheus or Cloudwatch) which relies on existing traffic, Gatus performs active health checks to detect issues even when there is no client traffic.

    Key Capabilities:

    • Proactive Monitoring: Uses HTTP, ICMP, TCP, and DNS queries to actively test endpoints.
    • Flexible Conditions: Evaluate health based on status codes, response times, certificate expiration, response body content, IP addresses, and more.
    • Alerting: Integrated support for numerous providers including Slack, Teams, PagerDuty, Discord, Twilio, and custom providers.
    • User Acceptance Testing: Can be used to create automated UATs by checking specific response patterns.
    • Low Footprint: Built in Go for minimal resource consumption.
    • Visualizations: Provides a dashboard with dark mode support and generates status badges (Uptime, Health, Response Time).
  2. Reload configuration on the fly

    master

    Gatus automatically reloads the configuration if the file is updated while running.

    • By default, Gatus exits if the new configuration is invalid.
    • You can set skip-invalid-config-update: true to keep running with the old configuration if an update fails.
    • Warning: If you don't check logs for invalid configuration messages, you might find Gatus unable to start if the application is restarted.
  3. Use placeholders in endpoint request bodies

    master

    When configuring endpoints[].body, you can use the following placeholders to dynamically inject values into your request body:

    • [ENDPOINT_NAME]: The value of endpoints[].name.
    • [ENDPOINT_GROUP]: The value of endpoints[].group.
    • [ENDPOINT_URL]: The value of endpoints[].url.
    • [LOCAL_ADDRESS]: The local IP and port (e.g., 192.0.2.1:25 or [2001:db8::1]:80).
    • [RANDOM_STRING_N]: A random alphanumeric string of length N (where N is max 8192).
  4. Use environment variables in configuration files

    master

    Gatus supports using environment variables directly within your YAML configuration files using $VAR or ${VAR} syntax.

    Important: If your configuration parameter contains a literal $ symbol that is not intended to be an environment variable, you must escape it by using $$.

  5. Understand External Endpoints

    master

    Unlike standard endpoints which Gatus polls at a set interval, External Endpoints are not monitored by Gatus internally. Instead, they are pushed to Gatus programmatically via an API.

    This pattern is useful for monitoring services in isolated environments that Gatus cannot reach directly, allowing those services to report their own health status to the Gatus dashboard.

  6. Use Remote Instances (EXPERIMENTAL)

    master

    The remote feature allows a Gatus instance to retrieve endpoint statuses from other remote Gatus instances. This is useful for aggregating multiple instances into a single dashboard or pulling data from instances behind firewalls.

    Warning: This is an experimental feature. It may be removed or updated in a breaking manner and has known issues. Use at your own risk.

    remote:
      instances:
        - endpoint-prefix: "status.example.org-"
          url: "https://status.example.org/api/v1/endpoints/statuses"
  7. How Suites work for workflow-style monitoring

    master

    Suites (ALPHA) allow you to execute a collection of endpoints sequentially within a shared context. This is ideal for multi-step workflows like authentication flows (login $\rightarrow$ access resource $\rightarrow$ logout) or API CRUD testing (create $\rightarrow$ update $\rightarrow$ verify $\rightarrow$ delete).

    Core Concepts:

    • Shared Context: Values extracted from one endpoint can be used in subsequent endpoints using the [CONTEXT].key syntax.
    • Sequential Execution: Endpoints run one after another. A suite is successful only if all required endpoints pass their conditions.
    • always-run: Setting this to true on an endpoint ensures it executes even if previous steps in the suite failed (useful for cleanup/logout steps).
    • Alerting: Suite-level alerts are not yet supported; configure alerts on individual endpoints within the suite instead.

    Context Syntax: You can reference context values in URLs, headers, request bodies, or conditions:

    • URL: https://api.example.com/users/[CONTEXT].user_id
    • Header: Authorization: Bearer [CONTEXT].auth_token
    • Body: {"user_id": "[CONTEXT].user_id"}
    • Condition: [BODY].server_ip == [CONTEXT].server_ip

    Note: Context/store keys are limited to A-Z, a-z, 0-9, _, and -.

    suites:
      - name: item-crud-workflow
        group: api-tests
        interval: 5m
        context:
          price: "19.99"
        endpoints:
          - name: create-item
            url: https://api.example.com/items
            method: POST
            body: '{"name": "Test Item", "price": "[CONTEXT].price"}'
            conditions:
              - "[STATUS] == 201"
              - "len([BODY].id) > 0"
            store:
              itemId: "[BODY].id"
          - name: delete-item
            url: https://api.example.com/items/[CONTEXT].itemId
            method: DELETE
            always-run: true
            conditions:
              - "[STATUS] == 204"
  8. How PagerDuty alerts work in Gatus

    master

    PagerDuty alerts in Gatus follow a threshold-based lifecycle:

    1. Triggering an Incident: When an endpoint fails to meet its defined conditions, Gatus tracks the failures. Once the number of consecutive failures reaches the failure-threshold, a new incident is created in PagerDuty.
    2. Resolving an Incident: Once an incident is active, Gatus monitors the endpoint for recovery. When the endpoint meets its conditions for a consecutive number of executions equal to the success-threshold, Gatus will resolve the incident in PagerDuty, provided that send-on-resolved is set to true.
  9. Monitor SSH endpoints

    master

    Prefix the endpoints[].url with ssh:// to execute commands on a remote server via SSH.

    • Authentication: Supports username/password or username/private-key.
    • Placeholders:
      • [CONNECTED]: Connection success status.
      • [STATUS]: The exit code of the executed command.
      • [BODY]: The stdout output of the command.
      • [IP]: The server's IP address.
      • [RESPONSE_TIME]: Time to establish connection and execute command.
    endpoints:
      - name: ssh-example-password
        url: "ssh://example.com:22"
        ssh:
          username: "username"
          password: "password"
        body: |
          {
            "command": "echo '{\"memory\": {\"used\": 512}}'"
          }
        interval: 1m
        conditions:
          - "[CONNECTED] == true"
          - "[STATUS] == 0"
          - "[BODY].memory.used > 500"
  10. Monitor WebSocket endpoints

    master

    Prefix the endpoints[].url with ws:// or wss:// to monitor WebSocket connections.

    • [CONNECTED] indicates if the connection was established.
    • [BODY] contains the output of the query.
    • You can use Go template syntax in conditions.
    endpoints:
      - name: example
        url: "wss://echo.websocket.org/"
        body: "status"
        conditions:
          - "[CONNECTED] == true"
          - "[BODY] == pat(*served by*)"
  11. Integrate Gatus with PagerDuty

    master

    You can integrate Gatus with PagerDuty to notify on-call responders when endpoints fail and automatically resolve incidents when endpoints return to a healthy state.

    1. Configure PagerDuty

    1. In PagerDuty, go to Configuration > Services.
    2. For an existing service: Click the service name, go to the Integrations tab, and click New Integration.
    3. For a new service: Create a new service in PagerDuty and select Gatus as the Integration Type.
    4. Set an Integration Name (e.g., Gatus-Shopping-Cart) and select Gatus from the Integration Type menu.
    5. Click Add Integration.
    6. Save the generated Integration Key; you will need this for the Gatus configuration.

    2. Configure Gatus

    In your Gatus configuration file, add the PagerDuty integration key under alerting.pagerduty.integration-key. Then, add an alert of type pagerduty to your specific endpoints.

    Note: It is highly recommended to set send-on-resolved: true for PagerDuty alerts to ensure incidents are automatically closed in PagerDuty when the endpoint recovers.

    alerting:
      pagerduty: 
        integration-key: "YOUR_PAGERDUTY_INTEGRATION_KEY"
    
    endpoints:
      - name: website
        url: "https://example.com/health"
        interval: 30s
        alerts:
          - type: pagerduty
            enabled: true
            failure-threshold: 3
            success-threshold: 5
            description: "healthcheck failed"
            send-on-resolved: true
        conditions:
          - "[STATUS] == 200"