Why close/reopen index will reset index stats to zero

Now we calculate index useage by index stats api, if close and reopen index, the index stats will reset to 0, such indexing/search/merge metrics. it will bring us misunderstanding.
I'm wondering why this operation will reset stats and reopening index is it possible reopen index does not reset stats?

Not only reopen index, and relocate shard operation

The statistics you're talking about are a property of the running shard copy, so it makes sense that they should be reset if the shard copy is stopped and started; also when a shard relocates we bring up a new shard copy at the new location and then shut the one down at the old location.

Another way to reset them to zero is to restart a node. It would be rather expensive to preserve statistics across node restarts, shard relocations etc: they would have to be written to disk and fsynced every time they changed, and would require node-to-node coordination during relocations. Yet even if we managed to achieve this we would still start counting from zero on a newly-added replica if the number of replicas is increased. There is no sensible alternative.

In short, however you are analysing these statistics must take the occasional reset into account.

1 Like

Thanks for reply.
In my understandingļ¼Œthe statistics are store in memory, it will lost while node or shard restart. To store correct statistics to disk will spent physical resources.
Could it possible write statistics to shards _state/state-0.st file every few seconds(like refresh_interval), and using a setting to let user enable this feature. Even if it can't guarantee the correct metric, but in the most time it's also useful to us.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.