-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[prometheusreceiver] Make use of created timestamp from prometheus #36660
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
[prometheusreceiver] Make use of created timestamp from prometheus #36660
Conversation
Signed-off-by: Florian Bacher <[email protected]>
Signed-off-by: Florian Bacher <[email protected]>
Signed-off-by: Florian Bacher <[email protected]>
Signed-off-by: Florian Bacher <[email protected]>
Signed-off-by: Florian Bacher <[email protected]>
Signed-off-by: Florian Bacher <[email protected]>
Signed-off-by: Florian Bacher <[email protected]>
Signed-off-by: Florian Bacher <[email protected]>
I think we might need the prometheus update for this to work: #36642 |
thanks for the link to the PR - I was wondering if I should also include the dependency update in my PR but in this case I will wait for the dependency update PR to get merged. One other thing: As of now, it seems like the |
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
Signed-off-by: Florian Bacher <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really excited to see this!
@@ -425,6 +425,11 @@ func (mf *metricFamily) addSeries(seriesRef uint64, metricName string, ls labels | |||
return nil | |||
} | |||
|
|||
func (mf *metricFamily) addCreationTimestamp(seriesRef uint64, ls labels.Labels, atMs, created int64) { | |||
mg := mf.loadMetricGroupOrCreate(seriesRef, ls, atMs) | |||
mg.created = float64(created) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be setting seconds but is setting milliseconds.
Change the `EnableCreatedTimestampZeroIngestion` setting in the prometheus scrape manager to use the otelcollector feature flag that has the same name and is disabled by default. This had introduced new parsing during a scrape loop that resulted in very high CPU at higher metric volumes. Reverts this PR: open-telemetry/opentelemetry-collector-contrib#36660 so that the functionality for this is the same as before v0.121.0``
…us setting to fix high CPU for openmetrics (#40355) <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description The PR #36660 enabled the setting in the scrape manager `EnableCreatedTimestampZeroIngestion` by default. This enabled the [Prometheus feature flag](https://prometheus.io/docs/prometheus/latest/feature_flags/#created-timestamps-zero-injection) by the same name. In Prometheus, when this is set to true, [a call to a new function](https://github.com/prometheus/prometheus/blob/1d9dfde9894f0c82b809b70aa5f9cecab25b8fea/scrape/scrape.go#L1770-L1799) CreatedTimestamp() is run. This currently isn't implemented for the Prometheus parser but is for the OpenMetrics parser and [has a comment](https://github.com/prometheus/prometheus/blob/main/model/textparse/openmetricsparse.go#L287) that it may use additional CPU and memory resources. We are seeing a 10x increase in CPU usage when there's a high volume of metrics scraped with this scenario. This PR puts the setting in the scrape manager behind a feature gate that allows it to be disabled. <!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes #40245 <!--Describe what testing was performed and which tests were added.--> #### Testing Tested with a custom build with this change. <!--Describe the documentation added.--> #### Documentation Documentation about the feature gate exists [here](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/prometheusreceiver/README.md#getting-started). <!--Please delete paragraphs that you did not use before submitting.--> --------- Co-authored-by: Arthur Silva Sens <[email protected]>
Description
This PR implements the
AppendCTZeroSample
andAppendHistogramCTZeroSample
methods which can be called by prometheus to pass through the creation timestamp of a metricLink to tracking issue
Fixes #36473
Testing
Added unit tests