Permalink
Browse files

Elastic: show relocating indexes in the views

  • Loading branch information...
NickCraver committed Oct 23, 2018
1 parent 1aaf4a0 commit f685367cd23d63af01472ced3857fe4bc8ec3c78
@@ -30,6 +30,16 @@ public IEnumerable<ClusterHealthInfo.IndexHealthInfo> TroubledIndexes
}
}
public IEnumerable<ClusterHealthInfo.IndexHealthInfo> InterestingIndexes
{
get
{
return HealthStatus.Data?.Indexes != null
? HealthStatus.Data.Indexes.Values.Where(i => i.MonitorStatus != MonitorStatus.Good || i.InitializingShards > 0 || i.UnassignedShards > 0 || i.RelocatingShards > 0).OrderByWorst()
: Enumerable.Empty<ClusterHealthInfo.IndexHealthInfo>();
}
}
public class ClusterHealthInfo : IMonitorStatus
{
public MonitorStatus MonitorStatus => ColorToStatus(Status);
@@ -24,7 +24,7 @@ public ActionResult Dashboard()
var vd = new DashboardModel
{
View = DashboardModel.Views.AllClusters,
WarningsOnly = true
DisplayMode = DashboardModel.DisplayModes.InterestingOnly
};
return View("AllClusters", vd);
}
@@ -194,11 +194,11 @@
}
</div>
<div class="js-refresh" data-name="cluster-sub-detail">
@foreach (var c in Model.Clusters.Where(c => c.TroubledIndexes.Any()))
@foreach (var c in Model.Clusters.Where(c => c.InterestingIndexes.Any()))
{
var m = new DashboardModel
{
WarningsOnly = Model.WarningsOnly,
DisplayMode = Model.DisplayMode,
CurrentCluster = c
};
<h5 class="page-header">
@@ -4,9 +4,9 @@
Layout = null;
var c = Model.CurrentCluster;
var i = Model.CurrentIndexName;
var shards = (Model.WarningsOnly ? c.TroubledShards : c.AllShards).Where(s => i == null || s.Index == i).ToList();
var shards = Model.DisplayShards.Where(s => i == null || s.Index == i).ToList();
}
<h4 class="modal-title">
@shards.Count.ToComma() Shards @(Model.WarningsOnly ? "in trouble" : "") on @c.HealthStatus.Data.TotalNodeCount.Pluralize("node") (@c.HealthStatus.Data.Name)
@shards.Count.ToComma() Shards @(Model.DisplayMode == DashboardModel.DisplayModes.WarningsOnly ? "in trouble" : "") on @c.HealthStatus.Data.TotalNodeCount.Pluralize("node") (@c.HealthStatus.Data.Name)
</h4>
@{ Html.RenderPartial("Shards.Table", Model); }
@@ -16,7 +16,48 @@ public class DashboardModel
//TODO: Global settings pre-websockets
public int Refresh { get; set; } = 10;
public bool WarningsOnly { get; set; }
public DisplayModes DisplayMode { get; set; }
public enum DisplayModes
{
All,
InterestingOnly,
WarningsOnly
}
public IEnumerable<ElasticCluster.ClusterHealthInfo.IndexHealthInfo> DisplayIndexexs
{
get
{
switch (DisplayMode)
{
case DisplayModes.InterestingOnly:
return CurrentCluster?.TroubledIndexes; // TODO: Differentiate both
case DisplayModes.WarningsOnly:
return CurrentCluster?.TroubledIndexes;
//case DashboardModel.DisplayModes.All:
default:
return CurrentCluster?.HealthStatus.Data?.Indexes?.Values;
}
}
}
public IEnumerable<ElasticCluster.ClusterStateInfo.ShardState> DisplayShards
{
get
{
switch (DisplayMode)
{
case DisplayModes.InterestingOnly:
return CurrentCluster?.TroubledShards; // TODO: Differentiate both
case DisplayModes.WarningsOnly:
return CurrentCluster?.TroubledShards;
//case DashboardModel.DisplayModes.All:
default:
return CurrentCluster?.AllShards;
}
}
}
public Views View { get; set; }
@@ -29,4 +70,4 @@ public enum Views
Shards = 4
}
}
}
}
@@ -1,12 +1,10 @@
@using StackExchange.Opserver.Data.Elastic
@model StackExchange.Opserver.Views.Elastic.DashboardModel
@using StackExchange.Opserver.Views.Elastic
@model DashboardModel
@{
var c = Model.CurrentCluster;
if (c == null) { return; }
var indexes = Model.WarningsOnly
? c.TroubledIndexes.ToList()
: c.HealthStatus.Data?.Indexes?.Values.ToList()
?? new List<ElasticCluster.ClusterHealthInfo.IndexHealthInfo>();
var indexes = Model.DisplayIndexexs ?? new List<ElasticCluster.ClusterHealthInfo.IndexHealthInfo>();
var stats = c.IndexStats.SafeData(true);
}
@if (indexes.Any())
@@ -61,7 +59,7 @@
<td>@i.UnassignedShards.ToComma()</td>
</tr>
}
@if (!Model.WarningsOnly)
@if (Model.DisplayMode == DashboardModel.DisplayModes.All)
{
var indexStats = stats.Indexes?.Values;
<tr class="total-row">
@@ -86,7 +84,7 @@
</tbody>
</table>
}
else if (!Model.WarningsOnly)
else if (Model.DisplayMode == DashboardModel.DisplayModes.All)
{
<div class="no-content">No indexes found in the @c.Name cluster</div>
}
@@ -1,12 +1,13 @@
@model StackExchange.Opserver.Views.Elastic.DashboardModel
@using StackExchange.Opserver.Views.Elastic
@model StackExchange.Opserver.Views.Elastic.DashboardModel
@{
var c = Model.CurrentCluster;
if (c == null) { return; }
var indexes = c.HealthStatus.Data.Indexes.Values.ToList();
}
<div class="js-refresh" data-name="elastic-indexes">
<h5 class="page-header">
@c.IconSpan() @c.Name: @indexes.Count.Pluralize("Index") @(Model.WarningsOnly ? "in trouble" : "") on @(c.Nodes.Data?.Nodes?.Count.Pluralize("node"))
@c.IconSpan() @c.Name: @indexes.Count.Pluralize("Index") @(Model.DisplayMode == DashboardModel.DisplayModes.WarningsOnly ? "in trouble" : "") on @(c.Nodes.Data?.Nodes?.Count.Pluralize("node"))
<span class="small">(Updated @c.IndexStats.ToPollSpan())</span>
@Helpers.PollNow(c)
</h5>
@@ -5,7 +5,7 @@
Layout = null;
var c = Model.CurrentCluster;
var i = Model.CurrentIndexName;
var shards = (Model.WarningsOnly ? c.TroubledShards : c.AllShards).Where(s => i == null || s.Index == i).ToList();
var shards = Model.DisplayShards.Where(s => i == null || s.Index == i).ToList();
}
@helper GetNodeName(string node, Dictionary<string, ElasticCluster.NodeInfo> nodes)
{

0 comments on commit f685367

Please sign in to comment.