Skip to content

Conversation

andsel
Copy link
Contributor

@andsel andsel commented Aug 1, 2025

Release notes

[rn:skip]

What does this PR do?

Create a new histogram metric type. Updated all metric infrastructure code, the core class is HistogramMetric which uses HdrHistogram Recorder to track the measurements and produces a new HistogramSnapshot every time getValue is invoked, clearing the measurements stored in the Recorder.
HistogramSnapshot is a data class that exposes 75Percentile and 90Percentile (at the moment).

To verify the effectiveness of this, the memory queue read client was updated to expose a metric to track the batch size.

Created a new setting named pipeline.batch.metrics with values "true" and "false" (at the moment), to enable and disable the computation of such metrics. This setting is a string because in a follow up PR will become a tri-state flag.

Why is it important/What is the impact to the user?

This is an intermediate step, it has to proof the exposition of new metric section under the _node/stats API endpoint like:

"pipelines": {
    "main": {
      ...
      "batch": {
        "event_size": {
          "p75": 12.4
          "p90": 13.1
        }
    }
  }
}

Percentiles are also pushed down to ES when leveraging the monitoring.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files (and/or docker env variables)
  • I have added tests that prove my fix is effective or that my feature works

Author's Checklist

  • Check with xpack monitoring

How to test this PR locally

Run Logstash with the setting pipeline.batch.metrics with values "true" and verify that node stats exposes the batch_size histogram.

curl http://localhost:9600/_node/stats | jq .pipelines.main.events

Related issues

Use cases

Screenshots

Logs

@andsel andsel self-assigned this Aug 1, 2025
Copy link
Contributor

github-actions bot commented Aug 1, 2025

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

Copy link
Contributor

mergify bot commented Aug 1, 2025

This pull request does not have a backport label. Could you fix it @andsel? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit.
  • If no backport is necessary, please add the backport-skip label

/**
* Class to expose percentiles retrieved from an HdrHistogram.
* */
public final class HistogramSnapshot implements Serializable {
Copy link
Contributor Author

@andsel andsel Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for reviewer

Implements Serializable so that Valuefier can use the identity converter.

)
);
converters.put(SecretVariable.class, JAVAUTIL_CONVERTER);
converters.put(HistogramSnapshot.class, JAVAUTIL_CONVERTER);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for reviewer

The x-pack monitoring pipeline create Logstash events which contains this snapshot, and need to be converted to Ruby object in the Rubyfier.deep method.

@andsel andsel force-pushed the feature/introduce_histogram_metric branch from 506c59c to 1e27899 Compare August 13, 2025 08:20
Copy link

@elasticmachine
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

History

cc @andsel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Define a new kind of metric that represents the histograms in a flow metric fashion, create histogram metric type

2 participants