diff --git a/packages/client/README.md b/packages/client/README.md index 5eb589fe0f..42465bb9ba 100644 --- a/packages/client/README.md +++ b/packages/client/README.md @@ -308,7 +308,7 @@ dist/bin/cli.js --d ## Metrics The client can optionally collect metrics using the Prometheus metrics platform and expose them via an HTTP endpoint with the following CLI flags. -The current metrics that are reported by the client can be found [here](./src/util//metrics.ts). +The current metrics that are reported by the client can be found at the default port and route: `localhost:8000/metrics`. ```sh # npm installation @@ -318,8 +318,6 @@ ethereumjs --prometheus npm run client:start:ts -- --prometheus --prometheusPort=9123 ``` -Note: The Prometheus endpoint runs on port 8000 by default - ## API [API Reference](./docs/README.md) diff --git a/packages/client/bin/cli.ts b/packages/client/bin/cli.ts index 4b2d1c1ba1..1bd8c5e2e0 100755 --- a/packages/client/bin/cli.ts +++ b/packages/client/bin/cli.ts @@ -1122,10 +1122,16 @@ async function run() { const reqUrl = new url.URL(req.url, `http://${req.headers.host}`) const route = reqUrl.pathname - if (route === '/metrics') { - // Return all metrics in the Prometheus exposition format - res.setHeader('Content-Type', register.contentType) - res.end(await register.metrics()) + switch (route) { + case '/metrics': + // Return all metrics in the Prometheus exposition format + res.setHeader('Content-Type', register.contentType) + res.end(await register.metrics()) + break + default: + res.statusCode = 404 + res.end('Not found') + return } }) // Start the HTTP server which exposes the metrics on http://localhost:${args.prometheusPort}/metrics