Merge pull request #14385 from ywelsch/feature/cat-snapshots-duration
Add duration field to /_cat/snapshots
This commit is contained in:
commit
c4b68801bf
|
@ -26,6 +26,7 @@ import org.elasticsearch.client.Client;
|
|||
import org.elasticsearch.common.Table;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.rest.RestChannel;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
|
@ -33,6 +34,7 @@ import org.elasticsearch.rest.RestResponse;
|
|||
import org.elasticsearch.rest.action.support.RestResponseListener;
|
||||
import org.elasticsearch.rest.action.support.RestTable;
|
||||
import org.elasticsearch.snapshots.SnapshotInfo;
|
||||
import org.elasticsearch.snapshots.SnapshotState;
|
||||
import org.joda.time.format.DateTimeFormat;
|
||||
import org.joda.time.format.DateTimeFormatter;
|
||||
|
||||
|
@ -80,6 +82,7 @@ public class RestSnapshotAction extends AbstractCatAction {
|
|||
.addCell("start_time", "alias:sti,startTime;desc:start time in HH:MM:SS")
|
||||
.addCell("end_epoch", "alias:ete,endEpoch;desc:end time in seconds since 1970-01-01 00:00:00")
|
||||
.addCell("end_time", "alias:eti,endTime;desc:end time in HH:MM:SS")
|
||||
.addCell("duration", "alias:dur,duration;text-align:right;desc:duration")
|
||||
.addCell("indices", "alias:i,indices;text-align:right;desc:number of indices")
|
||||
.addCell("successful_shards", "alias:ss,successful_shards;text-align:right;desc:number of successful shards")
|
||||
.addCell("failed_shards", "alias:fs,failed_shards;text-align:right;desc:number of failed shards")
|
||||
|
@ -101,6 +104,13 @@ public class RestSnapshotAction extends AbstractCatAction {
|
|||
table.addCell(dateFormat.print(snapshotStatus.startTime()));
|
||||
table.addCell(TimeUnit.SECONDS.convert(snapshotStatus.endTime(), TimeUnit.MILLISECONDS));
|
||||
table.addCell(dateFormat.print(snapshotStatus.endTime()));
|
||||
final long durationMillis;
|
||||
if (snapshotStatus.state() == SnapshotState.IN_PROGRESS) {
|
||||
durationMillis = System.currentTimeMillis() - snapshotStatus.startTime();
|
||||
} else {
|
||||
durationMillis = snapshotStatus.endTime() - snapshotStatus.startTime();
|
||||
}
|
||||
table.addCell(TimeValue.timeValueMillis(durationMillis));
|
||||
table.addCell(snapshotStatus.indices().size());
|
||||
table.addCell(snapshotStatus.successfulShards());
|
||||
table.addCell(snapshotStatus.failedShards());
|
||||
|
|
|
@ -8,9 +8,9 @@ Querying the snapshots of a repository named `repo1` then looks as follows.
|
|||
[source,sh]
|
||||
--------------------------------------------------
|
||||
% curl 'localhost:9200/_cat/snapshots/repo1?v'
|
||||
id status start_epoch start_time end_epoch end_time indices successful_shards failed_shards total_shards
|
||||
snap1 FAILED 1445616705 18:11:45 1445616978 18:16:18 1 4 1 5
|
||||
snap2 SUCCESS 1445634298 23:04:58 1445634672 23:11:12 2 10 0 10
|
||||
id status start_epoch start_time end_epoch end_time duration indices successful_shards failed_shards total_shards
|
||||
snap1 FAILED 1445616705 18:11:45 1445616978 18:16:18 4.6m 1 4 1 5
|
||||
snap2 SUCCESS 1445634298 23:04:58 1445634672 23:11:12 6.2m 2 10 0 10
|
||||
--------------------------------------------------
|
||||
|
||||
Each snapshot contains information about when it was started and stopped.
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
start_time .+ \n
|
||||
end_epoch .+ \n
|
||||
end_time .+ \n
|
||||
duration .+ \n
|
||||
indices .+ \n
|
||||
successful_shards .+ \n
|
||||
failed_shards .+ \n
|
||||
|
@ -74,6 +75,6 @@
|
|||
|
||||
- match:
|
||||
$body: |
|
||||
/^ snap1\s+ SUCCESS\s+ \d+\s+ \d\d\:\d\d\:\d\d\s+ \d+\s+ \d\d\:\d\d\:\d\d\s+ 2\s+ 2\s+ 0\s+ 2\s*\n
|
||||
snap2\s+ SUCCESS\s+ \d+\s+ \d\d\:\d\d\:\d\d\s+ \d+\s+ \d\d\:\d\d\:\d\d\s+ 2\s+ 2\s+ 0\s+ 2\s*\n
|
||||
/^ snap1\s+ SUCCESS\s+ \d+\s+ \d\d\:\d\d\:\d\d\s+ \d+\s+ \d\d\:\d\d\:\d\d\s+ \S+\s+ 2\s+ 2\s+ 0\s+ 2\s*\n
|
||||
snap2\s+ SUCCESS\s+ \d+\s+ \d\d\:\d\d\:\d\d\s+ \d+\s+ \d\d\:\d\d\:\d\d\s+ \S+\s+ 2\s+ 2\s+ 0\s+ 2\s*\n
|
||||
$/
|
||||
|
|
Loading…
Reference in New Issue