Skip to content

Instantly share code, notes, and snippets.

@christophemarois
Last active October 2, 2023 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christophemarois/11f6cec92a08f845103071d4dbc00de5 to your computer and use it in GitHub Desktop.
Save christophemarois/11f6cec92a08f845103071d4dbc00de5 to your computer and use it in GitHub Desktop.
Node Grafana/Prometheus Performance Monitoring

Monitor in Node (PerformanceObserver is not yet implemented in Bun. in bun 1.0.3)

import { collectDefaultMetrics, register } from 'prom-client'

if (req.method === 'GET' && pathname === '/metrics/') {
  return new Response(await register.metrics(), {
    headers: {
      'Content-Type': register.contentType,
    },
  })
}

In fly.toml

[metrics]
port = 4000
path = "/metrics"

Then inspect at https://fly-metrics.net/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment