Bonsai clusters support most Elasticsearch APIs out of the box, with a few exceptions. This article details those exceptions, along with a brief explanation of why they’re in place. Here is what we will cover :
- _all and wildcard destructive actions
- Tasks API
- Node Hot Threads
- Node Shutdown & Restart
- Snapshots
- Reindex
- Cluster Shard Reroute
- Cluster Settings
- Index Search Warmers
- Static Scripts
- Update By Query API
While having many of the following endpoints can be helpful for power users, the majority of applications don’t directly need them. If, however, you find yourself stuck without one of these available, please email us and we’ll be happy to help.
_all and wildcard destructive actions
Wildcard delete actions are usually for clusters with a large number of indices, and can be useful for completely wiping out a cluster and starting over. Wildcard and _all destructive actions were initially available on shared tier clusters. However, we received an increasingly large number of threads from distressed developers that accidentally deleted their entire production clusters.
After some internal discussion, we decided to disable wildcard actions. Removing the ability to sweepingly delete everything forces users to slow down and identify exactly what they’re deleting, reducing the risk of accidental and permanent data loss.
Examples of _all and wildcard destruction:
DELETE /* DELETE /_all
Tasks API
Elasticsearch provides an API for viewing information about current running tasks and the ability to cancel them on versions 5.x and up. This API is disabled for multi-tenant plans. It can be enabled by request on Business and Enterprise plans through an email to support.
GET /_tasks GET /_tasks/{task_id} POST /_tasks/{task_id}/_cancel
Node hot threads
A Java thread that uses lots of CPU and runs for an unusually long period of time is known as a hot thread. Elasticsearch provides an API to get the current hot threads on each node in the cluster. This information can be useful in forming a holistic picture of potential problems within the cluster.
Bonsai doesn’t support these endpoints on our shared tier to ensure user activity isn’t exposed to others. For a detailed explanation of why this is a concern, please see the article on Architecture Classes. Additionally, Bonsai is a managed service, so it’s really the responsibility of our Ops Team to investigate node-level issues.
If you think there is a problem with your cluster that you need help troubleshooting, please email support.
GET /_cluster/nodes/hotthreads GET /_cluster/nodes/hot_threads GET /_cluster/nodes/{node_id}/hotthreads GET /_cluster/nodes/{node_id}/hot_threads GET /_nodes/hotthreads GET /_nodes/hot_threads GET /_nodes/{node_id}/hotthreads GET /_nodes/{node_id}/hot_threads
Node Shutdown & Restart
Elasticsearch provides an API for shutting down and restarting nodes. This functionality is unsupported across the platform. On our multitenant architecture, this prevents a user from shutting down a node or set of nodes that may be in use by another user. That action would have an adverse affect on other users which is why it is unsupported. This also prevents users from exacerbating whatever problem they’re trying to resolve.
If you think there is a problem with your cluster that you need help troubleshooting, please email support.
POST /_cluster/nodes/_restart POST /_cluster/nodes/_shutdown POST /_cluster/nodes/{node_id}/_restart POST /_cluster/nodes/{node_id}/_shutdown POST /_shutdown
Snapshots
The Snapshot API allows users to create and restore snapshots of indices and cluster data. It’s useful as a backup tool and for recovering from problems or data loss. On Bonsai, we’re already taking regular snapshots and monitoring cluster states for problems,. This API is blocked to avoid problems associated with multiple users trying to snapshot/restore at once.
If you feel that you need a snapshot taken/restored, please reach out to our support team.
GET /_snapshot/_status DELETE /_snapshot/{repository} POST /_snapshot/{repository} PUT /_snapshot/{repository} GET /_snapshot/{repository}/_status DELETE /_snapshot/{repository}/{snapshot} GET /_snapshot/{repository}/{snapshot} POST /_snapshot/{repository}/{snapshot} PUT /_snapshot/{repository}/{snapshot} POST /_snapshot/{repository}/{snapshot}/_create PUT /_snapshot/{repository}/{snapshot}/_create POST /_snapshot/{repository}/{snapshot}/_restore GET /_snapshot/{repository}/{snapshot}/_status
Reindex
The Reindex API copies documents from one index to another. For example, it will copy documents from an index called books
into another index, like new_books
. It does this by using what is basically a scan and scroll search, reading the contents of one index into another. The API call looks something like this:
POST /_reindex
At this time, the Reindex API is supported on Bonsai for clusters running on Elasticsearch 5.6 and up. Because it can be extremely demanding on IO, which can impact performance and availability for other users on multitenant architectures, it is only available to pre-5.6 clusters on Business or Enterprise subscriptions.
One workaround is to set up an indexing script that uses the scan and scroll search to read documents from your old index and push them into the new index. For example, read the contents of GET /my_index/_search?search_type=scan&scroll=1m
, then POST
those retrieved docs into a new index. That would provide basically the same functionality.
Another option is to simply populate the new index directly from your database.
Cluster Shard Reroute
Elasticsearch provides an API to move shards around between nodes within a cluster. We don’t support this functionality on our shared plans for a few reasons. For one it interferes with our cluster management tooling, and there is a possibility for one or more users to allocate shards in a way that overloads a node.
If you need fine-grain control over the shard allocation within a cluster, please reach out to us and we can discuss your use case and look at whether single tenancy would be a good fit for you.
POST /_cluster/reroute
Cluster settings
Elasticsearch provides an API to apply cluster-wide settings. We don’t support this in our shared environment for safety reasons. In an environment where system resources are shared, this API would affect all users simultaneously. So one user could affect the behavior of everyone’s cluster in ways that those users may not want. Instead, we block this API and remain opinionated about cluster settings.
If you need to change the system settings for your cluster, you’ll need to be in a single tenant environment. Reach out to us and let’s talk through it.
PUT /_cluster/settings
Index Search Warmers
Elasticsearch provides a mechanism to speed up searches prior to being run. It does this by basically pre-populating caches via automatically running search requests. This is called “warming” the data, and it’s typically done against searches that require heavy system resources.
We don’t support this on shared clusters for stability reasons. Essentially there isn’t a great way to throttle the impact of an arbitrary number of warmers. There is a possibility that a user could overwhelm the system resources by creating a large number of “heavy” warmers (aggregations, sorts on large lists, etc). It’s also somewhat of an anti-pattern in a multitenant environment.
If this is something critical to your app, you would need to be on a dedicated cluster. Please reach out to us if you have any further questions on this.
POST /_warmer/{name} PUT /_warmer/{name} POST /_warmers/{name} PUT /_warmers/{name} POST /{index}/_warmer/{name} PUT /{index}/_warmer/{name} POST /{index}/_warmers/{name} PUT /{index}/_warmers/{name} POST /{index}/{type}/_warmer/{name} PUT /{index}/{type}/_warmer/{name} POST /{index}/{type}/_warmers/{name} PUT /{index}/{type}/_warmers/{name}
Static Scripts
Elasticsearch provides an API for adding and modifying static scripts within a cluster, which can be referenced by name. We can enable these endpoints on a case-by-case basis for Business and Enterprise clusters. Inline scripts with Painless are supported on all clusters.
DELETE /_scripts/{lang}/{id} GET /_scripts/{lang}/{id} POST /_scripts/{lang}/{id} PUT /_scripts/{lang}/{id} POST /_scripts/{lang}/{id}/_create PUT /_scripts/{lang}/{id}/_create
Update By Query API
Elasticsearch provides an API for updating documents that match a given query. This API is disabled on multitenant clusters due to the large amount of overhead and risk it introduces. Namely, it's possible to craft a query that runs, uncontrolled, for a long period of time and consumes significant amounts of CPU in the process. On multitenant systems, this translates to a severe performance degradation for multiple users.
Customers wanting to make use of this API can do so on a Business or Enterprise subscription.
POST /{index}/_update_by_query