Skip to content

[receiver/awsfirehose] Support all possible quantiles of CloudWatch metrics #39687

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

Merged

Conversation

yiquanzhou
Copy link
Contributor

@yiquanzhou yiquanzhou commented Apr 28, 2025

Description

This PR is an enhancement to the awsfirehose receiver.

By default, CloudWatch metric streams only include four statistics – Minimum, Maximum, Sample Count and Sum. But we can add additional statistics for specific metrics, including p70, p80, p90, p95 and p99 percentiles:

image

These additional statistics will be added to the firehose request payload. Example:

{
  "metric_stream_name": "firehose-metrics-stream",
  "account_id": "1234567890",
  "region": "eu-west-1",
  "namespace": "AWS/EC2",
  "metric_name": "CPUUtilization",
  "dimensions": {
    "InstanceId": "i-0a05ddddd2acb83a7"
  },
  "timestamp": 1745849100000,
  "value": {
    "max": 31.435,
    "min": 25.83666666666667,
    "sum": 140.94833333333332,
    "count": 5,
    "p99": 31.40867565167042,
    "p90": 31.172746310692506,
    "p95": 31.303598519605032
  },
  "unit": "Percent"
}

These values are currently ignored during unmarshalling. This PR adds these fields as optional fields during deserialization and adds the values to the summary quantiles.

Testing

Enrich existing unit test.

@yiquanzhou yiquanzhou requested a review from a team as a code owner April 28, 2025 14:48
@yiquanzhou yiquanzhou requested a review from mx-psi April 28, 2025 14:48
Copy link
Contributor

@axw axw left a comment

Choose a reason for hiding this comment

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

@yiquanzhou looks good. I'm pretty sure you can specify additional percentiles, but I think that could be handled as a followup. If you'd prefer to defer, maybe just update the changelog note to clarify that this only handles a fixed set of percentiles?

component: awsfirehosereceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: support all possible quantile values (0.7, 0.8, 0.9, 0.95, 0.99) of CloudWatch metrics in addition to quantile 0 (min) and 1 (max)
Copy link
Contributor

Choose a reason for hiding this comment

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

IIANM you can specify arbitrary percentiles, and you're not restricted to the ones in the drop down in CloudWatch

Comment on lines 53 to 62
// P70 is the 70th percentile of observed values. This value is optional.
P70 *float64 `json:"p70"`
// P80 is the 80th percentile of observed values. This value is optional.
P80 *float64 `json:"p80"`
// P90 is the 90th percentile of observed values. This value is optional.
P90 *float64 `json:"p90"`
// P95 is the 95th percentile of observed values. This value is optional.
P95 *float64 `json:"p95"`
// P99 is the 99th percentile of observed values. This value is optional.
P99 *float64 `json:"p99"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this is good enough to start with, but to handle arbitrary percentiles we would need to either decode the stats to a map and parse the keys, or otherwise stream parse the stats.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review. I adjusted the code to support any arbitrary percentile value

Copy link
Contributor

@axw axw left a comment

Choose a reason for hiding this comment

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

Thanks, looks great! Just one very minor issue

Copy link
Contributor

@axw axw left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@atoulme atoulme left a comment

Choose a reason for hiding this comment

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

LGTM, reviewed and approved by codeowner, merging.

@atoulme atoulme merged commit d9fc0b0 into open-telemetry:main May 2, 2025
173 checks passed
@github-actions github-actions bot added this to the next release milestone May 2, 2025
vincentfree pushed a commit to ing-bank/opentelemetry-collector-contrib that referenced this pull request May 6, 2025
…etrics (open-telemetry#39687)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
This PR is an enhancement to the awsfirehose receiver. 

By default, CloudWatch metric streams only include four statistics –
Minimum, Maximum, Sample Count and Sum. But we can add additional
statistics for specific metrics, including p70, p80, p90, p95 and p99
percentiles:

<img width="718" alt="image"
src="https://github.com/user-attachments/assets/fe17bced-9c00-4082-a0a3-9b520829bd70"
/>

These additional statistics will be added to the firehose request
payload. Example:
```
{
  "metric_stream_name": "firehose-metrics-stream",
  "account_id": "1234567890",
  "region": "eu-west-1",
  "namespace": "AWS/EC2",
  "metric_name": "CPUUtilization",
  "dimensions": {
    "InstanceId": "i-0a05ddddd2acb83a7"
  },
  "timestamp": 1745849100000,
  "value": {
    "max": 31.435,
    "min": 25.83666666666667,
    "sum": 140.94833333333332,
    "count": 5,
    "p99": 31.40867565167042,
    "p90": 31.172746310692506,
    "p95": 31.303598519605032
  },
  "unit": "Percent"
}
```

These values are currently ignored during unmarshalling. This PR adds
these fields as optional fields during deserialization and adds the
values to the summary quantiles.


<!--Describe what testing was performed and which tests were added.-->
#### Testing

Enrich existing unit test.

---------

Co-authored-by: Antoine Toulme <[email protected]>
Co-authored-by: Andrew Wilkins <[email protected]>
vincentfree pushed a commit to ing-bank/opentelemetry-collector-contrib that referenced this pull request May 20, 2025
…etrics (open-telemetry#39687)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
This PR is an enhancement to the awsfirehose receiver. 

By default, CloudWatch metric streams only include four statistics –
Minimum, Maximum, Sample Count and Sum. But we can add additional
statistics for specific metrics, including p70, p80, p90, p95 and p99
percentiles:

<img width="718" alt="image"
src="https://github.com/user-attachments/assets/fe17bced-9c00-4082-a0a3-9b520829bd70"
/>

These additional statistics will be added to the firehose request
payload. Example:
```
{
  "metric_stream_name": "firehose-metrics-stream",
  "account_id": "1234567890",
  "region": "eu-west-1",
  "namespace": "AWS/EC2",
  "metric_name": "CPUUtilization",
  "dimensions": {
    "InstanceId": "i-0a05ddddd2acb83a7"
  },
  "timestamp": 1745849100000,
  "value": {
    "max": 31.435,
    "min": 25.83666666666667,
    "sum": 140.94833333333332,
    "count": 5,
    "p99": 31.40867565167042,
    "p90": 31.172746310692506,
    "p95": 31.303598519605032
  },
  "unit": "Percent"
}
```

These values are currently ignored during unmarshalling. This PR adds
these fields as optional fields during deserialization and adds the
values to the summary quantiles.


<!--Describe what testing was performed and which tests were added.-->
#### Testing

Enrich existing unit test.

---------

Co-authored-by: Antoine Toulme <[email protected]>
Co-authored-by: Andrew Wilkins <[email protected]>
dragonlord93 pushed a commit to dragonlord93/opentelemetry-collector-contrib that referenced this pull request May 23, 2025
…etrics (open-telemetry#39687)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
This PR is an enhancement to the awsfirehose receiver. 

By default, CloudWatch metric streams only include four statistics –
Minimum, Maximum, Sample Count and Sum. But we can add additional
statistics for specific metrics, including p70, p80, p90, p95 and p99
percentiles:

<img width="718" alt="image"
src="https://github.com/user-attachments/assets/fe17bced-9c00-4082-a0a3-9b520829bd70"
/>

These additional statistics will be added to the firehose request
payload. Example:
```
{
  "metric_stream_name": "firehose-metrics-stream",
  "account_id": "1234567890",
  "region": "eu-west-1",
  "namespace": "AWS/EC2",
  "metric_name": "CPUUtilization",
  "dimensions": {
    "InstanceId": "i-0a05ddddd2acb83a7"
  },
  "timestamp": 1745849100000,
  "value": {
    "max": 31.435,
    "min": 25.83666666666667,
    "sum": 140.94833333333332,
    "count": 5,
    "p99": 31.40867565167042,
    "p90": 31.172746310692506,
    "p95": 31.303598519605032
  },
  "unit": "Percent"
}
```

These values are currently ignored during unmarshalling. This PR adds
these fields as optional fields during deserialization and adds the
values to the summary quantiles.


<!--Describe what testing was performed and which tests were added.-->
#### Testing

Enrich existing unit test.

---------

Co-authored-by: Antoine Toulme <[email protected]>
Co-authored-by: Andrew Wilkins <[email protected]>
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.

4 participants