Skip to content

Instantly share code, notes, and snippets.

@stand-sure
Created June 18, 2023 16:44
Show Gist options
  • Save stand-sure/5148790e26b745bcec3d7a385f07dd22 to your computer and use it in GitHub Desktop.
Save stand-sure/5148790e26b745bcec3d7a385f07dd22 to your computer and use it in GitHub Desktop.
nextjs prometheus metrics
import {collectDefaultMetrics, register} from 'prom-client';
collectDefaultMetrics({ register });
export async function GET() {
const metrics : string = await register.metrics();
return new Response(metrics, {
status: 200,
headers: {
"Content-Type": register.contentType,
},
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment