supabase / supavisor

A cloud-native, multi-tenant Postgres connection pooler.
https://supabase.github.io/supavisor/
Apache License 2.0
1.65k stars 54 forks source link

How to config metrics properly #335

Open dfang opened 2 months ago

dfang commented 2 months ago

Improve documentation

Link

https://supabase.github.io/supavisor/monitoring/metrics/

Describe the problem

curl -X 'GET' 'http://localhost:4000/metrics/supabase-staging' -H 'accept: application/json' -H 'Content-Type: application/json' -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2ODAxNjIxNTR9.U9orU6YYqXAtpF8uAiw6MS553tm4XxRzxOhz2IwDhpY' | jq

curl -X 'GET' 'http://localhost:4000/metrics' -H 'accept: application/json' -H 'Content-Type: application/json' -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2ODAxNjIxNTR9.U9orU6YYqXAtpF8uAiw6MS553tm4XxRzxOhz2IwDhpY' | jq

both return nothing

Describe the improvement

How to config metrics properly ?

J0 commented 2 months ago

Hey @dfang,

Thanks for flagging the issue. Mind sharing what your setup looks like?

I'm running

  1. make dev
  2. make db_start
  3. curl -X 'GET' 'http://localhost:4000/metrics' -H 'accept: application/json' -H 'Content-Type: application/json' -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2ODAxNjIxNTR9.U9orU6YYqXAtpF8uAiw6MS553tm4XxRzxOhz2IwDhpY' | jq

and am able to receive metrics.

Here's a truncated sample:

# HELP supavisor_prom_ex_phoenix_endpoint_port_info The configured port of the Endpoint module.
# TYPE supavisor_prom_ex_phoenix_endpoint_port_info gauge
supavisor_prom_ex_phoenix_endpoint_port_info{endpoint="SupavisorWeb.Endpoint",port="4000",host="127.0.0.1",region="eu",short_alloc_id="111e4567"} 1
# HELP supavisor_prom_ex_phoenix_endpoint_url_info The configured URL of the Endpoint module.
# TYPE supavisor_prom_ex_phoenix_endpoint_url_info gauge
supavisor_prom_ex_phoenix_endpoint_url_info{endpoint="SupavisorWeb.Endpoint",url="http://localhost:4000",host="127.0.0.1",region="eu",short_alloc_id="111e4567"} 1
# HELP supavisor_prom_ex_beam_system_schedulers_online_info The number of scheduler threads that are online.
# TYPE supavisor_prom_ex_beam_system_schedulers_online_info gauge
supavisor_prom_ex_beam_system_schedulers_online_info{host="127.0.0.1",region="eu",short_alloc_id="111e4567"} 10
# HELP supavisor_prom_ex_beam_system_schedulers_info The number of scheduler threads in use by the BEAM.
# TYPE supavisor_prom_ex_beam_system_schedulers_info gauge
supavisor_prom_ex_beam_system_schedulers_info{host="127.0.0.1",region="eu",short_alloc_id="111e4567"} 10
# HELP supavisor_prom_ex_beam_system_dirty_io_schedulers_info The total number of dirty I/O schedulers used to execute I/O bound native functions.
# TYPE supavisor_prom_ex_beam_system_dirty_io_schedulers_info gauge
dfang commented 1 month ago
version: '3'

services:
  supavisor:
    image: supabase/supavisor:1.1.45
    container_name: supavisor
    restart: always
    ports:
      - 4000:4000
      - 5452:5452
      - 6543:6543
    environment:
      PORT: 4000
      PROXY_PORT_SESSION: 5452
      PROXY_PORT_TRANSACTION: 6543
      # DATABASE_URL: "ecto://postgres:postgres@host.docker.internal:5432/postgres"
      DATABASE_URL: "ecto://supavisor:5w8JwUGH7wJBJflTPanW6wfiV7+7glCUCe3g@172.16.0.11:5432/postgres"
      # DATABASE_URL: "ecto://postgres:password@db:5432/postgres"
      CLUSTER_POSTGRES: "true"
      SECRET_KEY_BASE: "4dbd5a53cd015363f63942622186ba205b498708f8b84679aaf9878737a766b2"
      VAULT_ENC_KEY: "12345678901234567890123456789032"
      API_JWT_SECRET: "dev"
      METRICS_JWT_SECRET: "b8b55cf842a180997addc72c10493adbe35f6b2d13b223a9aa105b189a695317"
      REGION: "local"
      ERL_AFLAGS: -proto_dist inet_tcp
    depends_on:
      - db
    command:  sh -c "/app/bin/migrate && /app/bin/server"