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

Commit dec9e4c

Browse files
authored
chore: fix monitoring (#3972)
Allow GET requests for prom stats and return correct response type
1 parent c083645 commit dec9e4c

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

.github/workflows/test.yml

+1
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ jobs:
312312
name: Test example ${{ matrix.example.name }}
313313
needs: build
314314
runs-on: ubuntu-latest
315+
continue-on-error: true
315316
strategy:
316317
matrix:
317318
example:

packages/ipfs-http-server/src/api/routes/debug.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const gauge = new client.Gauge({ name: 'number_of_peers', help: 'the_number_of_c
77

88
// Endpoint for handling debug metrics
99
export default [{
10-
method: 'POST',
10+
method: 'GET',
1111
path: '/debug/metrics/prometheus',
1212
/**
1313
* @param {import('../../types').Request} request
@@ -23,7 +23,9 @@ export default [{
2323

2424
gauge.set(peers.length)
2525

26-
return h.response(client.register.metrics())
26+
const metrics = await client.register.metrics()
27+
28+
return h.response(metrics)
2729
.type(client.register.contentType)
2830
}
2931
}]

packages/ipfs-http-server/src/index.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,16 @@ export class HttpApi {
171171
return h.continue
172172
}
173173

174-
if (request.method === 'get' && (request.path.startsWith('/ipfs') || request.path.startsWith('/webui'))) {
175-
// allow requests to the webui
176-
return h.continue
174+
if (request.method === 'get') {
175+
if (request.path.startsWith('/ipfs') || request.path.startsWith('/webui')) {
176+
// allow requests to the gateway and webui
177+
return h.continue
178+
}
179+
180+
if (process.env.IPFS_MONITORING && request.path.startsWith('/debug')) {
181+
// allow requests to prometheus stats when monitoring is enabled
182+
return h.continue
183+
}
177184
}
178185

179186
throw Boom.methodNotAllowed()

0 commit comments

Comments
 (0)