Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add histogram metrics #154

Open
TNohaic opened this issue Apr 10, 2024 · 0 comments
Open

Add histogram metrics #154

TNohaic opened this issue Apr 10, 2024 · 0 comments

Comments

@TNohaic
Copy link
Contributor

TNohaic commented Apr 10, 2024

Use case

We want to be able to collect histogram metrics to represent statistics on summaries such as "how many HTTP responses take less than 30ms"

1. Definition of Histogram Metric in the Connector's Metrics Section

Example Metric Definition:

metrics: 
  http.server.response_time:
    unit: s
    type: histogram
    buckets: [ 0, 0.001, 1, 5, 20, +Inf ]

This requires modifications to the model, particularly the MetricDefinition class of the Connector. The changes include:

  • Supporting the histogram type.
  • Adding buckets.

2. Collection of Histograms in the Connector (Mapping)

Example Mapping:

mapping:
  type: histogram  # table | histogram | singleton
  source: ${source::T1}
  attributes:
    id: $2
    http.method: $1
    http.path: $2
  metrics:
    http.server.response_time: $3
    http.server.length:
      description: "Measures the duration for an HTTP server to process a request and send a response."
      unit: by
      buckets: []
      type: histogram
      value: $4

Required Actions:

  • Modify the Mapping class:
    • Add a type for the mapping (table (default), histogram, singleton).
    • Update the metrics section of the Mapping class to allow adding metadata and metric values directly without using metrics (description, unit, buckets, type, and value) defined in the top section of the YAML connector.
  • Update metricshub-engine (discovery and collect strategies) to interpret the new mapping type:
    • In the current mapping, a metric receives only one value. In histogram mapping, a metric will receive multiple values. We need to identify the monitor we are collecting to attribute the histogram metric. This can be done with an attribute key: id specified by the developer in the attributes section of the mapping, or with other attributes identified in the keys section of the job collect multi-instances.

Example:

collect:
  type: multiInstance
  keys:
  - http.path

3. Update metricshub-agent to Implement an Observer on the Metric and Record All Values per Collect

  • Create a DoubleHistogramBuilder object with the correct buckets and record values at each collection.
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

No branches or pull requests

1 participant