# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: Gatus
spec:
    description: Automated developer-oriented status page with alerting and incident support
    coverImage: https://cdn.zeabur.com/templates/cover-image/gatus.jpg
    icon: https://cdn.zeabur.com/templates/icon/gatus.svg
    variables:
        - key: PUBLIC_DOMAIN
          type: DOMAIN
          name: Public domain
          description: The domain name that will be used to access the status page and the metrics.
    readme: |
        Gatus is a developer-oriented health dashboard that gives you the ability to monitor your services using HTTP, ICMP, TCP, and even DNS queries as well as evaluate the result of said queries by using a list of conditions on values like the status code, the response time, the certificate expiration, the body and many others. The icing on top is that each of these health checks can be paired with alerting via Slack, Teams, PagerDuty, Discord, Twilio and many more.

        ## Usage

        This is a one-click deployment template for Gatus. It enables SQLite for status persistence and the Metrics endpoint for [Prometheus](https://zeabur.com/templates/XV8ADT) by default.

        You should set the endpoints to monitor in the [Config Editor](https://zeabur.com/docs/data-management/config-edit).

        For Gatus configuration documentation, please refer to [their GitHub documentation](https://github.com/TwiN/gatus#endpoints).

        ### Example: Monitoring HTTP endpoints

        ```yaml
        endpoints:
        - name: backend-gateway
          url: "http://backend-gateway:80"
          conditions:
            - "[STATUS] == 200"
        - name: backend-replica-1
          url: "http://backend-replica-1:8080"
          conditions:
            - "[STATUS] == 200"
        - name: backend-replica-2
          url: "http://backend-replica-2:8080"
          conditions:
            - "[STATUS] == 200"
        - name: backend-replica-3
          url: "http://backend-replica-3:8080"
          conditions:
            - "[STATUS] == 200"
        ```

        ### Example: Monitoring with custom HTTP headers

        ```yaml
        endpoints:
        - name: victoria-gateway
          url: "http://victoria-gateway:80"
          headers:
            # user:tNGeI87rzW27bwoeYFWQsfzO2Es9xCNc
            Authorization: "Basic dXNlcjp0TkdlSTg3cnpXMjdid29lWUZXUXNmek8yRXM5eENOYw=="
          conditions:
            - "[STATUS] == 200"
        ```

        ### Example: Monitoring TCP endpoints

        ```yaml
        endpoints:
        - name: postgresql
          url: "tcp://postgresql:5432"
          interval: 30s
          conditions:
            - "[CONNECTED] == true"
        - name: redis
          url: "tcp://redis:6379"
          interval: 30s
          conditions:
            - "[CONNECTED] == true"
        ```
    services:
        - name: gatus
          icon: https://cdn.zeabur.com/templates/icon/gatus.svg
          template: PREBUILT_V2
          spec:
            source:
                image: ghcr.io/twin/gatus:v5.34.0
            ports:
                - id: web
                  port: 8080
                  type: HTTP
            volumes:
                - id: data
                  dir: /storage
            configs:
                - path: /config/config.yaml
                  template: |
                    metrics: true

                    storage:
                      path: /storage/gatus.db
                      type: sqlite
                      caching: true

                    # Update this section with your endpoints
                    endpoints:
                      - name: front-end
                        group: core
                        url: "https://twin.sh/health"
                        interval: 5m
                        conditions:
                          - "[STATUS] == 200"
                          - "[BODY].status == UP"
                          - "[RESPONSE_TIME] < 150"

                      - name: back-end
                        group: core
                        url: "https://example.org/"
                        interval: 5m
                        conditions:
                          - "[STATUS] == 200"
                          - "[CERTIFICATE_EXPIRATION] > 48h"

                      - name: monitoring
                        group: internal
                        url: "https://example.org/"
                        interval: 5m
                        conditions:
                          - "[STATUS] == 200"

                      - name: nas
                        group: internal
                        url: "https://example.org/"
                        interval: 5m
                        conditions:
                          - "[STATUS] == 200"

                      - name: example-dns-query
                        url: "8.8.8.8" # Address of the DNS server to use
                        interval: 5m
                        dns:
                          query-name: "example.com"
                          query-type: "A"
                        conditions:
                          - "[BODY] == pat(*.*.*.*)"  # Matches any IPv4 address
                          - "[DNS_RCODE] == NOERROR"

                      - name: icmp-ping
                        url: "icmp://example.org"
                        interval: 1m
                        conditions:
                          - "[CONNECTED] == true"

                      - name: check-domain-expiration
                        url: "https://example.org/"
                        interval: 1h
                        conditions:
                          - "[DOMAIN_EXPIRATION] > 720h"
                  permission: null
                  envsubst: null
          domainKey: PUBLIC_DOMAIN
