Search...Cluster(3pm)

πŸ“¦
version 6.81 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

Search::Elasticsearch::Client::1_0::Direct::Cluster πŸ’…

okay bestie, so this is a page from the User Contributed Perl Documentation (the 3pm crew πŸŽ€), and it's literally all about Search::Elasticsearch::Client::1_0::Direct::Cluster. A whole module. For cluster-level stuff. Periodt.


✨ VERSION ✨

version 6.81 β€” yes, that's the one, don't @ me 🌸


🌈 NAME 🌈

Search::Elasticsearch::Client::1_0::Direct::Cluster β€” a client for running cluster-level requests. that's the whole vibe check right there πŸ¦‹


πŸ’– DESCRIPTION πŸ’–

So this module is your girl for cluster-level requests, which is giving: getting and setting cluster-level settings, manually rerouting shards, and retrieving stuff for monitoring purposes. like, all the top-level cluster gossip you could ever need πŸ‘‘

It does Search::Elasticsearch::Role::Client::Direct. that's the ancestry, the main character lineage, iykyk πŸ’œ


🌟 METHODS 🌟

real talk: these are the actual methods, spelled exactly like this, and you call them on $e->cluster. no cap.

🩺 health()

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

The health() method pulls info about cluster health, and it comes back with red, yellow or green to tell you the state of the cluster, indices or shards. it's literally a mood ring for your cluster πŸŸ’πŸŸ‘πŸ”΄

Query string parameters:

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

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


πŸ“Š 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. so iconic ✨

Query string parameters:

  • "flat_settings"
  • "human"

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


πŸ” get_settings()

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

This one is used to retrieve cluster-wide settings that were set with the put_settings() method. so like, whatever put_settings() did, this one comes and reads it back. tag team energy πŸ‘―

Query string parameters:

  • "flat_settings"
  • "master_timeout"
  • "timeout"

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


πŸŽ€ put_settings()

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

The put_settings() method sets cluster-wide settings, and you've got two flavors: transiently (which don't survive restarts 😭) or permanently (which do survive restarts πŸ‘‘). choose wisely bestie.

For instance:

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

Query string parameters:

  • "flat_settings"

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


πŸ—ΊοΈ state()

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

The state() method hands you the current cluster state, straight from the master node β€” or from the responding node if local is set to true. versatility, she has it ✨

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

  • "_all"
  • "blocks"
  • "metadata"
  • "nodes"
  • "routing_table"

And the metrics for indices can be limited to particular indices with the index parameter. very demure, very mindful πŸ¦‹

Query string parameters:

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

See the cluster state docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-state.html for more info ⭐


⏳ pending_tasks()

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

Returns a list of cluster-level tasks that are still pending on the master node. like, they're in the queue, they're waiting, they're not forgotten πŸ’€

Query string parameters:

  • "local"
  • "master_timeout"

See the pending tasks docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-pending.html for more info 🧚


🚚 reroute()

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

The reroute() method is how you manually reallocate shards from one node to another. The body should contain the commands telling it 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'
            }}
        ]
    }
);

(yes, the to_node value in that example is missing its closing quote β€” that's literally how it is in the original, so I'm leaving it exactly as-is πŸ™ˆ)

Query string parameters:

  • "dry_run"
  • "explain"
  • "master_timeout"
  • "metric"
  • "timeout"

See the reroute docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-reroute.html for more info πŸ”₯


πŸ‘‘ AUTHOR πŸ‘‘

Enrico Zimuel <enrico.zimuel@elastic.co> β€” the legend, the author, the moment πŸ’…


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 came from perl v5.36.0, dated 2022-08-28, and it's Search...Cluster(3pm) in the User Contributed Perl Documentation section β€” so cute, so historic, so slay. bye bye, go reroute something πŸ’–πŸŒˆβœ¨

πŸ“¦ where this page comes from