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
Boxiang Sun
gitlab-ce
Commits
b076d034
Commit
b076d034
authored
Mar 21, 2017
by
Jose Ivan Vargas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hover lines are now synced up when hovering in any graph
Cleaned up some code
parent
df3c8345
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
67 deletions
+76
-67
app/assets/javascripts/dispatcher.js
app/assets/javascripts/dispatcher.js
+1
-0
app/assets/javascripts/monitoring/prometheus_graph.js
app/assets/javascripts/monitoring/prometheus_graph.js
+75
-67
No files found.
app/assets/javascripts/dispatcher.js
View file @
b076d034
...
@@ -43,6 +43,7 @@ import GroupsList from './groups_list';
...
@@ -43,6 +43,7 @@ import GroupsList from './groups_list';
import
ProjectsList
from
'
./projects_list
'
;
import
ProjectsList
from
'
./projects_list
'
;
import
MiniPipelineGraph
from
'
./mini_pipeline_graph_dropdown
'
;
import
MiniPipelineGraph
from
'
./mini_pipeline_graph_dropdown
'
;
import
BlobLinePermalinkUpdater
from
'
./blob/blob_line_permalink_updater
'
;
import
BlobLinePermalinkUpdater
from
'
./blob/blob_line_permalink_updater
'
;
import
PrometheusGraph
from
'
./monitoring/prometheus_graph
'
;
import
UserCallout
from
'
./user_callout
'
;
import
UserCallout
from
'
./user_callout
'
;
const
ShortcutsBlob
=
require
(
'
./shortcuts_blob
'
);
const
ShortcutsBlob
=
require
(
'
./shortcuts_blob
'
);
...
...
app/assets/javascripts/monitoring/prometheus_graph.js
View file @
b076d034
...
@@ -30,10 +30,10 @@ class PrometheusGraph {
...
@@ -30,10 +30,10 @@ class PrometheusGraph {
}
}
createGraph
()
{
createGraph
()
{
Object
.
keys
(
this
.
data
).
forEach
((
key
)
=>
{
Object
.
keys
(
this
.
graphSpecificProperties
).
forEach
((
key
)
=>
{
const
value
=
this
.
data
[
key
];
const
value
=
this
.
graphSpecificProperties
[
key
];
if
(
value
.
length
>
0
)
{
if
(
value
.
data
.
length
>
0
)
{
this
.
plotValues
(
value
,
key
);
this
.
plotValues
(
key
);
}
}
});
});
}
}
...
@@ -129,7 +129,7 @@ class PrometheusGraph {
...
@@ -129,7 +129,7 @@ class PrometheusGraph {
.
attr
(
'
class
'
,
'
prometheus-graph-overlay
'
)
.
attr
(
'
class
'
,
'
prometheus-graph-overlay
'
)
.
attr
(
'
width
'
,
this
.
width
)
.
attr
(
'
width
'
,
this
.
width
)
.
attr
(
'
height
'
,
this
.
height
)
.
attr
(
'
height
'
,
this
.
height
)
.
on
(
'
mousemove
'
,
this
.
handleMouseOverGraph
.
bind
(
this
,
x
,
y
,
chart
,
prometheusGraphContainer
,
key
));
.
on
(
'
mousemove
'
,
this
.
handleMouseOverGraph
.
bind
(
this
,
chart
,
prometheusGraphContainer
));
}
}
// The legends from the metric
// The legends from the metric
...
@@ -200,67 +200,73 @@ class PrometheusGraph {
...
@@ -200,67 +200,73 @@ class PrometheusGraph {
.
attr
(
'
y
'
,
(
this
.
originalHeight
/
2
)
-
25
);
.
attr
(
'
y
'
,
(
this
.
originalHeight
/
2
)
-
25
);
}
}
handleMouseOverGraph
(
x
,
y
,
chart
,
prometheusGraphContainer
,
key
)
{
handleMouseOverGraph
(
chart
,
prometheusGraphContainer
)
{
const
graphSpecifics
=
this
.
graphSpecificProperties
[
key
];
const
rectOverlay
=
document
.
querySelector
(
`
${
prometheusGraphContainer
}
.prometheus-graph-overlay`
);
const
rectOverlay
=
document
.
querySelector
(
`
${
prometheusGraphContainer
}
.prometheus-graph-overlay`
);
const
mouseCoordOverlay
=
d3
.
mouse
(
rectOverlay
)[
0
];
const
currentXCoordinate
=
d3
.
mouse
(
rectOverlay
)[
0
];
const
timeValueFromOverlay
=
x
.
invert
(
mouseCoordOverlay
);
const
timeValueIndex
=
bisectDate
(
graphSpecifics
.
data
,
timeValueFromOverlay
,
1
);
Object
.
keys
(
this
.
graphSpecificProperties
).
forEach
((
key
)
=>
{
const
d0
=
graphSpecifics
.
data
[
timeValueIndex
-
1
];
const
currentGraphProps
=
this
.
graphSpecificProperties
[
key
];
const
d1
=
graphSpecifics
.
data
[
timeValueIndex
];
const
timeValueOverlay
=
currentGraphProps
.
xScale
.
invert
(
currentXCoordinate
);
const
currentData
=
timeValueFromOverlay
-
d0
.
time
>
d1
.
time
-
timeValueFromOverlay
?
d1
:
d0
;
const
overlayIndex
=
bisectDate
(
currentGraphProps
.
data
,
timeValueOverlay
,
1
);
const
maxValueMetric
=
y
(
d3
.
max
(
graphSpecifics
.
data
.
map
(
metricValue
=>
metricValue
.
value
)));
const
d0
=
currentGraphProps
.
data
[
overlayIndex
-
1
];
const
currentTimeCoordinate
=
x
(
currentData
.
time
);
const
d1
=
currentGraphProps
.
data
[
overlayIndex
];
const
evalTime
=
timeValueOverlay
-
d0
.
time
>
d1
.
time
-
timeValueOverlay
;
// Remove the current selectors
const
currentData
=
evalTime
?
d1
:
d0
;
d3
.
selectAll
(
`
${
prometheusGraphContainer
}
.selected-metric-line`
).
remove
();
const
currentTimeCoordinate
=
currentGraphProps
.
xScale
(
currentData
.
time
);
d3
.
selectAll
(
`
${
prometheusGraphContainer
}
.circle-metric`
).
remove
();
const
currentPrometheusGraphContainer
=
`
${
prometheusGraphsContainer
}
[graph-type=
${
key
}
]`
;
d3
.
selectAll
(
`
${
prometheusGraphContainer
}
.rect-text-metric`
).
remove
();
const
maxValueFromData
=
d3
.
max
(
currentGraphProps
.
data
.
map
(
metricValue
=>
metricValue
.
value
));
d3
.
selectAll
(
`
${
prometheusGraphContainer
}
.text-metric`
).
remove
();
const
maxMetricValue
=
currentGraphProps
.
yScale
(
maxValueFromData
);
chart
.
append
(
'
line
'
)
// Clear up all the pieces of the flag
.
attr
(
'
class
'
,
'
selected-metric-line
'
)
d3
.
selectAll
(
`
${
currentPrometheusGraphContainer
}
.selected-metric-line`
).
remove
();
.
attr
({
d3
.
selectAll
(
`
${
currentPrometheusGraphContainer
}
.circle-metric`
).
remove
();
x1
:
currentTimeCoordinate
,
d3
.
selectAll
(
`
${
currentPrometheusGraphContainer
}
.rect-text-metric`
).
remove
();
y1
:
y
(
0
),
d3
.
selectAll
(
`
${
currentPrometheusGraphContainer
}
.text-metric`
).
remove
();
x2
:
currentTimeCoordinate
,
y2
:
maxValueMetric
,
const
currentChart
=
d3
.
select
(
currentPrometheusGraphContainer
).
select
(
'
g
'
);
});
currentChart
.
append
(
'
line
'
)
.
attr
(
'
class
'
,
'
selected-metric-line
'
)
chart
.
append
(
'
circle
'
)
.
attr
({
.
attr
(
'
class
'
,
'
circle-metric
'
)
x1
:
currentTimeCoordinate
,
.
attr
(
'
fill
'
,
graphSpecifics
.
line_color
)
y1
:
currentGraphProps
.
yScale
(
0
),
.
attr
(
'
cx
'
,
currentTimeCoordinate
)
x2
:
currentTimeCoordinate
,
.
attr
(
'
cy
'
,
y
(
currentData
.
value
))
y2
:
maxMetricValue
,
.
attr
(
'
r
'
,
this
.
commonGraphProperties
.
circle_radius_metric
);
});
// The little box with text
currentChart
.
append
(
'
circle
'
)
const
rectTextMetric
=
chart
.
append
(
'
g
'
)
.
attr
(
'
class
'
,
'
circle-metric
'
)
.
attr
(
'
class
'
,
'
rect-text-metric
'
)
.
attr
(
'
fill
'
,
currentGraphProps
.
line_color
)
.
attr
(
'
translate
'
,
`(
${
currentTimeCoordinate
}
,
${
y
(
currentData
.
value
)}
)`
);
.
attr
(
'
cx
'
,
currentTimeCoordinate
)
.
attr
(
'
cy
'
,
currentGraphProps
.
yScale
(
currentData
.
value
))
rectTextMetric
.
append
(
'
rect
'
)
.
attr
(
'
r
'
,
this
.
commonGraphProperties
.
circle_radius_metric
);
.
attr
(
'
class
'
,
'
rect-metric
'
)
.
attr
(
'
x
'
,
currentTimeCoordinate
+
10
)
// The little box with text
.
attr
(
'
y
'
,
maxValueMetric
)
const
rectTextMetric
=
currentChart
.
append
(
'
g
'
)
.
attr
(
'
width
'
,
this
.
commonGraphProperties
.
rect_text_width
)
.
attr
(
'
class
'
,
'
rect-text-metric
'
)
.
attr
(
'
height
'
,
this
.
commonGraphProperties
.
rect_text_height
);
.
attr
(
'
translate
'
,
`(
${
currentTimeCoordinate
}
,
${
currentGraphProps
.
yScale
(
currentData
.
value
)}
)`
);
rectTextMetric
.
append
(
'
text
'
)
rectTextMetric
.
append
(
'
rect
'
)
.
attr
(
'
class
'
,
'
text-metric
'
)
.
attr
(
'
class
'
,
'
rect-metric
'
)
.
attr
(
'
x
'
,
currentTimeCoordinate
+
35
)
.
attr
(
'
x
'
,
currentTimeCoordinate
+
10
)
.
attr
(
'
y
'
,
maxValueMetric
+
35
)
.
attr
(
'
y
'
,
maxMetricValue
)
.
text
(
timeFormat
(
currentData
.
time
));
.
attr
(
'
width
'
,
this
.
commonGraphProperties
.
rect_text_width
)
.
attr
(
'
height
'
,
this
.
commonGraphProperties
.
rect_text_height
);
rectTextMetric
.
append
(
'
text
'
)
.
attr
(
'
class
'
,
'
text-metric-date
'
)
rectTextMetric
.
append
(
'
text
'
)
.
attr
(
'
x
'
,
currentTimeCoordinate
+
15
)
.
attr
(
'
class
'
,
'
text-metric
'
)
.
attr
(
'
y
'
,
maxValueMetric
+
15
)
.
attr
(
'
x
'
,
currentTimeCoordinate
+
35
)
.
text
(
dayFormat
(
currentData
.
time
));
.
attr
(
'
y
'
,
maxMetricValue
+
35
)
.
text
(
timeFormat
(
currentData
.
time
));
// Update the text
d3
.
select
(
`
${
prometheusGraphContainer
}
.text-metric-usage`
)
rectTextMetric
.
append
(
'
text
'
)
.
attr
(
'
class
'
,
'
text-metric-date
'
)
.
attr
(
'
x
'
,
currentTimeCoordinate
+
15
)
.
attr
(
'
y
'
,
maxMetricValue
+
15
)
.
text
(
dayFormat
(
currentData
.
time
));
d3
.
select
(
`
${
currentPrometheusGraphContainer
}
.text-metric-usage`
)
.
text
(
currentData
.
value
.
substring
(
0
,
8
));
.
text
(
currentData
.
value
.
substring
(
0
,
8
));
});
}
}
configureGraph
()
{
configureGraph
()
{
...
@@ -270,12 +276,16 @@ class PrometheusGraph {
...
@@ -270,12 +276,16 @@ class PrometheusGraph {
line_color
:
'
#5b99f7
'
,
line_color
:
'
#5b99f7
'
,
graph_legend_title
:
'
CPU Usage (Cores)
'
,
graph_legend_title
:
'
CPU Usage (Cores)
'
,
data
:
[],
data
:
[],
xScale
:
{},
yScale
:
{},
},
},
memory_values
:
{
memory_values
:
{
area_fill_color
:
'
#fca326
'
,
area_fill_color
:
'
#fca326
'
,
line_color
:
'
#fc6d26
'
,
line_color
:
'
#fc6d26
'
,
graph_legend_title
:
'
Memory Usage (MB)
'
,
graph_legend_title
:
'
Memory Usage (MB)
'
,
data
:
[],
data
:
[],
xScale
:
{},
yScale
:
{},
},
},
};
};
...
@@ -325,17 +335,15 @@ class PrometheusGraph {
...
@@ -325,17 +335,15 @@ class PrometheusGraph {
}
}
transformData
(
metricsResponse
)
{
transformData
(
metricsResponse
)
{
const
metricTypes
=
{};
Object
.
keys
(
metricsResponse
.
metrics
).
forEach
((
key
)
=>
{
Object
.
keys
(
metricsResponse
.
metrics
).
forEach
((
key
)
=>
{
if
(
key
===
'
cpu_values
'
||
key
===
'
memory_values
'
)
{
if
(
key
===
'
cpu_values
'
||
key
===
'
memory_values
'
)
{
const
metricValues
=
(
metricsResponse
.
metrics
[
key
])[
0
];
const
metricValues
=
(
metricsResponse
.
metrics
[
key
])[
0
];
metricTypes
[
key
]
=
metricValues
.
values
.
map
(
metric
=>
({
this
.
graphSpecificProperties
[
key
].
data
=
metricValues
.
values
.
map
(
metric
=>
({
time
:
new
Date
(
metric
[
0
]
*
1000
),
time
:
new
Date
(
metric
[
0
]
*
1000
),
value
:
metric
[
1
],
value
:
metric
[
1
],
}));
}));
}
}
});
});
this
.
data
=
metricTypes
;
}
}
}
}
...
...
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