Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-boot-admin
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
spring-boot-admin
Commits
62107078
Commit
62107078
authored
Sep 29, 2014
by
Dennis Schulte
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5 from joshiste/master
Horizontal bar chart with logback-classic like abbreviated labels
parents
035949d1
57192fe1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
34 deletions
+99
-34
controllers.js
...src/main/webapp/public/scripts/controllers/controllers.js
+14
-22
services.js
...erver/src/main/webapp/public/scripts/services/services.js
+69
-0
metrics.html
...er/src/main/webapp/public/views/apps/details/metrics.html
+16
-12
No files found.
spring-boot-admin-server/src/main/webapp/public/scripts/controllers/controllers.js
View file @
62107078
...
@@ -61,7 +61,7 @@ angular.module('springBootAdmin')
...
@@ -61,7 +61,7 @@ angular.module('springBootAdmin')
ApplicationDetails
.
getInfo
(
application
);
ApplicationDetails
.
getInfo
(
application
);
});
});
})
})
.
controller
(
'detailsMetricsCtrl'
,
function
(
$scope
,
$stateParams
,
Application
,
ApplicationDetails
)
{
.
controller
(
'detailsMetricsCtrl'
,
function
(
$scope
,
$stateParams
,
Application
,
ApplicationDetails
,
Abbreviator
)
{
$scope
.
memoryData
=
[];
$scope
.
memoryData
=
[];
$scope
.
heapMemoryData
=
[];
$scope
.
heapMemoryData
=
[];
$scope
.
counterData
=
[];
$scope
.
counterData
=
[];
...
@@ -71,13 +71,13 @@ angular.module('springBootAdmin')
...
@@ -71,13 +71,13 @@ angular.module('springBootAdmin')
ApplicationDetails
.
getMetrics
(
application
,
function
(
application
)
{
ApplicationDetails
.
getMetrics
(
application
,
function
(
application
)
{
//*** Extract data for JVM-Memory-Chart
//*** Extract data for JVM-Memory-Chart
application
.
metrics
[
"mem.used"
]
=
application
.
metrics
[
"mem"
]
-
$scope
.
application
.
metrics
[
"mem.free"
];
application
.
metrics
[
"mem.used"
]
=
application
.
metrics
[
"mem"
]
-
$scope
.
application
.
metrics
[
"mem.free"
];
$scope
.
memoryData
=
[
{
label
:
'Free Memory'
,
value
:
application
.
metrics
[
"mem.free"
]
}
,
$scope
.
memoryData
=
[
[
'Free Memory'
,
application
.
metrics
[
"mem.free"
]]
,
{
label
:
'Used Memory'
,
value
:
application
.
metrics
[
"mem.used"
]
}
];
[
'Used Memory'
,
application
.
metrics
[
"mem.used"
]]
];
//*** Extract data for Heap-Memory-Chart
//*** Extract data for Heap-Memory-Chart
application
.
metrics
[
"heap.free"
]
=
application
.
metrics
[
"heap"
]
-
$scope
.
application
.
metrics
[
"heap.used"
];
application
.
metrics
[
"heap.free"
]
=
application
.
metrics
[
"heap"
]
-
$scope
.
application
.
metrics
[
"heap.used"
];
$scope
.
heapMemoryData
=
[
{
label
:
'Free Heap'
,
value
:
application
.
metrics
[
"heap.free"
]
}
,
$scope
.
heapMemoryData
=
[
[
'Free Heap'
,
application
.
metrics
[
"heap.free"
]]
,
{
label
:
'Used Heap'
,
value
:
application
.
metrics
[
"heap.used"
]
}
];
[
'Used Heap'
,
application
.
metrics
[
"heap.used"
]]
];
//*** Extract data for Counter-Chart and Gauge-Chart
//*** Extract data for Counter-Chart and Gauge-Chart
...
@@ -86,31 +86,18 @@ angular.module('springBootAdmin')
...
@@ -86,31 +86,18 @@ angular.module('springBootAdmin')
for
(
var
metric
in
application
.
metrics
)
{
for
(
var
metric
in
application
.
metrics
)
{
var
matchCounter
=
/counter
\.(
.+
)
/
.
exec
(
metric
);
var
matchCounter
=
/counter
\.(
.+
)
/
.
exec
(
metric
);
if
(
matchCounter
!==
null
)
{
if
(
matchCounter
!==
null
)
{
$scope
.
counterData
[
0
].
values
.
push
(
{
label
:
matchCounter
[
1
],
value
:
application
.
metrics
[
metric
]
}
);
$scope
.
counterData
[
0
].
values
.
push
(
[
matchCounter
[
1
],
application
.
metrics
[
metric
]
]
);
}
}
var
matchGauge
=
/gauge
\.(
.+
)
/
.
exec
(
metric
);
var
matchGauge
=
/gauge
\.(
.+
)
/
.
exec
(
metric
);
if
(
matchGauge
!==
null
)
{
if
(
matchGauge
!==
null
)
{
$scope
.
gaugeData
[
0
].
values
.
push
(
{
label
:
matchGauge
[
1
],
value
:
application
.
metrics
[
metric
]
}
);
$scope
.
gaugeData
[
0
].
values
.
push
(
[
matchGauge
[
1
],
application
.
metrics
[
metric
]
]
);
}
}
}
}
});
});
});
});
$scope
.
xFunction
=
function
(){
return
function
(
d
)
{
return
d
.
label
;
};
}
$scope
.
yFunction
=
function
(){
return
function
(
d
)
{
return
d
.
value
;
};
}
var
colorArray
=
[
'#6db33f'
,
'#a5b2b9'
,
'#34302d'
];
var
colorArray
=
[
'#6db33f'
,
'#a5b2b9'
,
'#34302d'
];
$scope
.
colorFunction
=
function
()
{
$scope
.
colorFunction
=
function
()
{
return
function
(
d
,
i
)
{
return
function
(
d
,
i
)
{
...
@@ -118,6 +105,12 @@ angular.module('springBootAdmin')
...
@@ -118,6 +105,12 @@ angular.module('springBootAdmin')
};
};
}
}
$scope
.
abbreviateFunction
=
function
(
targetLength
,
preserveLast
,
shortenThreshold
){
return
function
(
s
)
{
return
Abbreviator
.
abbreviate
(
s
,
targetLength
,
preserveLast
,
shortenThreshold
)
};
}
$scope
.
intFormatFunction
=
function
(){
$scope
.
intFormatFunction
=
function
(){
return
function
(
d
)
{
return
function
(
d
)
{
return
d3
.
format
(
'd'
)(
d
);
return
d3
.
format
(
'd'
)(
d
);
...
@@ -126,8 +119,7 @@ angular.module('springBootAdmin')
...
@@ -126,8 +119,7 @@ angular.module('springBootAdmin')
$scope
.
toolTipContentFunction
=
function
(){
$scope
.
toolTipContentFunction
=
function
(){
return
function
(
key
,
x
,
y
,
e
,
graph
)
{
return
function
(
key
,
x
,
y
,
e
,
graph
)
{
console
.
log
(
key
,
x
,
y
,
e
,
graph
);
return
e
.
point
[
0
]
+
': '
+
e
.
point
[
1
]
;
return
x
+
': '
+
y
;
}
}
}
}
...
...
spring-boot-admin-server/src/main/webapp/public/scripts/services/services.js
View file @
62107078
...
@@ -124,4 +124,73 @@ angular.module('springBootAdmin.services', ['ngResource'])
...
@@ -124,4 +124,73 @@ angular.module('springBootAdmin.services', ['ngResource'])
}
}
});
});
}
}
}])
.
service
(
'Abbreviator'
,
[
function
()
{
function
_computeDotIndexes
(
fqName
,
preserveLast
)
{
var
dotArray
=
[];
//iterate over String and find dots
var
lastIndex
=
-
1
;
do
{
lastIndex
=
fqName
.
indexOf
(
'.'
,
lastIndex
+
1
);
if
(
lastIndex
!==
-
1
)
{
dotArray
.
push
(
lastIndex
);
}
}
while
(
lastIndex
!==
-
1
)
// remove dots to preserve more than the last element
for
(
var
i
=
0
;
i
<
preserveLast
-
1
;
i
++
)
{
dotArray
.
pop
();
}
return
dotArray
;
}
function
_computeLengthArray
(
fqName
,
targetLength
,
dotArray
,
shortenThreshold
)
{
var
lengthArray
=
[];
var
toTrim
=
fqName
.
length
-
targetLength
;
for
(
var
i
=
0
;
i
<
dotArray
.
length
;
i
++
)
{
var
previousDotPosition
=
-
1
;
if
(
i
>
0
)
{
previousDotPosition
=
dotArray
[
i
-
1
];
}
var
len
=
dotArray
[
i
]
-
previousDotPosition
-
1
;
var
newLen
=
(
toTrim
>
0
&&
len
>
shortenThreshold
?
1
:
len
);
toTrim
-=
(
len
-
newLen
);
lengthArray
[
i
]
=
newLen
+
1
;
}
var
lastDotIndex
=
dotArray
.
length
-
1
;
lengthArray
[
dotArray
.
length
]
=
fqName
.
length
-
dotArray
[
lastDotIndex
];
return
lengthArray
;
}
this
.
abbreviate
=
function
(
fqName
,
targetLength
,
preserveLast
,
shortenThreshold
)
{
if
(
fqName
.
length
<
targetLength
)
{
return
fqName
;
}
var
dotIndexesArray
=
_computeDotIndexes
(
fqName
,
preserveLast
);
if
(
dotIndexesArray
.
length
===
0
)
{
return
fqName
;
}
var
lengthArray
=
_computeLengthArray
(
fqName
,
targetLength
,
dotIndexesArray
,
shortenThreshold
);
var
result
=
""
;
for
(
var
i
=
0
;
i
<=
dotIndexesArray
.
length
;
i
++
)
{
if
(
i
===
0
)
{
result
+=
fqName
.
substr
(
0
,
lengthArray
[
i
]
-
1
);
}
else
{
result
+=
fqName
.
substr
(
dotIndexesArray
[
i
-
1
],
lengthArray
[
i
]);
}
}
return
result
;
}
}]);
}]);
spring-boot-admin-server/src/main/webapp/public/views/apps/details/metrics.html
View file @
62107078
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
<h1
style=
"text-align: center;"
>
JVM Memory
</h1>
<h1
style=
"text-align: center;"
>
JVM Memory
</h1>
<div
class=
"center-block"
style=
"width: 400px; height: 200px;"
>
<div
class=
"center-block"
style=
"width: 400px; height: 200px;"
>
<nvd3-pie-chart
id=
"memoryChart"
nodata=
"not available"
<nvd3-pie-chart
id=
"memoryChart"
nodata=
"not available"
data=
"memoryData"
x=
"xFunction()"
y=
"yFunction()"
data=
"memoryData"
color=
"colorFunction()"
margin=
"{left:0,top:0,bottom:0,right:0}"
>
color=
"colorFunction()"
margin=
"{left:0,top:0,bottom:0,right:0}"
>
</nvd3-pie-chart>
</nvd3-pie-chart>
</div>
</div>
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
<h1
style=
"text-align: center;"
>
Heap Memory
</h1>
<h1
style=
"text-align: center;"
>
Heap Memory
</h1>
<div
class=
"center-block"
style=
"width: 400px; height: 200px;"
>
<div
class=
"center-block"
style=
"width: 400px; height: 200px;"
>
<nvd3-pie-chart
id=
"heapMemoryChart"
nodata=
"not available"
<nvd3-pie-chart
id=
"heapMemoryChart"
nodata=
"not available"
data=
"heapMemoryData"
x=
"xFunction()"
y=
"yFunction()"
data=
"heapMemoryData"
color=
"colorFunction()"
margin=
"{left:0,top:0,bottom:0,right:0}"
>
color=
"colorFunction()"
margin=
"{left:0,top:0,bottom:0,right:0}"
>
</nvd3-pie-chart>
</nvd3-pie-chart>
</div>
</div>
...
@@ -53,26 +53,30 @@
...
@@ -53,26 +53,30 @@
<tr>
<tr>
<td>
<td>
<h1
style=
"text-align: center;"
>
Counter
</h1>
<h1
style=
"text-align: center;"
>
Counter
</h1>
<div
class=
"center-block"
style=
"width: 800px; height:
300
px; position:relative;"
>
<div
class=
"center-block"
style=
"width: 800px; height:
{{ 50 + counterData[0].values.length * 15 }}
px; position:relative;"
>
<nvd3-
discrete-bar
-chart
id=
"counterChart"
nodata=
"not available"
<nvd3-
multi-bar-horizontal
-chart
id=
"counterChart"
nodata=
"not available"
data=
"counterData"
x=
"xFunction()"
y=
"yFunction()"
data=
"counterData"
color=
"colorFunction()"
color=
"colorFunction()"
tooltips=
"true"
tooltipContent=
"toolTipContentFunction()"
tooltips=
"true"
tooltipContent=
"toolTipContentFunction()"
showYAxis=
"true"
yAxisTickFormat=
"intFormatFunction()"
>
showYAxis=
"true"
yAxisTickFormat=
"intFormatFunction()"
</nvd3-discrete-bar-chart>
showXAxis=
"true"
xAxisTickFormat=
"abbreviateFunction(30, 1, 3)"
margin=
"{ top: 25, left: 250, right: 25, bottom: 50}"
>
</nvd3-multi-bar-horizontal-chart>
</div>
</div>
</td>
</td>
</tr>
</tr>
<tr>
<tr>
<td>
<td>
<h1
style=
"text-align: center;"
>
Gauge
</h1>
<h1
style=
"text-align: center;"
>
Gauge
</h1>
<div
class=
"center-block"
style=
"width: 800px; height:
300
px; position:relative;"
>
<div
class=
"center-block"
style=
"width: 800px; height:
{{ 50 + gaugeData[0].values.length * 15 }}
px; position:relative;"
>
<nvd3-
discrete-bar
-chart
id=
"gaugesChart"
nodata=
"not available"
<nvd3-
multi-bar-horizontal
-chart
id=
"gaugesChart"
nodata=
"not available"
data=
"gaugeData"
x=
"xFunction()"
y=
"yFunction()"
data=
"gaugeData"
color=
"colorFunction()"
color=
"colorFunction()"
tooltips=
"true"
tooltipContent=
"toolTipContentFunction()"
tooltips=
"true"
tooltipContent=
"toolTipContentFunction()"
showYAxis=
"true"
yAxisTickFormat=
"intFormatFunction()"
>
showYAxis=
"true"
yAxisTickFormat=
"intFormatFunction()"
</nvd3-discrete-bar-chart>
showXAxis=
"true"
xAxisTickFormat=
"abbreviateFunction(30, 1, 3)"
margin=
"{ top: 25, left: 250, right: 25, bottom: 50}"
>
</nvd3-multi-bar-horizontal-chart>
</div>
</div>
</td>
</td>
</tr>
</tr>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment