Add --storage.tsdb.retention.percentage (#10287)#12278
Conversation
|
Can we make it work for windows too to keep feature parity? |
a7e9f3a to
8912e88
Compare
yes it should be OK. would it be possible to add a dependency to github.com/minio/minio/internal/disk as it seems complete and well maintained ? or just continue to handle disk information directly from prometheus sources ? |
d794957 to
3b199aa
Compare
forget it, I did not realized it was internal and cannot be used from prometheus. |
fa11739 to
a148c5a
Compare
|
Did you copy code over from minio? |
cadc74c to
cf74ceb
Compare
only the strict necessary, but yes it's a piece of code that is inspired by minio code |
|
Minio is released under AGPL-3.0. We might get into troubled waters. Or you could check if the code was present in the Apache-2 releases of minio. We probably want attribution in the headers of the files as well. |
5df8a81 to
3378275
Compare
No need I guess. Even if it looks like the same it's just a call to a windows syscall. cf doc from microsoft in the comment |
3378275 to
d019d63
Compare
|
I still need to test it on windows |
|
I'm still not fully happy with the solution that I provide. We clean up old blocks if the prom storage uses more that X% of the partition capacity. But If some other things are filling up the disk, it won't prevent the partition to get full and in this case prom is not working correctly. I'm thinking about adding the possibility to remove blocks if free disk usage raises over a limit. Let's say I want to remove old blocks if disk actual usage is over 90% no matter the size of the blocks. I just want to ensure prom will have spare space to write new data even if it means to delete old blocks, continuity of service first. what do you think ? |
|
I think we should indeed take into consideration the size of the disk and not the size of the blocks, then remove enough blocks to get back below the threshold |
|
We have discussed this during the Prometheus bug scrub. We decided that we should only look at the ration between disk space used by Prometheus vs the disk size. I will review this PR this week. |
|
I like the simplicity of having a percentage value instead of some calculated number of GiB as a retention. To me the most helpful feature would be to be able to just point Prometheus at a storage volume and tell it to use all of this this space and to do housekeeping / automagic expiry to never run out of space. Be there changes in rate or number of time series or whatever - Prometheus simply ensures the disk will not fill up 100%. So take my comment back to this PR: Can I simply set 99% and be done with it? |
|
I still plan to review this and we agreed again during the bug scrub that we should only take care about the scenario where Prometheus has its own volume/partition. There might be concerns with the size of the WAL and the size of the snapshots, but it is the same issue with the retention bytes. This PR should basically only set the retention bytes to the % of disk space. |
|
Hello from the bug-scrub! @roidelapluie do you think you will get back to this? |
YES @roidelapluie, please see my comment / issue #11112 about this |
| serverOnlyFlag(a, "storage.tsdb.retention.size", "Maximum number of bytes that can be stored for blocks. A unit is required, supported units: B, KB, MB, GB, TB, PB, EB. Ex: \"512MB\". Based on powers-of-2, so 1KB is 1024B."). | ||
| BytesVar(&cfg.tsdb.MaxBytes) | ||
|
|
||
| serverOnlyFlag(a, "storage.tsdb.retention.percentage", "Maximum percentage of the disk space that can be used to store blocks (prevails over storage.tsdb.retention.size)."). |
There was a problem hiding this comment.
On first reading I interpreted "disk space" to mean "free space"; after looking more deeply I realize you implemented as a percentage of the total disk (partition) size.
Also "can be used to store blocks" might suggest that the head (WAL, chunks, etc.) is not included, whereas I believe it is.
Suggest to make this clearer; maybe add some commentary in the docs.
There was a problem hiding this comment.
I can change the message, no problem. What would you suggest ?
|
Hello again from the bug-scrub! We discussed in detail and this seems reasonable; there are a few merge conflicts to resolve. |
d019d63 to
88d4be9
Compare
done |
66b3ba1 to
bf98acf
Compare
| serverOnlyFlag(a, "storage.tsdb.retention.size", "Maximum number of bytes that can be stored for blocks. A unit is required, supported units: B, KB, MB, GB, TB, PB, EB. Ex: \"512MB\". Based on powers-of-2, so 1KB is 1024B."). | ||
| BytesVar(&cfg.tsdb.MaxBytes) | ||
|
|
||
| serverOnlyFlag(a, "storage.tsdb.retention.percentage", "Maximum percentage of the disk space that can be used to store blocks (prevails over storage.tsdb.retention.size)."). |
There was a problem hiding this comment.
| serverOnlyFlag(a, "storage.tsdb.retention.percentage", "Maximum percentage of the disk space that can be used to store blocks (prevails over storage.tsdb.retention.size)."). | |
| serverOnlyFlag(a, "storage.tsdb.retention.percentage", "Maximum percentage of disk used for TSDB storage (overrides storage.tsdb.retention.size)."). |
Then the more detailed commentary can go in docs/storage.md
|
With this PR seemingly moving I'd like to again (#12278 (comment)) mention the usability issue with setting e.g. "95%" and still running out of disk space due to #11112. It would simply be AWESOME to have Prometheus be able to utilize all of the available space (e.g. running with this new flag set to 95% or even 99%) and not run out of space due to compaction. So what are "safe" values for all those |
|
Hello from the bug-scrub! Seems we are nearly there; there is one review comment and one small merge conflict. @fatpat if you're able to do this, please let us know, otherwise one of the maintainers can pick it up and clean up those things. |
Signed-off-by: Jérôme LOYET <[email protected]>
bf98acf to
a29537a
Compare
Hi, rebase's done. Unfortunately I have no spare time to work on this soon. Feel free to take over, I'd love to see this PR merged. And if possible to take compaction into account would be a game changer for us too. |
|
After talking with @krajorama, I'll try to bring this to an end, but can't directly edit this PR (I'm not a maintainer), so following up in #18080. |
@ldufr will you be tackling the issue with compaction not taking into account when calculating storage percentage then? |
|
@frittentheke I wasn't going to tackle the issue together and I think it makes more sense here to do it separately. |
Yes 2 different issues especially since that compation issue affects all the TSDB retention mechanisms (and is not as easy as it looks) |
@roidelapluie after all there is my issue #11112 which is to track that one anyways. |
|
Thanks for the work put on this, #18080 has been merged, so I am closing this one. |
As discussed in #10287, this PR add the
--storage.tsdb.retention.percentage.It takes an uint between 0 (disabled) and 100.
if set, each time
BeyondSizeRetentionis called,storage.tsdb.rentention.sizeis temporary overwritten with the percentage of the current size of the partition on which the DB directory is stored.