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

fix: add node memory stats to prometheus output #4209

Merged
merged 2 commits into from
Sep 16, 2022
Merged
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
12 changes: 11 additions & 1 deletion packages/ipfs-http-server/src/api/routes/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ import { disable, enable } from '@libp2p/logger'
client.register.clear()

/** @type {Record<string, client.Gauge<any>>} */
const gauges = {}
const gauges = {
nodejs_memory_usage: new client.Gauge({
name: 'nodejs_memory_usage',
help: 'nodejs_memory_usage',
labelNames: Object.keys(process.memoryUsage())
})
}

// Endpoint for handling debug metrics
export default [{
Expand All @@ -23,6 +29,10 @@ export default [{
throw Boom.notImplemented('Monitoring is disabled. Enable it by setting environment variable IPFS_MONITORING')
}

Object.entries(process.memoryUsage()).forEach(([key, value]) => {
gauges.nodejs_memory_usage.set({ [key]: key }, value)
})

const { ipfs } = request.server.app
// @ts-expect-error libp2p does not exist on ipfs
const metrics = ipfs.libp2p.metrics
Expand Down