Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
8c66ced7
Commit
8c66ced7
authored
Apr 12, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added deployment data to metrics graphs
Closes #26914
parent
5e2219db
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
126 additions
and
23 deletions
+126
-23
app/assets/javascripts/monitoring/deployments.js
app/assets/javascripts/monitoring/deployments.js
+104
-0
app/assets/javascripts/monitoring/prometheus_graph.js
app/assets/javascripts/monitoring/prometheus_graph.js
+17
-12
app/assets/stylesheets/pages/environments.scss
app/assets/stylesheets/pages/environments.scss
+5
-11
No files found.
app/assets/javascripts/monitoring/deployments.js
0 → 100644
View file @
8c66ced7
import
d3
from
'
d3
'
;
export
default
class
Deployments
{
constructor
(
width
)
{
this
.
width
=
width
;
this
.
timeFormat
=
d3
.
time
.
format
(
'
%b %d, %Y, %H:%M%p
'
);
}
init
(
chartData
)
{
this
.
chartData
=
chartData
;
this
.
x
=
d3
.
time
.
scale
().
range
([
0
,
this
.
width
]);
this
.
x
.
domain
(
d3
.
extent
(
this
.
chartData
,
d
=>
d
.
time
));
this
.
getData
();
}
getData
()
{
$
.
ajax
({
url
:
'
http://192.168.0.2:3000/root/hello-world/environments/21/deployments
'
,
dataType
:
'
JSON
'
,
})
.
done
((
data
)
=>
{
this
.
data
=
[];
data
.
deployments
.
forEach
((
deployment
)
=>
{
const
date
=
new
Date
(
deployment
.
created_at
);
if
(
this
.
x
(
date
)
>=
0
)
{
this
.
data
.
push
({
id
:
deployment
.
id
,
time
:
new
Date
(
deployment
.
created_at
),
sha
:
deployment
.
sha
,
});
}
});
this
.
plotData
();
});
}
plotData
()
{
const
charts
=
d3
.
selectAll
(
'
.prometheus-graph .graph-container
'
);
charts
.
each
((
d
,
i
)
=>
{
const
chart
=
d3
.
select
(
charts
[
0
][
i
]);
this
.
createLine
(
chart
);
this
.
createDeployInfoBox
(
chart
);
});
}
createLine
(
chart
)
{
chart
.
append
(
'
g
'
)
.
attr
(
'
class
'
,
'
deploy-info
'
)
.
selectAll
(
'
.deploy-info
'
)
.
data
(
this
.
data
)
.
enter
()
.
append
(
'
g
'
)
.
attr
(
'
class
'
,
d
=>
`deploy-info-
${
d
.
id
}
`
)
.
attr
(
'
transform
'
,
d
=>
`translate(
${
Math
.
floor
(
this
.
x
(
d
.
time
))
+
1
}
, -1)`
)
.
append
(
'
line
'
)
.
attr
(
'
class
'
,
'
deployment-line
'
)
.
attr
(
'
stroke
'
,
'
#000000
'
)
.
attr
(
'
stroke-width
'
,
'
2
'
)
.
attr
({
x1
:
0
,
x2
:
0
,
y1
:
0
,
y2
:
chart
.
node
().
getBoundingClientRect
().
height
-
22
,
});
}
createDeployInfoBox
(
chart
)
{
this
.
data
.
forEach
((
d
)
=>
{
const
group
=
chart
.
select
(
`.deploy-info-
${
d
.
id
}
`
)
.
append
(
'
svg
'
)
.
attr
(
'
class
'
,
'
rect-text-metric deploy-info-rect
'
)
.
attr
(
'
x
'
,
'
5
'
)
.
attr
(
'
y
'
,
'
0
'
)
.
attr
(
'
width
'
,
100
)
.
attr
(
'
height
'
,
35
);
group
.
append
(
'
rect
'
)
.
attr
(
'
class
'
,
'
rect-metric
'
)
.
attr
(
'
x
'
,
0
)
.
attr
(
'
y
'
,
0
)
.
attr
(
'
rx
'
,
3
)
.
attr
(
'
width
'
,
'
100%
'
)
.
attr
(
'
height
'
,
'
100%
'
)
const
text
=
group
.
append
(
'
text
'
)
.
attr
(
'
x
'
,
5
)
.
attr
(
'
y
'
,
'
50%
'
)
.
attr
(
'
style
'
,
'
dominant-baseline: middle;
'
)
.
text
((
d
)
=>
{
return
`
${
d
.
sha
.
slice
(
0
,
6
)}
-
${
this
.
timeFormat
(
d
.
time
)}
`
;
});
group
.
attr
(
'
width
'
,
Math
.
floor
(
text
.
node
().
getBoundingClientRect
().
width
)
+
10
);
});
}
}
app/assets/javascripts/monitoring/prometheus_graph.js
View file @
8c66ced7
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
import
d3
from
'
d3
'
;
import
d3
from
'
d3
'
;
import
statusCodes
from
'
~/lib/utils/http_status
'
;
import
statusCodes
from
'
~/lib/utils/http_status
'
;
import
Deployments
from
'
./deployments
'
;
import
'
../lib/utils/common_utils
'
;
import
'
../lib/utils/common_utils
'
;
import
'
../flash
'
;
import
'
../flash
'
;
...
@@ -25,6 +26,8 @@ class PrometheusGraph {
...
@@ -25,6 +26,8 @@ class PrometheusGraph {
this
.
width
=
parentContainerWidth
-
this
.
margin
.
left
-
this
.
margin
.
right
;
this
.
width
=
parentContainerWidth
-
this
.
margin
.
left
-
this
.
margin
.
right
;
this
.
height
=
400
-
this
.
margin
.
top
-
this
.
margin
.
bottom
;
this
.
height
=
400
-
this
.
margin
.
top
-
this
.
margin
.
bottom
;
this
.
backOffRequestCounter
=
0
;
this
.
backOffRequestCounter
=
0
;
this
.
deployments
=
new
Deployments
(
this
.
width
);
this
.
configureGraph
();
this
.
configureGraph
();
this
.
init
();
this
.
init
();
}
}
...
@@ -45,6 +48,7 @@ class PrometheusGraph {
...
@@ -45,6 +48,7 @@ class PrometheusGraph {
}
else
{
}
else
{
this
.
transformData
(
metricsResponse
);
this
.
transformData
(
metricsResponse
);
this
.
createGraph
();
this
.
createGraph
();
this
.
deployments
.
init
(
this
.
data
[
Object
.
keys
(
this
.
data
)[
0
]]);
}
}
});
});
}
}
...
@@ -64,6 +68,7 @@ class PrometheusGraph {
...
@@ -64,6 +68,7 @@ class PrometheusGraph {
.
attr
(
'
width
'
,
this
.
width
+
this
.
margin
.
left
+
this
.
margin
.
right
)
.
attr
(
'
width
'
,
this
.
width
+
this
.
margin
.
left
+
this
.
margin
.
right
)
.
attr
(
'
height
'
,
this
.
height
+
this
.
margin
.
bottom
+
this
.
margin
.
top
)
.
attr
(
'
height
'
,
this
.
height
+
this
.
margin
.
bottom
+
this
.
margin
.
top
)
.
append
(
'
g
'
)
.
append
(
'
g
'
)
.
attr
(
'
class
'
,
'
graph-container
'
)
.
attr
(
'
transform
'
,
`translate(
${
this
.
margin
.
left
}
,
${
this
.
margin
.
top
}
)`
);
.
attr
(
'
transform
'
,
`translate(
${
this
.
margin
.
left
}
,
${
this
.
margin
.
top
}
)`
);
const
axisLabelContainer
=
d3
.
select
(
prometheusGraphContainer
)
const
axisLabelContainer
=
d3
.
select
(
prometheusGraphContainer
)
...
@@ -204,14 +209,13 @@ class PrometheusGraph {
...
@@ -204,14 +209,13 @@ class PrometheusGraph {
const
d0
=
valuesToPlot
[
timeValueIndex
-
1
];
const
d0
=
valuesToPlot
[
timeValueIndex
-
1
];
const
d1
=
valuesToPlot
[
timeValueIndex
];
const
d1
=
valuesToPlot
[
timeValueIndex
];
const
currentData
=
timeValueFromOverlay
-
d0
.
time
>
d1
.
time
-
timeValueFromOverlay
?
d1
:
d0
;
const
currentData
=
timeValueFromOverlay
-
d0
.
time
>
d1
.
time
-
timeValueFromOverlay
?
d1
:
d0
;
const
maxValueMetric
=
y
(
d3
.
max
(
valuesToPlot
.
map
(
metricValue
=>
metricValue
.
value
)));
const
maxValueMetric
=
Math
.
floor
(
y
(
d3
.
max
(
valuesToPlot
.
map
(
metricValue
=>
metricValue
.
value
)
)));
const
currentTimeCoordinate
=
x
(
currentData
.
time
);
const
currentTimeCoordinate
=
Math
.
floor
(
x
(
currentData
.
time
)
);
const
graphSpecifics
=
this
.
graphSpecificProperties
[
key
];
const
graphSpecifics
=
this
.
graphSpecificProperties
[
key
];
// Remove the current selectors
// Remove the current selectors
d3
.
selectAll
(
`
${
prometheusGraphContainer
}
.selected-metric-line`
).
remove
();
d3
.
selectAll
(
`
${
prometheusGraphContainer
}
.selected-metric-line`
).
remove
();
d3
.
selectAll
(
`
${
prometheusGraphContainer
}
.circle-metric`
).
remove
();
d3
.
selectAll
(
`
${
prometheusGraphContainer
}
.circle-metric`
).
remove
();
d3
.
selectAll
(
`
${
prometheusGraphContainer
}
.rect-text-metric`
).
remove
();
d3
.
selectAll
(
`
${
prometheusGraphContainer
}
.rect-text-metric:not(.deploy-info-rect)`
).
remove
();
d3
.
selectAll
(
`
${
prometheusGraphContainer
}
.text-metric`
).
remove
();
chart
.
append
(
'
line
'
)
chart
.
append
(
'
line
'
)
.
attr
(
'
class
'
,
'
selected-metric-line
'
)
.
attr
(
'
class
'
,
'
selected-metric-line
'
)
...
@@ -230,27 +234,28 @@ class PrometheusGraph {
...
@@ -230,27 +234,28 @@ class PrometheusGraph {
.
attr
(
'
r
'
,
this
.
commonGraphProperties
.
circle_radius_metric
);
.
attr
(
'
r
'
,
this
.
commonGraphProperties
.
circle_radius_metric
);
// The little box with text
// The little box with text
const
rectTextMetric
=
chart
.
append
(
'
g
'
)
const
rectTextMetric
=
chart
.
append
(
'
sv
g
'
)
.
attr
(
'
class
'
,
'
rect-text-metric
'
)
.
attr
(
'
class
'
,
'
rect-text-metric
'
)
.
attr
(
'
translate
'
,
`(
${
currentTimeCoordinate
}
,
${
y
(
currentData
.
value
)}
)`
);
.
attr
(
'
x
'
,
currentTimeCoordinate
)
.
attr
(
'
y
'
,
-
1
);
rectTextMetric
.
append
(
'
rect
'
)
rectTextMetric
.
append
(
'
rect
'
)
.
attr
(
'
class
'
,
'
rect-metric
'
)
.
attr
(
'
class
'
,
'
rect-metric
'
)
.
attr
(
'
x
'
,
currentTimeCoordinate
+
10
)
.
attr
(
'
x
'
,
10
)
.
attr
(
'
y
'
,
maxValueMetric
)
.
attr
(
'
y
'
,
0
)
.
attr
(
'
width
'
,
this
.
commonGraphProperties
.
rect_text_width
)
.
attr
(
'
width
'
,
this
.
commonGraphProperties
.
rect_text_width
)
.
attr
(
'
height
'
,
this
.
commonGraphProperties
.
rect_text_height
);
.
attr
(
'
height
'
,
this
.
commonGraphProperties
.
rect_text_height
);
rectTextMetric
.
append
(
'
text
'
)
rectTextMetric
.
append
(
'
text
'
)
.
attr
(
'
class
'
,
'
text-metric
'
)
.
attr
(
'
class
'
,
'
text-metric
'
)
.
attr
(
'
x
'
,
currentTimeCoordinate
+
35
)
.
attr
(
'
x
'
,
35
)
.
attr
(
'
y
'
,
maxValueMetric
+
35
)
.
attr
(
'
y
'
,
35
)
.
text
(
timeFormat
(
currentData
.
time
));
.
text
(
timeFormat
(
currentData
.
time
));
rectTextMetric
.
append
(
'
text
'
)
rectTextMetric
.
append
(
'
text
'
)
.
attr
(
'
class
'
,
'
text-metric-date
'
)
.
attr
(
'
class
'
,
'
text-metric-date
'
)
.
attr
(
'
x
'
,
currentTimeCoordinate
+
15
)
.
attr
(
'
x
'
,
15
)
.
attr
(
'
y
'
,
maxValueMetric
+
15
)
.
attr
(
'
y
'
,
15
)
.
text
(
dayFormat
(
currentData
.
time
));
.
text
(
dayFormat
(
currentData
.
time
));
// Update the text
// Update the text
...
...
app/assets/stylesheets/pages/environments.scss
View file @
8c66ced7
...
@@ -157,7 +157,8 @@
...
@@ -157,7 +157,8 @@
.prometheus-graph
{
.prometheus-graph
{
text
{
text
{
fill
:
$stat-graph-axis-fill
;
fill
:
#525252
;
stroke-width
:
0
;
}
}
}
}
...
@@ -200,22 +201,15 @@
...
@@ -200,22 +201,15 @@
.rect-text-metric
{
.rect-text-metric
{
fill
:
$white-light
;
fill
:
$white-light
;
stroke-width
:
1
;
stroke-width
:
1
;
stroke
:
$black
;
stroke
:
#e1e1e1
;
}
}
.rect-axis-text
{
.rect-axis-text
{
fill
:
$white-light
;
fill
:
$white-light
;
}
}
.text-metric
,
.text-metric
{
.text-median-metric
,
font-weight
:
600
;
.text-metric-usage
,
.text-metric-date
{
fill
:
$black
;
}
.text-metric-date
{
font-weight
:
200
;
}
}
.selected-metric-line
{
.selected-metric-line
{
...
...
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