Skip to content

Commit f0a0096

Browse files
committed
2 parents 54a4d97 + 65c74a0 commit f0a0096

File tree

4 files changed

+73
-5
lines changed

4 files changed

+73
-5
lines changed

spring-boot-admin-server/src/main/webapp/public/scripts/controllers/controllers.js

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ angular.module('springBootAdmin')
6464
.controller('detailsMetricsCtrl', function ($scope, $stateParams, Application, ApplicationDetails) {
6565
$scope.memoryData = [];
6666
$scope.heapMemoryData = [];
67+
$scope.counterData = [];
68+
$scope.gaugeData = [];
6769

6870
$scope.application = Application.query({id: $stateParams.id}, function(application) {
6971
ApplicationDetails.getMetrics(application, function(application) {
@@ -77,6 +79,22 @@ angular.module('springBootAdmin')
7779
$scope.heapMemoryData = [{ label: 'Free Heap', value : application.metrics["heap.free"] },
7880
{ label: 'Used Heap', value : application.metrics["heap.used"] }];
7981

82+
83+
//*** Extract data for Counter-Chart and Gauge-Chart
84+
$scope.counterData = [ { key : "value", values: [] } ];
85+
$scope.gaugeData = [ { key : "value", values: [] } ];
86+
for (var metric in application.metrics) {
87+
var matchCounter = /counter\.(.+)/.exec(metric);
88+
if ( matchCounter !== null) {
89+
$scope.counterData[0].values.push({ label : matchCounter[1], value : application.metrics[metric] });
90+
}
91+
92+
var matchGauge = /gauge\.(.+)/.exec(metric);
93+
if ( matchGauge !== null) {
94+
$scope.gaugeData[0].values.push({ label : matchGauge[1], value : application.metrics[metric] });
95+
}
96+
}
97+
8098
});
8199
});
82100

@@ -93,13 +111,26 @@ angular.module('springBootAdmin')
93111
};
94112
}
95113

96-
var colorArray = ['#6db33f', '#a5b2b9', '#ebf1e7', '#34302d' ];
114+
var colorArray = ['#6db33f', '#a5b2b9', '#34302d' ];
97115
$scope.colorFunction = function() {
98116
return function(d, i) {
99117
return colorArray[i % colorArray.length];
100118
};
101119
}
102120

121+
$scope.intFormatFunction = function(){
122+
return function(d) {
123+
return d3.format('d')(d);
124+
};
125+
}
126+
127+
$scope.toolTipContentFunction = function(){
128+
return function(key, x, y, e, graph) {
129+
console.log(key, x, y, e, graph);
130+
return x + ': ' + y ;
131+
}
132+
}
133+
103134
})
104135
.controller('detailsEnvCtrl', function ($scope, $stateParams, Application, ApplicationDetails) {
105136
$scope.application = Application.query({id: $stateParams.id}, function(application) {

spring-boot-admin-server/src/main/webapp/public/styles/application.css

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ ul.download-links {
1414
margin-right: auto;
1515
}
1616

17+
.nvd3 text, div.nvtooltip {
18+
font-size: 14px;
19+
}
20+
1721
ul.chart-legend {
1822
list-style: none;
1923
}
@@ -31,9 +35,6 @@ li.chart-2:before {
3135
color: #a5b2b9;
3236
}
3337
li.chart-3:before {
34-
color: #ebf1e7;
35-
}
36-
li.chart-4:before {
3738
color: #34302d;
3839
}
3940
li.no-bullet:before {

spring-boot-admin-server/src/main/webapp/public/styles/main.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
}
1313

1414
.table tr.highlight > td {
15-
background-color: #6db33f !important;
15+
background-color: #a5b2b9 !important;
1616
font-weight: bold;
1717
}
1818

spring-boot-admin-server/src/main/webapp/public/views/apps/details/metrics.html

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,42 @@ <h1 style="text-align: center;">Heap Memory</h1>
4343
</tbody>
4444
</table>
4545

46+
<table class="table table-striped">
47+
<thead>
48+
<tr>
49+
<th>Metrics</th>
50+
</tr>
51+
</thead>
52+
<tbody>
53+
<tr>
54+
<td>
55+
<h1 style="text-align: center;">Counter</h1>
56+
<div class="center-block" style="width: 800px; height: 300px; position:relative;">
57+
<nvd3-discrete-bar-chart id="counterChart" nodata="not available"
58+
data="counterData" x="xFunction()" y="yFunction()"
59+
color="colorFunction()"
60+
tooltips="true" tooltipContent="toolTipContentFunction()"
61+
showYAxis="true" yAxisTickFormat="intFormatFunction()">
62+
</nvd3-discrete-bar-chart>
63+
</div>
64+
</td>
65+
</tr>
66+
<tr>
67+
<td>
68+
<h1 style="text-align: center;">Gauge</h1>
69+
<div class="center-block" style="width: 800px; height: 300px; position:relative;">
70+
<nvd3-discrete-bar-chart id="gaugesChart" nodata="not available"
71+
data="gaugeData" x="xFunction()" y="yFunction()"
72+
color="colorFunction()"
73+
tooltips="true" tooltipContent="toolTipContentFunction()"
74+
showYAxis="true" yAxisTickFormat="intFormatFunction()">
75+
</nvd3-discrete-bar-chart>
76+
</div>
77+
</td>
78+
</tr>
79+
</tbody>
80+
</table>
81+
4682
<table class="table table-striped">
4783
<col style="width:30%">
4884
<col style="width:auto">

0 commit comments

Comments
 (0)