# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: Grafana
spec:
    description: Grafana is the open source analytics & monitoring solution for every database.
    coverImage: https://cdn.zeabur.com/templates/cover-image/grafana.png
    icon: https://cdn.zeabur.com/templates/icon/grafana.svg
    variables:
        - key: GF_SECURITY_ADMIN_USER
          type: STRING
          name: Grafana Admin User
          description: The username for the Grafana admin user
        - key: PUBLIC_DOMAIN
          type: DOMAIN
          name: Domain
          description: The domain name for your Grafana dashboard
    tags:
        - monitoring
        - observability
        - grafana
    readme: |
        Grafana is the open source analytics & monitoring solution for every database.

        ## Usage

        It is a one-click deployment of Grafana.

        You specify the domain to access your Grafana dashboard, and the admin user to
        access the Grafana dashboard. Password will be generated automatically.

        ## Integrations

        To achieve a comprehensive telemetry solution, you may need additional metrics backends. Several useful Zeabur one-click templates comprise [the tracing, metrics, and logs trio](https://opentelemetry.io/docs/concepts/observability-primer/):

        - Metrics
          - [Prometheus](https://zeabur.com/templates/XV8ADT)
          - [VictoriaMetrics](https://zeabur.com/templates/UBHA7Z)
        - Tracing
          - [Tempo](https://zeabur.com/templates/DO7QLO)
          - [VictoriaTraces](https://zeabur.com/templates/XUSH4W)
        - Logs
          - [VictoriaLogs](https://zeabur.com/templates/OXA4QA)

        You may also want to use [OpenTelemetry Collector for VictoriaMetrics](https://zeabur.com/templates/Z07UW5) to collect metrics from your services and send them to your backends centrally.

        ### Cross-project solution

        If your Grafana is not in the same project as the metrics backends, you may need to connect them via a public network.

        Solutions like [HAProxy](https://zeabur.com/templates/X1822W), [Caddy](https://zeabur.com/templates/FFDLWU), and [NGINX](https://zeabur.com/templates/YIUNMF) can help you set up basic authentication for your backend, ensuring that unauthorized users cannot access your metrics.

        If you are using VictoriaMetrics Stack, we have an [out-of-the-box solution based on Caddy](https://zeabur.com/templates/JNEQBS) for you.
    services:
        - name: grafana
          icon: https://cdn.zeabur.com/templates/icon/grafana.svg
          template: PREBUILT
          spec:
            source:
                image: grafana/grafana-enterprise:12.4.0-21693836646
            ports:
                - id: web
                  port: 3000
                  type: HTTP
            volumes:
                - id: data
                  dir: /var/lib/grafana
            instructions:
                - title: Grafana Admin Username
                  content: ${GF_SECURITY_ADMIN_USER}
                - title: Grafana Admin Password
                  content: ${GF_SECURITY_ADMIN_PASSWORD}
            env:
                GF_SECURITY_ADMIN_PASSWORD:
                    default: ${PASSWORD}
                GF_SECURITY_ADMIN_USER:
                    default: admin
                GF_SERVER_ROOT_URL:
                    default: ${ZEABUR_WEB_URL}
          domainKey: PUBLIC_DOMAIN
