pg_stat_statements:
  query: |
    SELECT
      queryid,
      LEFT(query, 80) AS query,
      calls,
      mean_exec_time / 1000.0 AS mean_time_seconds,
      total_exec_time / 1000.0 AS total_time_seconds
    FROM pg_stat_statements
    WHERE dbid = (SELECT oid FROM pg_database WHERE datname = 'trails')
    ORDER BY mean_exec_time DESC
    LIMIT 20
  metrics:
    - queryid:
        usage: "LABEL"
        description: "Query ID"
    - query:
        usage: "LABEL"
        description: "Query text (truncated)"
    - calls:
        usage: "GAUGE"
        description: "Number of calls"
    - mean_time_seconds:
        usage: "GAUGE"
        description: "Mean execution time in seconds"
    - total_time_seconds:
        usage: "GAUGE"
        description: "Total execution time in seconds"
