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

Extend metrics intake to accept histograms #4884

Closed
axw opened this issue Mar 2, 2021 · 4 comments · Fixed by #5360
Closed

Extend metrics intake to accept histograms #4884

axw opened this issue Mar 2, 2021 · 4 comments · Fixed by #5360
Assignees
Milestone

Comments

@axw
Copy link
Member

axw commented Mar 2, 2021

Agents should be able to send self-describing histogram (values and counts) and summary (sum and count) metrics. We need to be able to identify the metric type, either from an explicit "type" field or inferred from the type-specific fields that are specified (e.g. counts & values specified? it's a histogram).

@axw
Copy link
Member Author

axw commented Apr 15, 2021

Application metrics sent by agents currently look like:

{
    "timestamp": 123456,
    "tags": {"a": "b", "c": "d"},
    "samples": {
      "metric_name": {
        "value": 123.456
      }
    }
}

There's nothing saying whether a metric is a gauge (point in time) or a counter (monotonically increasing). It's also not possible to record multi-value aggregated metrics (histograms, summaries).

I propose we extend the object format of samples with additional optional fields:

  • type: one of "gauge", "counter", "distribution" or "summary"
  • unit: one of "percent", "byte", or a time unit (i.e. follow the rules defined at https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-field-meta.html)
  • counts and values: counts and values for a distribution-type metric (both required if type is "distribution", and must have the same length; neither allowed otherwise)
  • count, sum, min, max: metrics for a summary-type metric (count and sum are required and min and max are optional if type is summary; none are allowed otherwise)

The server will use unit and type to set field metadata:

  • if unit is set (and valid), we will set the unit field metadata to the same value
  • if type is set to gauge or counter, we will set the metric_type field metadata to the same value
  • if neither type nor unit are specified, we will not set any field metadata

Example latency distribution metric:

{
    "timestamp": 123456,
    "samples": {
      "latency_distribution": {
        "type": "distribution",
        "unit": "micros",
        "counts": [3, 2, 1, 0, 0, 1],
        "values": [0.01, 0.1, 1, 10, 100, 1000]
      }
    }
}

Example summary metric:

{
    "timestamp": 123456,
    "samples": {
      "span.self_time": {
        "type": "summary",
        "unit": "micros",
        "sum": "123.456",
        "count": "7"
      }
    }
}

@felixbarny
Copy link
Member

Looks good!
Questions:

{
    "timestamp": 123456,
    "samples": {
      "span.self_time": {
        "type": "summary",
        "unit": "micros",
        "sum": "123.456",
        "count": "7"
      }
    }
}
{
    "timestamp": 123456,
    "samples": {
      "span.self_time.count": {
        "value": "7"
      }
    }
},
{
    "timestamp": 123456,
    "samples": {
      "span.self_time.sum": {
        "value": "123.456"
      }
    }
}

Should agents update send their breakdown metrics in the new format if they are sending data to an APM Server that understands the new format?
Should agents not sent histograms to APM server if they are connected to an older version that doesn't support them yet?

@axw
Copy link
Member Author

axw commented Apr 15, 2021

@felixbarny

How is the unit going to be used? Does it have an effect to the UI?

It will eventually be used by Kibana: elastic/kibana#82348

Which type should we use for resetting counters?

I think for resetting counters we should omit type for now, and discuss an addition like "resetting_counter" or "delta" with the Metrics, Elasticsearch, and Kibana/Lens teams.

Backward compatibility with the old metrics format. Are these interpreted similarly?

No, a summary type will end up in a single aggregate_metric_double field.

Should agents update send their breakdown metrics in the new format if they are sending data to an APM Server that understands the new format?

Eventually yes, but I don't think we should do that just now. We'll need to figure out a migration plan. I'm not sure how that'll work yet.

Should agents not sent histograms to APM server if they are connected to an older version that doesn't support them yet?

I think that would be best. The current JSON Schema says that "value" is required, but that field will not be sent for histograms or summaries.

@axw
Copy link
Member Author

axw commented May 28, 2021

Due to some issues related to the aggregate_metric_double field type, I'm going to remove summaries from the initial implementation. I've created #5359 to track that separately.

@axw axw changed the title Extend metrics intake to accept histograms and summaries Extend metrics intake to accept histograms May 28, 2021
@axw axw added this to the 7.14 milestone May 30, 2021
@axw axw closed this as completed in #5360 Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants