How to know if an index is readonly

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
all

Describe the issue:
I’m wondering if there is an easy way to know if an index is readonly. There is the cat api and it gives me the index status, but if the index became readonly, either because I made it readonly, or because the server reached the watermark level, there isn’t an obvious way to query for that. The index shows yellow whether it is readonly or not.

The only thing I have found so far is to query the cluster settings and it may indicate the status.

Ideally such a state would be available via “cat” APIs, like “cat index” or “cat cluster”. If we run low on disk space now, it shows the state as yellow, but if the index is readonly it still shows yellow.

You can get the read only blocks by calling the get index settings API:

GET abc/_settings

, if the index is read only, the setting index.blocks.write or index.blocks.read_only_allow_delete is true.

You can also call the cluster state API to get all index blocks in the cluster:

GET _cluster/state/blocks

You can use the Monitor, a job that periodically queries the data “appointed indices” and performs actions based on certain conditions, then your query should check the settings of indices to see if index.blocks.write or index.blocks.read_only_allow_delete is set to true, where you can add a Trigger if conditions occur and Action for the trigger.