Skip to content

feat: add read-only system metadata collector (experimental)#11

Merged
rokernel merged 2 commits intomasterfrom
feat/system-metadata-collector
Feb 24, 2026
Merged

feat: add read-only system metadata collector (experimental)#11
rokernel merged 2 commits intomasterfrom
feat/system-metadata-collector

Conversation

@rokernel
Copy link
Owner

@rokernel rokernel commented Feb 24, 2026

Summary

  • add a new system_collector that exports:
    • sonic_system_identity_info
    • sonic_system_software_info
    • sonic_system_uptime_seconds
    • collector health metrics (collector_success, scrape_duration_seconds, cache_age_seconds)
  • implement source fallback order to support mixed SONiC versions:
    1. Redis (DEVICE_METADATA|localhost, CHASSIS_INFO|chassis 1)
    2. Read-only files (/etc/sonic/sonic_version.yml, /host/machine.conf, /etc/hostname, /proc/uptime)
    3. Optional read-only command fallbacks (show platform summary --json, show version, show platform syseeprom)
  • enforce safety and stability controls:
    • read-only design (no Redis/file writes)
    • command allowlist
    • command timeout + max output bytes
    • cached refresh path so /metrics stays responsive
    • missing values mapped to unknown
  • add debug-level validation logs to explain:
    • missing expected fields
    • which source populated a field
    • fallback sources ignored due to priority

Stability Decision

system_collector is still experimental and is now disabled by default for stability.

  • SYSTEM_ENABLED default: false
  • Explicit opt-in required:
    • SYSTEM_ENABLED=true ./sonic-exporter

Documentation Updates

README now clearly documents:

  • experimental status and default-off behavior
  • enable command
  • metrics exposed by system collector
  • source order and fallback strategy
  • read-only/security behavior
  • debug logging behavior
  • all SYSTEM_* configuration flags

Data Hygiene

  • test fixtures and examples are anonymized (hostname/serial/model/build metadata)
  • no real confidential values added to repository

Verification

Local

  • go test ./...
  • go build ./...
  • go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8 run

Runtime (both SONiC versions)

Validated on:

  • exoadmin@192.168.240.124 (SONiC 202012)
  • exoadmin@192.168.240.141 (SONiC OS12)

Checks performed:

  1. default behavior (SYSTEM_ENABLED unset): no sonic_system_* metrics exposed
  2. enabled behavior (SYSTEM_ENABLED=true):
    • sonic_system_identity_info present
    • sonic_system_software_info present
    • sonic_system_uptime_seconds present
    • sonic_system_collector_success 1
  3. debug behavior: clear logs for expected missing fields and fallback decisions

@rokernel rokernel changed the title feat: add read-only system metadata collector feat: add read-only system metadata collector (experimental) Feb 24, 2026
@rokernel rokernel merged commit a93335f into master Feb 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant