Skip to content
Snippets Groups Projects
Commit d03809c8 authored by kawa.acikgoez's avatar kawa.acikgoez Committed by julian.baeume
Browse files

Add: redis memory gauge

parent a738be84
No related branches found
No related tags found
No related merge requests found
......@@ -47,6 +47,35 @@ export const versionCountGauge = new Gauge({
}
})
export const usedMemoryGauge = new Gauge({
name: 'redis_used_ram',
help: 'Total used memory in human readable units and as a percentage (RSS / total memory)',
labelNames: ['memory_type'],
async collect () {
redis.client.info('memory', (err, result) => {
if (err) {
throw err
}
// Parse the result
const infoLines = result.split('\r\n')
const memoryInfo = {}
for (const line of infoLines) {
const [key, value] = line.split(':')
if (key && value) {
memoryInfo[key] = value
}
}
const usedMemoryRSS = parseFloat(memoryInfo.used_memory_rss)
const memoryTotal = parseFloat(memoryInfo.total_system_memory)
this.set({ memory_type: 'usedMemoryRSSHuman' }, usedMemoryRSS)
this.set({ memory_type: 'totalUsedMemoryPercentage' }, usedMemoryRSS / memoryTotal)
})
}
})
export function set (key, value, timeout) {
logger.debug(`[Cache] Set ${key}`)
if (cache[key] === value) return
......@@ -62,7 +91,6 @@ export async function clear () {
}
fileCacheSizeGauge.reset()
}
export async function get (key, fallback) {
if (cache[key]) {
logger.debug(`[Cache] Resolve from memory: ${key}`)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment