Problem/Motivation

Collectors emit both an unlabeled total AND per-label metrics, causing sum() queries in Prometheus to return incorrect results.

Affected collectors:

  • NodeCount / RevisionCount
  • UserCount
  • CommentCollector

For example:

# HELP drupal_revision_count_total Total revision count.
# TYPE drupal_revision_count_total gauge
drupal_revision_count_total 1
drupal_revision_count_total{bundle="article"} 1
drupal_revision_count_total{bundle="page"} 0

When I do a sum(drupal_revision_count_total) I'll get the count of 1 with no labels, but also the count for the bundle="article".

Proposed resolution

Only emit labeled metrics when labels are configured. This follows Prometheus best practices.

  • NodeCount/RevisionCount: emit per-bundle metrics only when bundles configured, otherwise emit unlabeled total
  • UserCount: emit only activated/blocked labeled metrics
  • CommentCollector: emit only published/not published labeled metrics

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

nterbogt created an issue. See original summary.

kim.pepper made their first commit to this issue’s fork.

kim.pepper’s picture

Title: Double counting » Double-counting when using labels for subgroups
Issue summary: View changes
Status: Active » Needs review

MR ready for review.

Updated IS and title

  • kim.pepper committed e2d873b9 on 2.x
    fix: #3587926 Double-counting when using labels for subgroups
    
    By:...
kim.pepper’s picture

Status: Needs review » Fixed

Committed to 2.x

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.