Repository navigation
feat(agent): Continue flushing for outputs rejecting metrics - #20033
Conversation
| require.Len(t, plugin.Metrics(), totalMetrics) | ||
| } | ||
|
|
||
| func TestRunningOutputNoRetriggerOnStopFlushingPartialWriteError(t *testing.T) { |
There was a problem hiding this comment.
[nit] Same scenario as TestRunningOutputNoRetriggerOnUnsuccessfulPartialWriteError above, since false is the zero value. Could we fold the extra assertions into that test instead?
There was a problem hiding this comment.
I wanted to make this explicit to keep the symmetry, i.e. to have an explicit test for both cases...
There was a problem hiding this comment.
With the flag gone this is the same case as TestRunningOutputNoRetriggerOnUnsuccessfulPartialWriteError again, and StopFlushing in the name points at a field that no longer exists. Could we fold its stronger asserts into the older test, or at least rename it?
|
One question outside the diff. azure_monitor already rejects too-old metrics, and when the whole batch is outside the window the |
I prefer a separate PR. The same might happen to other plugins where none of the metrics sent is valid... |
9501cde to
c747f58
Compare
|
@skartikey and @JoeGadd-BBC iterating on this problem I found that we should start without an additional flag in the |
|
Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip. 📦 Click here to get additional PR build artifactsArtifact URLs |
|
@srebhan Agreed. That also means the all-stale azure_monitor branch drains without any change there, so I'll drop the follow-up I mentioned. @JoeGadd-BBC that answers your question too. No flag needed on #19953, rejecting the expired metrics is enough once this lands. |
| // was modified, i.e. at least one metric was accepted or rejected, in order | ||
| // to avoid flush storms hammering the plugin's endpoint with requests while | ||
| // it potentially cannot accept any. | ||
| r.continueFlushing.Store(len(writeErr.MetricsAccept) > 0 || len(writeErr.MetricsReject) > 0) |
There was a problem hiding this comment.
[question] Are we ok with this for outputs that reject on a server answer, like influxdb_v2 on a transient 404 (it rejects any unlisted 4xx)? With an all-reject mock the buffer now empties back to back, 5000 metrics gone in under 500ms, where master drops one batch per flush interval.
There was a problem hiding this comment.
I think we should rather fix the plugin here as it might be correct to drop the whole buffer or not but the previous behavior is certainly bad either. What do you think?
There was a problem hiding this comment.
Agreed, fixing the plugin is the right place. I'll open a PR for influxdb_v2 to keep 404 as a plain retry error like 401 and 403, so only real permanent rejects drain the buffer.
There was a problem hiding this comment.
Correction on the influxdb_v2 404 idea. A 404 there is mostly bucket not found with bucket_tag, and TestStatusCodeNonRetryable4xx pins that those metrics get dropped. Retrying them would keep them in the buffer until overflow and push out metrics for the good buckets, so I'll leave 404 as it is. Draining a missing bucket quickly is fine.
| require.Len(t, plugin.Metrics(), totalMetrics) | ||
| } | ||
|
|
||
| func TestRunningOutputNoRetriggerOnStopFlushingPartialWriteError(t *testing.T) { |
There was a problem hiding this comment.
With the flag gone this is the same case as TestRunningOutputNoRetriggerOnUnsuccessfulPartialWriteError again, and StopFlushing in the name points at a field that no longer exists. Could we fold its stronger asserts into the older test, or at least rename it?
Summary
Currently, the output model stops flushing filled buffers if not at least one metric was accepted to prevent flush storms on outputs which cannot handle metrics e.g. if the endpoint is not reachable. However, this neglects cases where metrics in a batch are permanently rejected, e.g. if they cannot be serialized or because the output cannot send those metrics because they are too old. In those cases we could continue flushing minimizing the chance of buffer overflows.
This PR forces the model to continue flushing for partial-write-errors if the buffer is modified i.e. at least one metric was accepted or rejected.
Checklist
Related issues
resolves #20015
superseeds #20016
related to #19945
related to #19953