Browse Source

Add start slm user action (#87854)

This creates a user action for the slm health indicator that will help
the user to start SLM.
Andrei Dan 3 years ago
parent
commit
6e98072db5

+ 40 - 0
docs/reference/tab-widgets/troubleshooting/data/start-slm-widget.asciidoc

@@ -0,0 +1,40 @@
+++++
+<div class="tabs" data-tab-group="host">
+  <div role="tablist" aria-label="Start SLM">
+    <button role="tab"
+            aria-selected="true"
+            aria-controls="cloud-tab-start-slm"
+            id="cloud-start-slm">
+      Elasticsearch Service
+    </button>
+    <button role="tab"
+            aria-selected="false"
+            aria-controls="self-managed-tab-start-slm"
+            id="self-managed-start-slm"
+            tabindex="-1">
+      Self-managed
+    </button>
+  </div>
+  <div tabindex="0"
+       role="tabpanel"
+       id="cloud-tab-start-slm"
+       aria-labelledby="cloud-start-slm">
+++++
+
+include::start-slm.asciidoc[tag=cloud]
+
+++++
+  </div>
+  <div tabindex="0"
+       role="tabpanel"
+       id="self-managed-tab-start-slm"
+       aria-labelledby="self-managed-start-slm"
+       hidden="">
+++++
+
+include::start-slm.asciidoc[tag=self-managed]
+
+++++
+  </div>
+</div>
+++++

+ 87 - 0
docs/reference/tab-widgets/troubleshooting/data/start-slm.asciidoc

@@ -0,0 +1,87 @@
+// tag::cloud[]
+In order to start {slm} we need to go to Kibana and execute the <<slm-api-start, start command>>.
+
+**Use {kib}**
+
+//tag::kibana-api-ex[]
+. Log in to the {ess-console}[{ecloud} console].
++
+
+. On the **Elasticsearch Service** panel, click the name of your deployment. 
++
+
+NOTE:
+If the name of your deployment is disabled your {kib} instances might be
+unhealthy, in which case please contact https://support.elastic.co[Elastic Support].
+If your deployment doesn't include {kib}, all you need to do is 
+{cloud}/ec-access-kibana.html[enable it first].
+
+. Open your deployment's side navigation menu (placed under the Elastic logo in the upper left corner)
+and go to **Dev Tools > Console**.
++
+[role="screenshot"]
+image::images/kibana-console.png[{kib} Console,align="center"]
+
+. <<slm-api-start, Start>> {slm}:
++
+[source,console]
+----
+POST _slm/start
+----
++
+The reponse will look like this:
++
+[source,console-result]
+----
+{
+  "acknowledged": true
+}
+----
+// TESTRESPONSE[skip:the result is for illustrating purposes only]
++
+. Verify {slm} is now running:
++
+[source,console]
+----
+GET _slm/status
+----
++
+The reponse will look like this:
++
+[source,console-result]
+----
+{
+  "operation_mode": "RUNNING"
+}
+----
+// TESTRESPONSE[skip:the result is for illustrating purposes only]
+//end::kibana-api-ex[]
+// end::cloud[]
+
+// tag::self-managed[]
+<<slm-api-start, Start>> {slm}:
+[source,console]
+----
+POST _slm/start
+----
+The reponse will look like this:
+[source,console-result]
+----
+{
+  "acknowledged": true
+}
+----
+// TESTRESPONSE[skip:the result is for illustrating purposes only]
+Verify the {slm} is now running:
+[source,console]
+----
+GET _slm/status
+----
+The reponse will look like this:
+[source,console-result]
+----
+{
+  "operation_mode": "RUNNING"
+}
+----
+// end::self-managed[]

+ 2 - 0
docs/reference/troubleshooting.asciidoc

@@ -54,6 +54,8 @@ include::troubleshooting/data/increase-tier-capacity.asciidoc[]
 
 include::troubleshooting/data/start-ilm.asciidoc[]
 
+include::troubleshooting/data/start-slm.asciidoc[]
+
 include::monitoring/troubleshooting.asciidoc[]
 
 include::transform/troubleshooting.asciidoc[leveloffset=+1]

+ 12 - 0
docs/reference/troubleshooting/data/start-slm.asciidoc

@@ -0,0 +1,12 @@
+[[start-slm]]
+== Start Snapshot Lifecycle Management
+
+Automatic snapshot lifecycle management is currently disabled. New backup
+snapshots will not be created automatically.
+
+In order to start the snapshot lifecycle management service, follow these steps:
+
+include::{es-repo-dir}/tab-widgets/troubleshooting/data/start-slm-widget.asciidoc[]
+
+
+

+ 6 - 1
x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SlmHealthIndicatorService.java

@@ -14,6 +14,7 @@ import org.elasticsearch.health.HealthIndicatorResult;
 import org.elasticsearch.health.HealthIndicatorService;
 import org.elasticsearch.health.ImpactArea;
 import org.elasticsearch.health.SimpleHealthIndicatorDetails;
+import org.elasticsearch.health.UserAction;
 import org.elasticsearch.xpack.core.ilm.OperationMode;
 import org.elasticsearch.xpack.core.slm.SnapshotLifecycleMetadata;
 
@@ -38,6 +39,10 @@ public class SlmHealthIndicatorService implements HealthIndicatorService {
     public static final String NAME = "slm";
 
     public static final String HELP_URL = "https://ela.st/fix-slm";
+    public static final UserAction SLM_NOT_RUNNING = new UserAction(
+        new UserAction.Definition("slm-not-running", "Start SLM using [POST /_slm/start].", HELP_URL),
+        null
+    );
 
     private final ClusterService clusterService;
 
@@ -79,7 +84,7 @@ public class SlmHealthIndicatorService implements HealthIndicatorService {
                     List.of(ImpactArea.BACKUP)
                 )
             );
-            return createIndicator(YELLOW, "SLM is not running", createDetails(explain, slmMetadata), impacts, Collections.emptyList());
+            return createIndicator(YELLOW, "SLM is not running", createDetails(explain, slmMetadata), impacts, List.of(SLM_NOT_RUNNING));
         } else {
             return createIndicator(
                 GREEN,

+ 2 - 1
x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/slm/SlmHealthIndicatorServiceTests.java

@@ -31,6 +31,7 @@ import static org.elasticsearch.xpack.core.ilm.OperationMode.RUNNING;
 import static org.elasticsearch.xpack.core.ilm.OperationMode.STOPPED;
 import static org.elasticsearch.xpack.core.ilm.OperationMode.STOPPING;
 import static org.elasticsearch.xpack.slm.SlmHealthIndicatorService.NAME;
+import static org.elasticsearch.xpack.slm.SlmHealthIndicatorService.SLM_NOT_RUNNING;
 import static org.hamcrest.Matchers.equalTo;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -80,7 +81,7 @@ public class SlmHealthIndicatorServiceTests extends ESTestCase {
                             List.of(ImpactArea.BACKUP)
                         )
                     ),
-                    Collections.emptyList()
+                    List.of(SLM_NOT_RUNNING)
                 )
             )
         );