# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: Prometheus
spec:
    description: Open source metrics and monitoring for your systems and services
    coverImage: https://cdn.zeabur.com/templates/cover-image/prometheus.png
    icon: https://cdn.zeabur.com/templates/icon/prometheus.svg
    tags:
        - monitoring
        - observability
        - metrics
    readme: |
        Prometheus, a Cloud Native Computing Foundation project, is a systems and service monitoring system. It collects metrics from configured targets at given intervals, evaluates rule expressions, displays the results, and can trigger alerts when specified conditions are observed.

        Typically, you compose Prometheus with [Grafana](https://zeabur.com/templates/MDTTQR) to visualize and integrate the metrics.

        Learn more about Prometheus on [the official website](https://prometheus.io/).

        ## Usage

        You can find the port mapping (`9090`) from the “Networking” tab in the “Services” section.

        To add your own targets, you should add them in the `/etc/prometheus.yaml` file on [Config Editor](https://zeabur.com/docs/data-management/config-edit). For example:

        ```yaml
        scrape_configs:
          - job_name: 'prometheus'
            static_configs:
              - targets: ['localhost:9090']
          - job_name: 'tempo'
            static_configs:
              - targets: ['tempo:3200']
          - job_name: 'tempo-usage-metrics'
            metrics_path: '/usage_metrics'
            static_configs:
              - targets: ['tempo:3200']
        ```
    services:
        - name: prometheus
          icon: https://cdn.zeabur.com/templates/icon/prometheus.svg
          template: PREBUILT
          spec:
            source:
                image: prom/prometheus:latest
                args:
                    - --config.file=/etc/prometheus.yaml
                    - --web.enable-remote-write-receiver
                    - --enable-feature=exemplar-storage
                    - --enable-feature=native-histograms
            ports:
                - id: web
                  port: 9090
                  type: HTTP
            volumes:
                - id: data
                  dir: /prometheus
            configs:
                - path: /etc/prometheus.yaml
                  template: |
                    global:
                      scrape_interval:     15s
                      evaluation_interval: 15s

                    scrape_configs:
                      - job_name: 'prometheus'
                        static_configs:
                          - targets: ['localhost:9090']
                  permission: null
                  envsubst: null
