Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

node-mixin: Adjust `memory used` Dashboard to use `MemAvailable`

Aperta Adatta ai principianti
#3,830 3 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
75/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
linux, prometheus
Ambito
observability

Direzione di ricerca

L'issue punta al file specifico docs/node-mixin/lib/prom-mixin.libsonnet righe 126-137 e al file delle regole docs/node-mixin/rules/rules.libsonnet. Inizia esaminando la formula attuale del dashboard della memoria utilizzata e la regola di utilizzo della memoria esistente che già utilizza MemAvailable. Il compito è aggiornare la formula del dashboard per utilizzare MemAvailable con un fallback al calcolo precedente per compatibilità. Verifica la modifica controllando la struttura del mixin JSONnet e comprendendo come vengono costruite le query di Prometheus.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Currently, the memory used dashboard in the node-mixin for Linux uses the formula

\text{memory used} = \text{MemTotal} - \text{MemFree} - \text{Buffers} - \text{Cached}

https://github.com/prometheus/node_exporter/blob/125a02099cde708ee9c99fddcc29a2703e92c576/docs/node-mixin/lib/prom-mixin.libsonnet#L126-L137

The Linux kernel introduced MemAvailable specifically because the formula above is a less accurate estimation of usable memory. As a result, a more accurate number for memory usage would be

\text{memory used} = \text{MemTotal} - \text{MemAvailable}

We encouraged gopsutil to adopt the same formula to calculate usage and psutil adopted it at coincidentally the same time (but independent of our gopsutil suggestion).

I see that the memory utilization dashboard already accounts for this: https://github.com/prometheus/node_exporter/blob/125a02099cde708ee9c99fddcc29a2703e92c576/docs/node-mixin/rules/rules.libsonnet#L43-L58

Should the memory used dashboard do the same thing? I assume if it did something like this:

  node_memory_MemTotal_bytes{%(nodeExporterSelector)s} - (
    node_memory_MemAvailable_bytes{%(nodeExporterSelector)s}
    or
    (
      node_memory_Buffers_bytes{%(nodeExporterSelector)s}
      +
      node_memory_Cached_bytes{%(nodeExporterSelector)s}
      +
      node_memory_MemFree_bytes{%(nodeExporterSelector)s}
    )
  )

That would make it so users on Linux environments that don't provide MemAvailable wouldn't be broken, but the rest could get a more accurate value that is similar to the calculation already being done in the utilization dashboard.

P.S. The way free used to calculated this in the past also included SReclaimable as part of the calculation alongside Cached, Buffers, and MemFree, and gopsutil used to do the same thing. I'm unsure whether it's worth it at this point to mess with the existing approximation formula in the dashboard, but I figured I would bring it up.

Lingua principale
Go
Stelle
13.8k
Fork
2.7k
Merge medio
1g 4h
PR unite (30g)
7

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di prometheus/node_exporter

Tutte le issue di prometheus/node_exporter

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.