Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở Phù hợp với người mới
#3,830 3 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
75/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
linux, prometheus
Lĩnh vực
observability

Hướng nghiên cứu

Issue chỉ ra tệp cụ thể docs/node-mixin/lib/prom-mixin.libsonnet dòng 126-137 và tệp quy tắc docs/node-mixin/rules/rules.libsonnet. Bắt đầu bằng cách kiểm tra công thức bảng điều khiển bộ nhớ đã sử dụng hiện tại và quy tắc sử dụng bộ nhớ hiện có đã sử dụng MemAvailable. Nhiệm vụ là cập nhật công thức bảng điều khiển để sử dụng MemAvailable với phương án dự phòng là tính toán cũ để tương thích. Xác minh thay đổi bằng cách kiểm tra cấu trúc mixin JSONnet và hiểu cách các truy vấn Prometheus được xây dựng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Go
Star
13.8k
Fork
2.7k
Merge trung bình
1 ngày 4 giờ
Pull request đã merge (30 ngày)
7

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của prometheus/node_exporter

Tất cả issue của prometheus/node_exporter

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.