Filtering stats by release
Change-Id: I238a5596052542395dd09aec66d7934edcb4fdf1
This commit is contained in:
parent
d7b65ea6b3
commit
f8c6723b85
|
@ -250,4 +250,8 @@ svg text {
|
|||
|
||||
.nv-series text, .p0_title, .p1_title {
|
||||
font-size: 13px !important;
|
||||
}
|
||||
}
|
||||
|
||||
#release-filter {
|
||||
margin: 10px 0 0 13px;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
<!-- Start Base Layout -->
|
||||
<div class="base-box">
|
||||
<select id="release-filter"></select>
|
||||
|
||||
<!-- TOP BIG GRAPH -->
|
||||
<div class="container-fluid titul-graph-box">
|
||||
|
|
|
@ -13,14 +13,54 @@ function($, d3, D3pie, d3tip, nv, elasticsearch) {
|
|||
|
||||
var statuses = ['operational', 'error'];
|
||||
|
||||
var elasticSearchHost = function() {
|
||||
return {
|
||||
host: {
|
||||
protocol: $(location).attr('protocol'),
|
||||
host: $(location).attr('hostname')
|
||||
var releases = [
|
||||
{name: 'All', filter: ''},
|
||||
{name: '6.0 Technical Preview', filter: '6.0-techpreview'},
|
||||
{name: '6.0 GA', filter: '6.0'}
|
||||
];
|
||||
var currentRelease = releases[0].filter;
|
||||
|
||||
var releaseFilter = $('#release-filter');
|
||||
releases.forEach(function(release) {
|
||||
releaseFilter.append($('<option/>', {text: release.name, value: release.filter}));
|
||||
});
|
||||
releaseFilter.on('change', function(e) {
|
||||
var newRelease = $(e.currentTarget).val();
|
||||
currentRelease = newRelease;
|
||||
statsPage();
|
||||
});
|
||||
|
||||
var applyFilters = function(body) {
|
||||
var result = body;
|
||||
if (currentRelease) {
|
||||
result = {
|
||||
aggs: {
|
||||
releases: {
|
||||
filter: {
|
||||
terms: {
|
||||
'fuel_release.release': [currentRelease]
|
||||
}
|
||||
},
|
||||
aggs: body.aggs
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
var getRootData = function(resp) {
|
||||
return currentRelease ? resp.aggregations.releases : resp.aggregations;
|
||||
};
|
||||
|
||||
var elasticSearchHost = function() {
|
||||
return {
|
||||
host: {
|
||||
protocol: $(location).attr('protocol'),
|
||||
host: $(location).attr('hostname')
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var statsPage = function() {
|
||||
installationsCount();
|
||||
|
@ -33,15 +73,15 @@ function($, d3, D3pie, d3tip, nv, elasticsearch) {
|
|||
|
||||
var installationsCount = function() {
|
||||
var client = new elasticsearch.Client(elasticSearchHost());
|
||||
client.count({
|
||||
var request = {query: currentRelease ? {terms: {'fuel_release.release': [currentRelease]}} : {match_all: {}}};
|
||||
|
||||
client.count({
|
||||
index: 'fuel',
|
||||
type: 'structure',
|
||||
body: {
|
||||
query: {match_all: {}}
|
||||
}
|
||||
}).then(function(resp) {
|
||||
$('#installations-count').html(resp.count);
|
||||
});
|
||||
body: request
|
||||
}).then(function(resp) {
|
||||
$('#installations-count').html(resp.count);
|
||||
});
|
||||
};
|
||||
|
||||
var environmentsCount = function() {
|
||||
|
@ -49,23 +89,24 @@ function($, d3, D3pie, d3tip, nv, elasticsearch) {
|
|||
client.search({
|
||||
index: 'fuel',
|
||||
type: 'structure',
|
||||
body: {
|
||||
body: applyFilters({
|
||||
aggs: {
|
||||
clusters: {
|
||||
nested: {
|
||||
path: 'clusters'
|
||||
},
|
||||
aggs: {
|
||||
aggs: {
|
||||
statuses: {
|
||||
terms: {field: 'status'}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}).then(function(resp) {
|
||||
var rawData = resp.aggregations.clusters.statuses.buckets,
|
||||
total = resp.aggregations.clusters.doc_count,
|
||||
var rootData = getRootData(resp);
|
||||
var rawData = rootData.clusters.statuses.buckets,
|
||||
total = rootData.clusters.doc_count,
|
||||
colors = {
|
||||
error: '#FF7372',
|
||||
operational: '#51851A',
|
||||
|
@ -121,7 +162,7 @@ function($, d3, D3pie, d3tip, nv, elasticsearch) {
|
|||
client.search({
|
||||
index: 'fuel',
|
||||
size: 0,
|
||||
body: {
|
||||
body: applyFilters({
|
||||
aggs: {
|
||||
envs_distribution: {
|
||||
histogram: {
|
||||
|
@ -130,9 +171,10 @@ function($, d3, D3pie, d3tip, nv, elasticsearch) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}).then(function(resp) {
|
||||
var rawData = resp.aggregations.envs_distribution.buckets,
|
||||
var rootData = getRootData(resp);
|
||||
var rawData = rootData.envs_distribution.buckets,
|
||||
chartData = [];
|
||||
$.each(rawData, function(key, value) {
|
||||
chartData.push({label: value.key, value: value.doc_count});
|
||||
|
@ -192,7 +234,7 @@ function($, d3, D3pie, d3tip, nv, elasticsearch) {
|
|||
index: 'fuel',
|
||||
type: 'structure',
|
||||
size: 0,
|
||||
body: {
|
||||
body: applyFilters({
|
||||
aggs: {
|
||||
clusters: {
|
||||
nested: {
|
||||
|
@ -215,10 +257,11 @@ function($, d3, D3pie, d3tip, nv, elasticsearch) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}).then(function(resp) {
|
||||
var rawData = resp.aggregations.clusters.statuses.nodes_ranges.buckets,
|
||||
total = resp.aggregations.clusters.statuses.doc_count,
|
||||
var rootData = getRootData(resp);
|
||||
var rawData = rootData.clusters.statuses.nodes_ranges.buckets,
|
||||
total = rootData.clusters.statuses.doc_count,
|
||||
chartData = [];
|
||||
$('#count-nodes-distribution').html(total);
|
||||
$.each(rawData, function(key, value) {
|
||||
|
@ -282,7 +325,7 @@ function($, d3, D3pie, d3tip, nv, elasticsearch) {
|
|||
size: 0,
|
||||
index: 'fuel',
|
||||
type: 'structure',
|
||||
body: {
|
||||
body: applyFilters({
|
||||
aggs: {
|
||||
clusters: {
|
||||
nested: {
|
||||
|
@ -311,10 +354,11 @@ function($, d3, D3pie, d3tip, nv, elasticsearch) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}).then(function(resp) {
|
||||
var rawData = resp.aggregations.clusters.statuses.attributes.libvirt_types.buckets,
|
||||
total = resp.aggregations.clusters.statuses.attributes.doc_count,
|
||||
var rootData = getRootData(resp);
|
||||
var rawData = rootData.clusters.statuses.attributes.libvirt_types.buckets,
|
||||
total = rootData.clusters.statuses.attributes.doc_count,
|
||||
totalСounted = 0,
|
||||
chartData = [];
|
||||
$.each(rawData, function(key, value) {
|
||||
|
@ -384,7 +428,7 @@ function($, d3, D3pie, d3tip, nv, elasticsearch) {
|
|||
size: 0,
|
||||
index: 'fuel',
|
||||
type: 'structure',
|
||||
body: {
|
||||
body: applyFilters({
|
||||
aggs: {
|
||||
clusters: {
|
||||
nested: {
|
||||
|
@ -414,10 +458,11 @@ function($, d3, D3pie, d3tip, nv, elasticsearch) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}).then(function(resp) {
|
||||
var rawData = resp.aggregations.clusters.statuses.release.oses.buckets,
|
||||
total = resp.aggregations.clusters.statuses.doc_count,
|
||||
var rootData = getRootData(resp);
|
||||
var rawData = rootData.clusters.statuses.release.oses.buckets,
|
||||
total = rootData.clusters.statuses.doc_count,
|
||||
chartData = [];
|
||||
$('#count-distribution-of-oses').html(total);
|
||||
$.each(rawData, function(key, value) {
|
||||
|
|
|
@ -70,10 +70,21 @@ class Reports(ElasticTest):
|
|||
|
||||
def test_installations_number(self):
|
||||
installations_num = 150
|
||||
self.generate_data(installations_num=installations_num)
|
||||
installations = self.generate_data(installations_num=installations_num)
|
||||
release = "6.0-ga"
|
||||
query = {
|
||||
"query": {
|
||||
"terms": {
|
||||
"fuel_release.release": [release]
|
||||
}
|
||||
}
|
||||
}
|
||||
resp = self.es.count(index=config.INDEX_FUEL,
|
||||
doc_type=config.DOC_TYPE_STRUCTURE)
|
||||
self.assertEquals(installations_num, resp['count'])
|
||||
doc_type=config.DOC_TYPE_STRUCTURE,
|
||||
body=query)
|
||||
inst_count = len(filter(
|
||||
lambda x: x['fuel_release']['release'] == release, installations))
|
||||
self.assertEquals(inst_count, resp['count'])
|
||||
|
||||
def test_filtration(self):
|
||||
installations_num = 100
|
||||
|
|
Loading…
Reference in New Issue