Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
chore: fix monitoring (#3972)
Browse files Browse the repository at this point in the history
Allow GET requests for prom stats and return correct response type
  • Loading branch information
achingbrain authored Dec 13, 2021
1 parent c083645 commit dec9e4c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ jobs:
name: Test example ${{ matrix.example.name }}
needs: build
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
example:
Expand Down
6 changes: 4 additions & 2 deletions packages/ipfs-http-server/src/api/routes/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const gauge = new client.Gauge({ name: 'number_of_peers', help: 'the_number_of_c

// Endpoint for handling debug metrics
export default [{
method: 'POST',
method: 'GET',
path: '/debug/metrics/prometheus',
/**
* @param {import('../../types').Request} request
Expand All @@ -23,7 +23,9 @@ export default [{

gauge.set(peers.length)

return h.response(client.register.metrics())
const metrics = await client.register.metrics()

return h.response(metrics)
.type(client.register.contentType)
}
}]
13 changes: 10 additions & 3 deletions packages/ipfs-http-server/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,16 @@ export class HttpApi {
return h.continue
}

if (request.method === 'get' && (request.path.startsWith('/ipfs') || request.path.startsWith('/webui'))) {
// allow requests to the webui
return h.continue
if (request.method === 'get') {
if (request.path.startsWith('/ipfs') || request.path.startsWith('/webui')) {
// allow requests to the gateway and webui
return h.continue
}

if (process.env.IPFS_MONITORING && request.path.startsWith('/debug')) {
// allow requests to prometheus stats when monitoring is enabled
return h.continue
}
}

throw Boom.methodNotAllowed()
Expand Down

0 comments on commit dec9e4c

Please sign in to comment.