Skip to content

Export metrics every 10 minutes instead of every minute #2260

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

RebeccaMahany
Copy link
Contributor

Our metrics exporter by default exports data points every minute. I had assumed that if no measurement had occurred during that minute, there would be nothing to export, so the export wouldn't happen. However, that appears to be incorrect -- the exporter will re-ship all meters with at least one data point every minute. I believe this behavior indicates that the latest data measurement is "unbroken", which seems reasonable and useful, but I also believe this is contributing to our higher metrics storage cost.

This PR changes the export interval to every 10 minutes instead of every minute. (I think we could comfortably bump this up to every 30 minutes or possibly every hour, but I'd like to confirm that this actually affects our billing data before making that change.) All metrics not yet exported will always be flushed and exported on launcher shutdown, so we don't risk losing data with this greater interval -- metrics will just take longer to show up. This seems like an acceptable tradeoff to me.

@RebeccaMahany RebeccaMahany added this pull request to the merge queue May 15, 2025
@@ -345,7 +345,7 @@ func (t *TelemetryExporter) setNewGlobalMeterProvider(launcherResource *resource
// Create new meter provider and let otel set it globally
newMeterProvider := sdkmetric.NewMeterProvider(
sdkmetric.WithResource(launcherResource),
sdkmetric.WithReader(sdkmetric.NewPeriodicReader(metricsExporter)),
sdkmetric.WithReader(sdkmetric.NewPeriodicReader(metricsExporter, sdkmetric.WithInterval(10*time.Minute))),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the kind of thing we could adjust at runtime, or is it baked too deeply?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, just seeing this question now! We can't adjust this after provider creation. However, we have the same issue with the tracer provider (e.g. when we want to adjust the sampling rate), and we address it there by creating a new tracer provider anytime the relevant tracing flags change. We could do the same thing here -- make this into a flag, then on flag change, create a new global meter provider with the updated interval -- if desired.

Merged via the queue into kolide:main with commit 9d3bc7a May 15, 2025
37 checks passed
@RebeccaMahany RebeccaMahany deleted the becca/metrics-export-interval branch May 15, 2025 17:10
@RebeccaMahany RebeccaMahany added the observability Observability label May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
observability Observability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants