Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prometheus cleanup #3583

Merged
merged 3 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions packages/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
14 changes: 10 additions & 4 deletions packages/client/bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading