| 1 | # Licensed to Elasticsearch B.V. under one or more contributor | ||
| 2 | # license agreements. See the NOTICE file distributed with | ||
| 3 | # this work for additional information regarding copyright | ||
| 4 | # ownership. Elasticsearch B.V. licenses this file to you under | ||
| 5 | # the Apache License, Version 2.0 (the "License"); you may | ||
| 6 | # not use this file except in compliance with the License. | ||
| 7 | # You may obtain a copy of the License at | ||
| 8 | # | ||
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
| 10 | # | ||
| 11 | # Unless required by applicable law or agreed to in writing, | ||
| 12 | # software distributed under the License is distributed on an | ||
| 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| 14 | # KIND, either express or implied. See the License for the | ||
| 15 | # specific language governing permissions and limitations | ||
| 16 | # under the License. | ||
| 17 | |||
| 18 | package Search::Elasticsearch::Client::8_0::Direct::Cluster; | ||
| 19 | $Search::Elasticsearch::Client::8_0::Direct::Cluster::VERSION = '8.12'; | ||
| 20 | use Moo; | ||
| 21 | with 'Search::Elasticsearch::Client::8_0::Role::API'; | ||
| 22 | with 'Search::Elasticsearch::Role::Client::Direct'; | ||
| 23 | __PACKAGE__->_install_api('cluster'); | ||
| 24 | |||
| 25 | 1; | ||
| 26 | |||
| 27 | =pod | ||
| 28 | |||
| 29 | =encoding UTF-8 | ||
| 30 | |||
| 31 | =head1 NAME | ||
| 32 | |||
| 33 | Search::Elasticsearch::Client::8_0::Direct::Cluster - A client for running cluster-level requests | ||
| 34 | |||
| 35 | =head1 VERSION | ||
| 36 | |||
| 37 | version 8.12 | ||
| 38 | |||
| 39 | =head1 DESCRIPTION | ||
| 40 | |||
| 41 | This module provides methods to make cluster-level requests, such as | ||
| 42 | getting and setting cluster-level settings, manually rerouting shards, | ||
| 43 | and retrieving for monitoring purposes. | ||
| 44 | |||
| 45 | It does L<Search::Elasticsearch::Role::Client::Direct>. | ||
| 46 | |||
| 47 | =head1 METHODS | ||
| 48 | |||
| 49 | =head2 C<health()> | ||
| 50 | |||
| 51 | $response = $e->cluster->health( | ||
| 52 | index => 'index' | \@indices # optional | ||
| 53 | ); | ||
| 54 | |||
| 55 | The C<health()> method is used to retrieve information about the cluster | ||
| 56 | health, returning C<red>, C<yellow> or C<green> to indicate the state | ||
| 57 | of the cluster, indices or shards. | ||
| 58 | |||
| 59 | Query string parameters: | ||
| 60 | C<error_trace>, | ||
| 61 | C<human>, | ||
| 62 | C<level>, | ||
| 63 | C<local>, | ||
| 64 | C<master_timeout>, | ||
| 65 | C<timeout>, | ||
| 66 | C<wait_for_active_shards>, | ||
| 67 | C<wait_for_events>, | ||
| 68 | C<wait_for_no_initializing_shards>, | ||
| 69 | C<wait_for_no_relocating_shards>, | ||
| 70 | C<wait_for_nodes>, | ||
| 71 | C<wait_for_status> | ||
| 72 | |||
| 73 | See the L<cluster health docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html> | ||
| 74 | for more information. | ||
| 75 | |||
| 76 | =head2 C<stats()> | ||
| 77 | |||
| 78 | $response = $e->cluster->stats( | ||
| 79 | node_id => 'node' | \@nodes # optional | ||
| 80 | ); | ||
| 81 | |||
| 82 | Returns high-level cluster stats, optionally limited to the listed nodes. | ||
| 83 | |||
| 84 | Query string parameters: | ||
| 85 | C<error_trace>, | ||
| 86 | C<flat_settings>, | ||
| 87 | C<human>, | ||
| 88 | C<timeout> | ||
| 89 | |||
| 90 | See the L<cluster stats docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-stats.html> | ||
| 91 | for more information. | ||
| 92 | |||
| 93 | =head2 C<get_settings()> | ||
| 94 | |||
| 95 | $response = $e->cluster->get_settings() | ||
| 96 | |||
| 97 | The C<get_settings()> method is used to retrieve cluster-wide settings that | ||
| 98 | have been set with the L</put_settings()> method. | ||
| 99 | |||
| 100 | Query string parameters: | ||
| 101 | C<error_trace>, | ||
| 102 | C<flat_settings>, | ||
| 103 | C<human>, | ||
| 104 | C<include_defaults>, | ||
| 105 | C<master_timeout>, | ||
| 106 | C<timeout> | ||
| 107 | |||
| 108 | See the L<cluster settings docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html> | ||
| 109 | for more information. | ||
| 110 | |||
| 111 | =head2 C<put_settings()> | ||
| 112 | |||
| 113 | $response = $e->cluster->put_settings( %settings ); | ||
| 114 | |||
| 115 | The C<put_settings()> method is used to set cluster-wide settings, either | ||
| 116 | transiently (which don't survive restarts) or permanently (which do survive | ||
| 117 | restarts). | ||
| 118 | |||
| 119 | For instance: | ||
| 120 | |||
| 121 | $response = $e->cluster->put_settings( | ||
| 122 | body => { | ||
| 123 | transient => { "discovery.zen.minimum_master_nodes" => 6 } | ||
| 124 | } | ||
| 125 | ); | ||
| 126 | |||
| 127 | Query string parameters: | ||
| 128 | C<error_trace>, | ||
| 129 | C<flat_settings>, | ||
| 130 | C<human> | ||
| 131 | |||
| 132 | See the L<cluster settings docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html> | ||
| 133 | for more information. | ||
| 134 | |||
| 135 | =head2 C<state()> | ||
| 136 | |||
| 137 | $response = $e->cluster->state( | ||
| 138 | metric => $metric | \@metrics # optional | ||
| 139 | index => $index | \@indices # optional | ||
| 140 | ); | ||
| 141 | |||
| 142 | The C<state()> method returns the current cluster state from the master node, | ||
| 143 | or from the responding node if C<local> is set to C<true>. | ||
| 144 | |||
| 145 | It returns all metrics by default, but these can be limited to any of: | ||
| 146 | C<_all>, | ||
| 147 | C<blocks>, | ||
| 148 | C<metadata>, | ||
| 149 | C<nodes>, | ||
| 150 | C<routing_table> | ||
| 151 | |||
| 152 | Metrics for indices can be limited to particular indices with the C<index> | ||
| 153 | parameter. | ||
| 154 | |||
| 155 | Query string parameters: | ||
| 156 | C<allow_no_indices>, | ||
| 157 | C<error_trace>, | ||
| 158 | C<expand_wildcards>, | ||
| 159 | C<flat_settings>, | ||
| 160 | C<human>, | ||
| 161 | C<ignore_unavailable>, | ||
| 162 | C<local>, | ||
| 163 | C<master_timeout>, | ||
| 164 | C<wait_for_metadata_version>, | ||
| 165 | C<wait_for_timeout> | ||
| 166 | |||
| 167 | See the L<cluster state docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-state.html> | ||
| 168 | for more information. | ||
| 169 | |||
| 170 | =head2 C<allocation_explain()> | ||
| 171 | |||
| 172 | $response = $e->cluster->allocation_explain( | ||
| 173 | body => { ... shard selectors ...} # optional | ||
| 174 | ); | ||
| 175 | |||
| 176 | Returns information about why a shard is allocated or unallocated or why. | ||
| 177 | |||
| 178 | Query string parameters: | ||
| 179 | C<error_trace>, | ||
| 180 | C<human>, | ||
| 181 | C<include_disk_info>, | ||
| 182 | C<include_yes_decisions> | ||
| 183 | |||
| 184 | See the L<cluster allocation explain docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-allocation-explain.html> | ||
| 185 | for more information. | ||
| 186 | |||
| 187 | =head2 C<pending_tasks()> | ||
| 188 | |||
| 189 | $response = $e->cluster->pending_tasks(); | ||
| 190 | |||
| 191 | Returns a list of cluster-level tasks still pending on the master node. | ||
| 192 | |||
| 193 | Query string parameters: | ||
| 194 | C<error_trace>, | ||
| 195 | C<human>, | ||
| 196 | C<local>, | ||
| 197 | C<master_timeout> | ||
| 198 | |||
| 199 | See the L<pending tasks docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-pending.html> | ||
| 200 | for more information. | ||
| 201 | |||
| 202 | =head2 C<reroute()> | ||
| 203 | |||
| 204 | $e->cluster->reroute( | ||
| 205 | body => { commands } | ||
| 206 | ); | ||
| 207 | |||
| 208 | The C<reroute()> method is used to manually reallocate shards from one | ||
| 209 | node to another. The C<body> should contain the C<commands> indicating | ||
| 210 | which changes should be made. For instance: | ||
| 211 | |||
| 212 | $e->cluster->reroute( | ||
| 213 | body => { | ||
| 214 | commands => [ | ||
| 215 | { move => { | ||
| 216 | index => 'test', | ||
| 217 | shard => 0, | ||
| 218 | from_node => 'node_1', | ||
| 219 | to_node => 'node_2 | ||
| 220 | }}, | ||
| 221 | { allocate => { | ||
| 222 | index => 'test', | ||
| 223 | shard => 1, | ||
| 224 | node => 'node_3' | ||
| 225 | }} | ||
| 226 | ] | ||
| 227 | } | ||
| 228 | ); | ||
| 229 | |||
| 230 | Query string parameters: | ||
| 231 | C<dry_run>, | ||
| 232 | C<error_trace>, | ||
| 233 | C<explain>, | ||
| 234 | C<human>, | ||
| 235 | C<master_timeout>, | ||
| 236 | C<metric>, | ||
| 237 | C<retry_failed>, | ||
| 238 | C<timeout> | ||
| 239 | |||
| 240 | See the L<reroute docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-reroute.html> | ||
| 241 | for more information. | ||
| 242 | |||
| 243 | =head2 C<remote_info()> | ||
| 244 | |||
| 245 | $response = $e->cluster->remote_info(); | ||
| 246 | |||
| 247 | The C<remote_info()> API retrieves all of the configured remote cluster information. | ||
| 248 | |||
| 249 | Query string parameters: | ||
| 250 | C<error_trace>, | ||
| 251 | C<human> | ||
| 252 | |||
| 253 | See the L<remote_info docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-remote-info.html> | ||
| 254 | for more information. | ||
| 255 | |||
| 256 | =head1 AUTHOR | ||
| 257 | |||
| 258 | Enrico Zimuel <enrico.zimuel@elastic.co> | ||
| 259 | |||
| 260 | =head1 COPYRIGHT AND LICENSE | ||
| 261 | |||
| 262 | This software is Copyright (c) 2024 by Elasticsearch BV. | ||
| 263 | |||
| 264 | This is free software, licensed under: | ||
| 265 | |||
| 266 | The Apache License, Version 2.0, January 2004 | ||
| 267 | |||
| 268 | =cut | ||
| 269 | |||
| 270 | __END__ |