Search...Cluster(3pm)

Search...Cluster(3pm) πŸ’–

okay bestie, welcome to the manual page for Search::Elasticsearch::Client::2_0::Direct::Cluster β€” a whole module that's literally just your backstage pass to all the cluster-level drama going on in Elasticsearch. it's the Search...Cluster(3pm) page, and yes we're doing this, sit down, hydrate, let's go 🫢


✨ NAME ✨

Search::Elasticsearch::Client::2_0::Direct::Cluster β€” a client for running cluster-level requests. it's giving main character, it's giving I talk to the whole cluster at once πŸ‘‘


🌸 VERSION 🌸

version 6.81


πŸ¦‹ DESCRIPTION πŸ¦‹

this module hands you the methods to make cluster-level requests, like:

  • getting and setting cluster-level settings
  • manually rerouting shards (yes, moving them around by hand, iconic)
  • retrieving stuff for monitoring purposes

It does Search::Elasticsearch::Role::Client::Direct. that's the whole vibe.


πŸ’… METHODS πŸ’…

πŸ’œ health()

$response = $e->cluster->health(
    index   => 'index' | \@indices  # optional
);

health() is your vibe check for the whole cluster β€” it pulls back info about cluster health and returns red, yellow or green so you know the state of the cluster, the indices, or the shards. green = slay, yellow = hmm, red = 😭.

Query string parameters:

  • level
  • local
  • master_timeout
  • timeout
  • wait_for_active_shards
  • wait_for_nodes
  • wait_for_relocating_shards
  • wait_for_status

for more info, check the cluster health docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html ✨


πŸŽ€ stats()

$response = $e->cluster->stats(
    node_id => 'node' | \@nodes     # optional
);

returns high-level cluster stats, and if you want you can limit it to just the nodes you list. lowkey a whole dashboard in one call.

Query string parameters:

  • flat_settings
  • human
  • timeout

for more info, check the cluster stats docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-stats.html πŸ’–


🌈 get_settings()

$response = $e->cluster->get_settings()

get_settings() retrieves the cluster-wide settings β€” specifically the ones that got set by the put_settings() method. it's the read half of the duo, fr fr.

Query string parameters:

  • flat_settings
  • master_timeout
  • timeout

for more info, check the cluster settings docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html 🧚


⭐ put_settings()

$response = $e->cluster->put_settings( %settings );

put_settings() sets cluster-wide settings, and you've got two flavours bestie:

  • transiently β€” which don't survive restarts πŸ™ˆ
  • permanently β€” which do survive restarts πŸ‘‘

for instance:

$response = $e->cluster->put_settings(
    body => {
        transient => { "discovery.zen.minimum_master_nodes" => 5 }
    }
);

Query string parameters:

  • flat_settings

for more info, check the cluster settings docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html 🌸


πŸ”₯ state()

$response = $e->cluster->state(
    metric => $metric | \@metrics   # optional
    index  => $index  | \@indices   # optional
);

state() returns the current cluster state from the master node β€” or from the responding node instead, if local is set to true. plot twist energy.

it returns all metrics by default, but you can limit them to any of:

  • _all
  • blocks
  • metadata
  • nodes
  • routing_table

and metrics for indices can be limited to particular indices with the index parameter. so much control, obsessed.

Query string parameters:

  • allow_no_indices
  • expand_wildcards
  • flat_settings
  • ignore_unavailable
  • local
  • master_timeout

for more info, check the cluster state docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-state.html πŸ’œ


🌟 pending_tasks()

$response = $e->cluster->pending_tasks();

returns a list of cluster-level tasks that are still pending on the master node. it's the "girl what is taking so long" method, no cap.

Query string parameters:

  • local
  • master_timeout

for more info, check the pending tasks docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-pending.html πŸ“


πŸ¦„ reroute()

$e->cluster->reroute(
    body => { commands }
);

reroute() is for manually reallocating shards from one node to another. the body should contain the commands saying which changes should be made. for instance:

$e->cluster->reroute(
    body => {
        commands => [
            { move => {
                index     => 'test',
                shard     => 0,
                from_node => 'node_1',
                to_node   => 'node_2
            }},
            { allocate => {
                index     => 'test',
                shard     => 1,
                node      => 'node_3'
            }}
        ]
    }
);

Query string parameters:

  • dry_run
  • explain
  • master_timeout
  • metric
  • timeout

for more info, check the reroute docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-reroute.html ✨


πŸ‘‘ AUTHOR πŸ‘‘

Enrico Zimuel <enrico.zimuel@elastic.co> β€” an actual legend, we thank them for their service 🫢


This software is Copyright (c) 2020 by Elasticsearch BV.

This is free software, licensed under:

The Apache License, Version 2.0, January 2004

and that's the whole page bestie!! this one's running on perl v5.32.0, dated 2020-11-25, and that's the Search...Cluster(3pm) moment πŸ’…βœ¨ bye ily, go check your cluster health πŸŽ€