You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求适用于PowerShell的ElasticSearch磁盘阈值配置命令

Solution: Convert Elasticsearch Curl Command to Working PowerShell Invoke-RestMethod

I get it—dealing with Elasticsearch disk threshold alerts spamming your logs is annoying enough, and then hitting a wall converting the curl command to PowerShell on Windows just adds to the frustration. Let’s cut straight to the working command you need:

Invoke-RestMethod -Method Put -Uri "http://localhost:9200/_cluster/settings" -ContentType "application/json" -Body '{ "persistent" : { "cluster.routing.allocation.disk.threshold_enabled" : "false" } }'

Why your previous attempts might have failed:

  • Missing the PUT method: By default, Invoke-RestMethod uses GET if you don’t specify -Method Put, which won’t modify cluster settings.
  • JSON formatting issues: PowerShell is picky about string quoting. Using single quotes around the entire JSON body avoids conflicts with the double quotes inside the JSON structure.
  • Forgotten Content-Type header: Elasticsearch requires the Content-Type: application/json header to parse the request body correctly—omitting this will lead to errors.

Verify the setting took effect:

To confirm the disk threshold is disabled, run this command to check the current cluster settings:

Invoke-RestMethod -Uri "http://localhost:9200/_cluster/settings?include_defaults=false"

Look for the persistent section in the output—you should see "cluster.routing.allocation.disk.threshold_enabled": "false" listed.

内容的提问来源于stack exchange,提问作者user7951690

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 04:58:35