Hide metrics endpoint

Hello,

I have a nodejs app hosted on fly.io, I wanted to add a few custom metrics so I’ve added the /metrics endpoint

[http_service]
  internal_port = 3000
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 0
  processes = ["app"]

[metrics]
  port = 3000
  path = "/metrics"
  processes = ["app"]

[env]
  PORT="3000"
  HOSTNAME="0.0.0.0"
  NODE_ENV="production"

using prom-client I’m able to see my new metrics in Grafana, the issue I have is that I don’t like to have metrics public, is there to hide the metrics endpoint and make it available only to fly.io to scrape the metrics?

You should expose your metrics endpoint on a separate port instead of on 3000.

mmm I’m a bit confused, if I change the metrics port:

[metrics]
  port = 9091 (or any other port)
  path = "/metrics"
  processes = ["app"]

am I missing something?

You’ll need to serve the metrics endpoint from a web server running on a different port in your application, then update the fly.toml to point the metrics config to that port.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.