<commit_before>[role="xpack"]
[testenv="basic"]
[[start-stop-ilm]]
== Start and stop {ilm}

All indices that are managed by ILM will continue to execute
their policies. There may be times when this is not desired on certain
indices, or maybe even all the indices in a cluster. For example,
maybe there are scheduled maintenance windows when cluster topology
changes are desired that may impact running ILM actions. For this reason,
ILM has two ways to disable operations.

When stopping ILM, snapshot lifecycle management operations are also stopped,
this means that no scheduled snapshots are created (currently ongoing snapshots
are unaffected).

Normally, ILM will be running by default.
To see the current operating status of ILM, use the <<ilm-get-status,Get Status API>>
to see the current state of ILM.

////
[source,console]
--------------------------------------------------
PUT _ilm/policy/my_policy
{
  "policy": {
    "phases": {
      "warm": {
        "min_age": "10d",
        "actions": {
          "forcemerge": {
            "max_num_segments": 1
          }
        }
      },
      "delete": {
        "min_age": "30d",
        "actions": {
          "delete": {}
        }
      }
    }
  }
}

PUT my_index
{
  "settings": {
    "index.lifecycle.name": "my_policy"
  }
}
--------------------------------------------------
////

[source,console]
--------------------------------------------------
GET _ilm/status
--------------------------------------------------

If the request does not encounter errors, you receive the following result:

[source,console-result]
--------------------------------------------------
{
  "operation_mode": "RUNNING"
}
--------------------------------------------------

The operating modes of ILM:

[[ilm-operating-modes]]
.ILM Operating Modes
[options="header"]
|===
|Name |Description
|RUNNING |Normal operation where all policies are executed as normal
|STOPPING|ILM has received a request to stop but is still processing some policies
|STOPPED |This represents a state where no policies are executed
|===

[float]
=== Stopping ILM=

The ILM service can be paused such that no further steps will be executed
using the <<ilm-stop,Stop API>>.

[source,console]
--------------------------------------------------
POST _ilm/stop
--------------------------------------------------
// TEST[continued]

When stopped, all further policy actions will be halted. This will
be reflected in the Status API

////
[source,console]
--------------------------------------------------
GET _ilm/status
--------------------------------------------------
// TEST[continued]
////

[source,console-result]
--------------------------------------------------
{
  "operation_mode": "STOPPING"
}
--------------------------------------------------
// TESTRESPONSE[skip:"AwaitsFix https://github.com/elastic/elasticsearch/issues/46528"]

The ILM service will then, asynchronously, run all policies to a point
where it is safe to stop. After ILM verifies that it is safe, it will
move to the `STOPPED` mode.

////
[source,console]
--------------------------------------------------
PUT trigger_ilm_cs_action

GET _ilm/status
--------------------------------------------------
// TEST[continued]
////

[source,console-result]
--------------------------------------------------
{
  "operation_mode": "STOPPED"
}
--------------------------------------------------

[float]
=== Starting ILM

To start ILM and continue executing policies, use the <<ilm-start, Start API>>.


[source,console]
--------------------------------------------------
POST _ilm/start
--------------------------------------------------
// TEST[continued]

////
[source,console]
--------------------------------------------------
GET _ilm/status
--------------------------------------------------
// TEST[continued]
////

The Start API will send a request to the ILM service to immediately begin
normal operations.

[source,console-result]
--------------------------------------------------<commit_msg>Fix ILM start and stop doc tests (#46559)<commit_after>[role="xpack"]
[testenv="basic"]
[[start-stop-ilm]]
== Start and stop {ilm}

All indices that are managed by ILM will continue to execute
their policies. There may be times when this is not desired on certain
indices, or maybe even all the indices in a cluster. For example,
maybe there are scheduled maintenance windows when cluster topology
changes are desired that may impact running ILM actions. For this reason,
ILM has two ways to disable operations.

When stopping ILM, snapshot lifecycle management operations are also stopped,
this means that no scheduled snapshots are created (currently ongoing snapshots
are unaffected).

Normally, ILM will be running by default.
To see the current operating status of ILM, use the <<ilm-get-status,Get Status API>>
to see the current state of ILM.

////
[source,console]
--------------------------------------------------
PUT _ilm/policy/my_policy
{
  "policy": {
    "phases": {
      "warm": {
        "min_age": "10d",
        "actions": {
          "forcemerge": {
            "max_num_segments": 1
          }
        }
      },
      "delete": {
        "min_age": "30d",
        "actions": {
          "delete": {}
        }
      }
    }
  }
}

PUT my_index
{
  "settings": {
    "index.lifecycle.name": "my_policy"
  }
}
--------------------------------------------------
////

[source,console]
--------------------------------------------------
GET _ilm/status
--------------------------------------------------

If the request does not encounter errors, you receive the following result:

[source,console-result]
--------------------------------------------------
{
  "operation_mode": "RUNNING"
}
--------------------------------------------------

The operating modes of ILM:

[[ilm-operating-modes]]
.ILM Operating Modes
[options="header"]
|===
|Name |Description
|RUNNING |Normal operation where all policies are executed as normal
|STOPPING|ILM has received a request to stop but is still processing some policies
|STOPPED |This represents a state where no policies are executed
|===

[float]
=== Stopping ILM=

The ILM service can be paused such that no further steps will be executed
using the <<ilm-stop,Stop API>>.

[source,console]
--------------------------------------------------
POST _ilm/stop
--------------------------------------------------
// TEST[continued]

When stopped, all further policy actions will be halted. This will
be reflected in the Status API

////
[source,console]
--------------------------------------------------
GET _ilm/status
--------------------------------------------------
// TEST[continued]
////

[source,console-result]
--------------------------------------------------
{
  "operation_mode": "STOPPING"
}
--------------------------------------------------
// TESTRESPONSE[s/"STOPPING"/$body.operation_mode/]

The ILM service will then, asynchronously, run all policies to a point
where it is safe to stop. After ILM verifies that it is safe, it will
move to the `STOPPED` mode.

////
[source,console]
--------------------------------------------------
PUT trigger_ilm_cs_action

GET _ilm/status
--------------------------------------------------
// TEST[continued]
////

[source,console-result]
--------------------------------------------------
{
  "operation_mode": "STOPPED"
}
--------------------------------------------------
// TESTRESPONSE[s/"STOPPED"/$body.operation_mode/]

[float]
=== Starting ILM

To start ILM and continue executing policies, use the <<ilm-start, Start API>>.


[source,console]
--------------------------------------------------
POST _ilm/start
--------------------------------------------------
// TEST[continued]

////
[source,console]
--------------------------------------------------
GET _ilm/status
--------------------------------------------------
// TEST[continued]
////

The Start API will send a request to the ILM service to immediately begin
normal operations.

[source,console-result]
--------------------------------------------------
{'fraction_non_alphanumeric': 0.34166977728007963, 'fraction_numerical': 0.0024884907303720292, 'mean_word_length': 1.3448074679113184, 'pattern_counts': {'":': 32, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7380110', 'n_tokens_mistral': 1943, 'n_tokens_neox': 1884, 'n_words': 683}