• Type: Improvement
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Server Ingress Security
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Overview

      Expose a gauge for online host CPU cores so SREs can compute Monguard process CPU as % of host, instead of absolute cores from monguard_process_cpu_seconds_total alone.

      Background

      Fleet Overview currently shows Peak Monguard CPU (cores) by Region:

      max by (xgen_region) (rate(monguard_process_cpu_seconds_total[$interval]))
      

      That metric is correct for process load in cores (from /proc/self/stat utime+stime), but it is not host utilization. Without a core count (or cgroup quota), dashboards cannot answer \"how much of the box is Monguard using?\" and %-style panels are misleading.

      Proposed metric

      * Name: monguard_host_cpu_cores
      * Type: Gauge (int)
      * Help: Number of online CPUs available to the process/host
      * Source (preferred order):
      *# sysconf(_SC_NPROCESSORS_ONLN) (simple, matches typical host view)
      *# If running under cgroup CPU quota (container), prefer effective quota cores from cpu.max / cpu.cfs_quota_us+cpu.cfs_period_us when quota is set — document which source wins
      * Refresh: alongside existing refresh_process_metrics() in monguard/src/observability/metrics.rs

      Dashboard / PromQL (follow-up once metric ships)

      
      h1. Peak Monguard CPU % of host by region
      max by \(xgen\_region\) \(
        100 \* rate\(monguard\_process\_cpu\_seconds\_total{...}\[$interval\]\)
          / monguard\_host\_cpu\_cores{...}
      \)
      

      Optional later (out of scope unless cheap): host busy % from aggregate /proc/stat cpu line — only needed if node_exporter is unavailable on these hosts.

      Scope

      * Add monguard_host_cpu_cores + unit test / proc-read coverage
      * Keep monguard_process_cpu_seconds_total (consider Counter vs Gauge cleanup as a separate note if touching the same code)
      * Update Fleet Overview panel once metric is scraped in prod (or document query for manual panel edit)
      * Do not replace the cores-based peak panel until the new metric is verified on a sample of regions/instance sizes

      Acceptance criteria

      * Metric present on /metrics on Linux
      * Value matches online CPU count (or documented cgroup effective cores) on test hosts
      * Documented PromQL for process % of host
      * No change to existing process CPU seconds semantics

            Assignee:
            Nairuz Elmadbooh
            Reporter:
            Anand Paithankar
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: