---
#==============================================================#
# File      :   datasource.yml
# Mtime     :   2025-12-09
# Desc      :   Grafana Data Source Provisioner Definition
# Path      :  /etc/grafana/provisioning/datasources/pigsty.yml
# License   :   Apache-2.0 @ https://pigsty.io/docs/about/license/
# Copyright :   2018-2026  Ruohang Feng / Vonng (rh@vonng.com)
#==============================================================#

apiVersion: 1

# remove provisioned data sources
deleteDatasources:
  - { name: Metrics    , orgId: 1 }
  - { name: Logs       , orgId: 1 }
  - { name: Traces     , orgId: 1 }
  - { name: Meta       , orgId: 1 }
  - { name: Static     , orgId: 1 }

# install following data sources
datasources:

  # Pigsty Metrics Database (VictoriaMetrics, Prometheus compatible)
  - name: Metrics
    uid: ds-prometheus
    type: prometheus
    url: http://127.0.0.1:{{ vmetrics_port|default(8428) }}
    access: proxy
    isDefault: true
    editable: true
    version: 1
    jsonData:
      timeInterval: "2s"
      queryTimeout: "60s"
      tlsAuth: false
      tlsAuthWithCACert: false
    secureJsonData: {}

  # Pigsty Meta Database (PostgreSQL)
  - name: Meta
    type: postgres
    uid: ds-meta
    url: 127.0.0.1:5432
    access: proxy
    user: dbuser_view
    database: meta
    editable: true
    jsonData: {
      "database": "meta",
      "sslmode": "require",
      "connMaxLifetime": 14400,
      "maxIdleConns": 10,
      "maxOpenConns": 64,
      "postgresVersion": {% if pg_version is defined %}{% if pg_version|int >= 15 %}15{% else %}{{ pg_version }}{% endif %}{% else %}10{% endif %}00,
      "tlsAuth": false,
      "tlsAuthWithCACert": false
    }
    secureJsonData:
      password: {{ grafana_view_password|default('DBUser.Viewer') }}

  # Pigsty Logging Database (VictoriaLogs)
  - name: Logs
    type: victoriametrics-logs-datasource
    uid: ds-vlogs
    url: http://127.0.0.1:{{ vlogs_port|default(9428) }}
    access: proxy
    editable: true

  # Pigsty Tracing Database (VictoriaTraces, Jaeger compatible)
  - name: Traces
    type: jaeger
    uid: ds-vtraces
    url: http://127.0.0.1:{{ vtraces_port|default(10428) }}
    access: proxy
    editable: true

  # Pigsty Static Datasource
  - name: Static
    type: marcusolsson-static-datasource
    uid: ds-static
    editable: true

...
