Elastic Search

Elasticsearch Cluster Settings

When working as a database administrator, understanding how to manage your cluster is one of the most important things.

In this post, we will show you how to get started with cluster administration by fetching and updating the cluster wide settings.

Let’s dive in!

Elasticsearch Get Cluster Settings API

To fetch the cluster settings in Elasticsearch, we can use the GET cluster settings API as shown in the following syntax:

GET /_cluster/settings

The API should return the settings for the cluster. Keep in mind that this API endpoint may require a monitor or manage privileges.

Example: Return All Cluster Settings

The following example request shows all the cluster settings as explicitly defined:

curl -XGET "http://localhost:9200/_cluster/settings" -H "kbn-xsrf: reporting"

The resulting output is as shown in the following:

{
  "persistent": {
    "action": {
      "auto_create_index": ".ent-search-*-logs-*,-.ent-search-*,+*"
    },
    "cluster": {
      "indices": {
        "close": {
          "enable": "true"
        }
      },
      "metadata": {
        "display_name": "elk_stack"
      }
    },
    "slm": {
      "retention_schedule": "0 20,50 * * * ?"
    }
  },
  "transient": {
    "action": {
      "auto_create_index": ".ent-search-*-logs-*,-.ent-search-*,+*"
    }
  }
}

To include the default cluster settings, we can include the include_defaults parameter as shown in the following:

curl -XGET "http://localhost:9200/_cluster/settings?include_defaults=true" -H "kbn-xsrf: reporting"

Setting the include_defaults parameter to true includes the default cluster settings as shown in the following example:

"defaults": {
    "cluster": {
      "max_voting_config_exclusions": "10",
      "metadata": {
        "managed_index_templates": ".cloud-",
        "managed_repository": "found-snapshots",
        "managed_policies": "[cloud-snapshot-policy]"
      },
      "auto_shrink_voting_configuration": "true",
      "discovery_configuration_check": {
        "interval": "30000ms"
      },
      "election": {
        "duration": "500ms",
        "initial_timeout": "100ms",
        "max_timeout": "10s",
        "back_off_time": "100ms",
        "strategy": "supports_voting_only"
      },
      "no_master_block": "write",
      "persistent_tasks": {
        "allocation": {
          "enable": "all",
          "recheck_interval": "30s"
        }
      },
      "blocks": {
        "read_only_allow_delete": "false",
        "read_only": "false"
      },
      "remote": {
        "initial_connect_timeout": "30s",
        "node": {
          "attr": ""
        },
        "connections_per_cluster": "3"
      },
      "follower_lag": {
        "timeout": "90000ms"
      },
      "routing": {
        "use_adaptive_replica_selection": "true",
        "rebalance": {
          "enable": "all"
        },
        "allocation": {
          "enforce_default_tier_preference": "true",
          "node_concurrent_incoming_recoveries": "2",
          "node_initial_primaries_recoveries": "4",
          "same_shard": {
            "host": "false"
          },
          "total_shards_per_node": "-1",
          "type": "balanced",
          "disk": {
            "threshold_enabled": "true",
            "reroute_interval": "60s",
            "watermark": {
              "flood_stage.frozen.max_headroom": "20GB",
              "flood_stage": "95%",
              "high": "90%",
              "low": "85%",
              "enable_for_single_data_node": "true",
              "flood_stage.frozen": "95%"
            }
          },
          "awareness": {
            "attributes": [
              "region",
              "logical_availability_zone"
            ]
          },
          "balance": {
            "index": "0.55",
            "threshold": "1.0",
            "shard": "0.45"
          },
          "enable": "all",
          "node_concurrent_outgoing_recoveries": "2",
          "allow_rebalance": "indices_all_active",
          "cluster_concurrent_rebalance": "2",
          "node_concurrent_recoveries": "2"
        }
      },
      "indices": {
        "tombstones": {
          "size": "500"
        }
      },
      "join_validation": {
        "cache_timeout": "60s"
      },
      "max_shards_per_node.frozen": "3000",
      "nodes": {
        "reconnect_interval": "10s"
      },
      "service": {
        "master_service_starvation_logging_threshold": "5m",
        "slow_master_task_logging_threshold": "10s",
        "slow_task_logging_threshold": "30s"
      },
      "publish": {
        "timeout": "30000ms",
        "info_timeout": "10000ms"
      },
      "name": "93bb98ab7e8c413bbb62abd77d602be8",
      "fault_detection": {
        "leader_check": {
          "interval": "1000ms",
          "timeout": "10000ms",
          "retry_count": "3"
        },
        "follower_check": {
          "interval": "1000ms",
          "timeout": "10000ms",
          "retry_count": "3"
        }
      },
      "max_shards_per_node": "1000",
      "initial_master_nodes": [
        "instance-0000000000",
        "instance-0000000001",
        "tiebreaker-0000000002"
      ],
      "deprecation_indexing": {
        "enabled": "true",
        "x_opaque_id_used": {
          "enabled": "true"
        }
      },
------------------OUTPUT TRUNCATED----------------------

We can also show the cluster settings in flat format by setting the flat_settings parameter as shown in the following:

curl -XGET "http://localhost:9200/_cluster/settings?flat_settings=true" -H "kbn-xsrf: reporting"

Output:

{
  "persistent": {
    "action.auto_create_index": ".ent-search-*-logs-*,-.ent-search-*,+*",
    "cluster.indices.close.enable": "true",
    "cluster.metadata.display_name": "elk_stack",
    "slm.retention_schedule": "0 20,50 * * * ?"
  },
  "transient": {
    "action.auto_create_index": ".ent-search-*-logs-*,-.ent-search-*,+*"
  }
}

Conclusion

In this article, you learned to fetch the cluster wide settings using the get cluster settings API.

Thanks for reading!

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list