-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bfcdbb4
commit ed70511
Showing
14 changed files
with
269 additions
and
270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,36 @@ | ||
import uiModules from 'ui/modules'; | ||
import _ from 'lodash'; | ||
import { initChart, getDataHeatMap } from './chart_utils'; | ||
|
||
|
||
uiModules | ||
.get('app/topology', []) | ||
.factory('Topology', ['$http', '$q', 'chrome', function ($http, $q, chrome) { | ||
.factory('Topology', ['$http', 'chrome', function ($http, chrome) { | ||
class Topology { | ||
|
||
constructor() { | ||
} | ||
|
||
getClusterTopology() { | ||
return $http.get(chrome.addBasePath('/topology/cluster')); | ||
} | ||
constructor(container) { | ||
$http.get(chrome.addBasePath('/topology/cluster_health')) | ||
.then( (health) => { | ||
this.description = health.data; | ||
}.bind(this)); | ||
|
||
getIndicesColors( indices ) { | ||
return _.map( indices, ( index ) => index.color ); | ||
this.chart = initChart(container); | ||
} | ||
|
||
getShardsColors( indices ) { | ||
return _.map( indices, ( index ) => _.map( index.children , ( shard, key ) => shard.color ) ); | ||
getChart() { | ||
return this.chart; | ||
} | ||
} | ||
return Topology; | ||
|
||
setClusterName ( clusterName ) { | ||
this.clusterName = clusterName; | ||
} | ||
}]) | ||
.factory('DataHeatMap', ['Topology', '$http', 'chrome',function (Topology, $http, chrome) { | ||
class DataHeatMap extends Topology { | ||
|
||
constructor(container) { | ||
super(container); | ||
getDataHeatMap($http, chrome).then( (option) => this.chart.setOption( option ) ); | ||
} | ||
} | ||
return Topology; | ||
return DataHeatMap; | ||
|
||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import _ from 'lodash'; | ||
import echarts from 'plugins/topology/../node_modules/echarts/dist/echarts.min.js'; | ||
|
||
function getIndicesColors( indices ) { | ||
return _.map( indices, ( index ) => index.color ); | ||
} | ||
|
||
function getShardsColors( indices ) { | ||
return _.map( indices, ( index ) => _.map( index.children , ( shard, key ) => shard.color ) ); | ||
} | ||
|
||
function initChart(container) { | ||
return echarts.init(container); | ||
} | ||
|
||
function getDataHeatMap($http, chrome) { | ||
const formatUtil = echarts.format; | ||
|
||
return $http.get(chrome.addBasePath('/topology/data_heat_map')) | ||
.then( response => { | ||
return { | ||
tooltip: { | ||
formatter: function (info) { | ||
const value = info.value; | ||
const docsCount = info.data['docs.count']; | ||
const docsDeleted = info.data['docs.deleted']; | ||
const treePathInfo = info.treePathInfo; | ||
const treePath = []; | ||
|
||
for (var i = 1; i < treePathInfo.length; i++) { | ||
treePath.push(treePathInfo[i].name); | ||
} | ||
|
||
var scaleValue = function(value) { | ||
if ( value >= 1024 ) { | ||
return formatUtil.addCommas( value / 1000 ) + ' GB' | ||
} else if ( value >= 1024*1024 ) { | ||
return formatUtil.addCommas( value / (1024*1024) ) + ' TB'; | ||
} | ||
|
||
return formatUtil.addCommas(value) + ' MB'; | ||
} | ||
|
||
let docsStats = ['<div>Docs count: ' + formatUtil.addCommas(docsCount) + '</div>', | ||
'<div>Docs deleted: ' + formatUtil.addCommas(docsDeleted) + '</div>']; | ||
if ( typeof info.data.segments != 'undefined' ) { | ||
docsStats = ['<div>Docs count: ' + formatUtil.addCommas(info.data['docs']) + '</div>'] | ||
} | ||
|
||
return [ | ||
'<div class="tooltip-title">' + formatUtil.encodeHTML(treePath.join('/')) + '</div>', | ||
'<div>Disk Usage: ' + scaleValue(value)+ '</div>' | ||
].concat(docsStats).join(''); | ||
} | ||
}, | ||
series: [{ | ||
name: 'Index topology', | ||
type: 'treemap', | ||
data: response.data.treemap, | ||
visibleMin: null, | ||
leafDepth: 1, | ||
zoomToNodeRatio: 0.02*0.02, | ||
breadcrumb: { | ||
top: 1, | ||
itemStyle: { | ||
normal: { | ||
color: '#607D8B', | ||
borderWidth: 1, | ||
borderColor: '#90A4AE', | ||
textStyle: { | ||
fontSize: 14 | ||
} | ||
} | ||
} | ||
}, | ||
levels: [ | ||
{ | ||
color: getIndicesColors(response.data.treemap), | ||
itemStyle: { | ||
normal: { | ||
borderColor: '#2f99c1', | ||
borderWidth: 15, | ||
gapWidth: 15 | ||
} | ||
} | ||
}, | ||
{ | ||
color: getShardsColors(response.data.treemap), | ||
|
||
itemStyle: { | ||
normal: { | ||
borderColor: '#424242', | ||
borderWidth: 10, | ||
gapWidth: 10 | ||
} | ||
} | ||
}, | ||
{ | ||
|
||
itemStyle: { | ||
normal: { | ||
borderColor: '#212121', | ||
borderWidth: 10, | ||
gapWidth: 10 | ||
} | ||
} | ||
} | ||
] | ||
}] | ||
} | ||
}); | ||
} | ||
|
||
export { | ||
initChart, | ||
getDataHeatMap | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<div class="topology-container" flex layout="row" layout-align="center center"> | ||
<h1>{{topology.clusterName}}</h1> | ||
<h1>{{topology.description.cluster}}</h1> | ||
<div cluster-topology flex style="width: 100%; min-height: 250px; height: 650px" flex class="cluster-topology"></div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
import cat_indices from './cat_indices' | ||
import cat_shards from './cat_shards' | ||
import cat_segments from './cat_segments' | ||
import get_cluster_topology from './get_cluster_topology' | ||
import get_cluster_health from './get_cluster_health' | ||
import get_data_heat_map from './get_data_heat_map' | ||
|
||
export default function (server) { | ||
server = cat_indices(server); | ||
server = cat_shards(server); | ||
server = cat_segments(server); | ||
server = get_cluster_topology(server); | ||
server = get_cluster_health(server); | ||
server = get_data_heat_map(server); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.