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

chore: fix monitoring #3972

Merged
merged 3 commits into from
Dec 13, 2021
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
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