Skip to content

Enforce module identity across metric alerts #8141

Closed
NethServer/ns8-metrics
#79

Description

@Amygos

Problem

Module-provided metrics and alerts need a consistent module identity before
provider-published alert rules can be safely introduced.

Without module-level isolation, data and alert state belonging to different
module instances can overlap.

Proposed solution

Establish module identity across the metrics and alert flow as the foundation
for provider-published alert rules, while preserving existing behavior.

Implementation and compatibility details are documented in
NethServer/ns8-metrics#79.

Activity

  1. added theissue type on Aug 31, 2026
  2. moved this from ToDo to In Progress in NethServeron Aug 31, 2026
  3. linked a pull request that will close this issueEnforce module identity across metric alerts #79on Aug 31, 2026
  4. Amygos commented on Aug 31, 2026

    @Amygos
    MemberAuthor

    In Testing:

    • metrics 1.3.2-dev.1
  5. added this to the NethServer 8.10 milestone on Aug 31, 2026
  6. added
    testingPackages are available from testing repositories
    on Aug 31, 2026
  7. moved this from In Progress to Testing in NethServeron Aug 31, 2026
  8. Amygos commented on Aug 31, 2026

    @Amygos
    MemberAuthor

    Manual QA — module_id label

    Preconditions

    • Install the testing image as metrics1.
    • Run the tests from a root shell on the leader node.
    • Inspect generated state with:
    runagent -m metrics1
    cd ~/.config/state

    QA-MID-01 — Add a missing module_id

    Publish a target without module_id:

    redis-cli -x HSET module/qaapp1/metrics_targets application <<'YAML'
    - targets:
      - 127.0.0.1:65531
      labels:
        node: "1"
        environment: qa
    YAML
    
    redis-cli PUBLISH module/qaapp1/event/metrics-target-changed '{}'

    Expected result:

    • The generated target contains module_id: qaapp1.
    • The value is derived from the Redis key.
    • Existing labels remain unchanged.
    • Prometheus discovers the target with module_id="qaapp1".

    QA-MID-02 — Replace a conflicting module_id

    Publish the following target under module/qaapp1/metrics_targets:

    - targets:
      - 127.0.0.1:65531
      labels:
        module_id: qaapp2
        node: "1"

    Expected result:

    • The generated target contains module_id: qaapp1.
    • The supplied qaapp2 value cannot override the Redis-derived identity.
    • Metrics logs report module_id='qaapp2' overwritten with 'qaapp1' and identify the Redis key, field, and item position.
    • Prometheus remains operational.

    QA-MID-03 — Preserve a matching module_id

    Publish:

    - targets:
      - 127.0.0.1:65531
      labels:
        module_id: qaapp1
        node: "1"

    Expected result:

    • module_id: qaapp1 remains unchanged.
    • No module_id conflict warning is logged.
    • Other labels remain unchanged.

    QA-MID-04 — Separate different module instances

    Publish equivalent targets under:

    module/qaapp1/metrics_targets
    module/qaapp2/metrics_targets
    

    Expected result:

    • The first generated target has module_id: qaapp1.
    • The second generated target has module_id: qaapp2.
    • Both targets appear independently in Prometheus, even if their addresses and other labels are identical.

    QA-MID-05 — Add module_id to every target item

    Publish multiple items in one field:

    - targets:
      - 127.0.0.1:65531
      labels:
        node: "1"
    - targets:
      - 127.0.0.1:65532
      labels:
        node: "2"

    Expected result:

    • Every item contains the Redis-derived module_id.
    • No item is left without module_id.
    • Item-specific labels remain unchanged.

    QA-MID-06 — Keep built-in node targets module-less

    Inspect every generated file matching:

    prometheus.d/node_*.yml
    

    Expected result:

    • Built-in node targets do not contain module_id.
    • Existing node targets remain visible in Prometheus.

    Cleanup

    redis-cli DEL \
      module/qaapp1/metrics_targets \
      module/qaapp2/metrics_targets
    
    redis-cli PUBLISH module/qaapp1/event/metrics-target-changed '{}'
  9. DavidePrincipi commented on Sep 17, 2026

    @DavidePrincipi
    Member

    Test cases VERIFIED

  10. removed their assignment
    on Sep 17, 2026
  11. removed
    testingPackages are available from testing repositories
    on Sep 17, 2026
  12. moved this from Testing to Verified in NethServeron Sep 17, 2026
  13. DavidePrincipi commented on Sep 18, 2026

    @DavidePrincipi
    Member
  14. moved this from Verified to Done in NethServeron Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    verifiedAll test cases were verified successfully

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions