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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
faf5363e
Commit
faf5363e
authored
Jul 28, 2017
by
Jose Ivan Vargas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored the monitoring_column component to process all of the time series
parent
4ea9c9b6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
45 deletions
+77
-45
app/assets/javascripts/monitoring/components/graph.vue
app/assets/javascripts/monitoring/components/graph.vue
+77
-45
No files found.
app/assets/javascripts/monitoring/components/graph.vue
View file @
faf5363e
...
@@ -3,10 +3,10 @@
...
@@ -3,10 +3,10 @@
import
GraphLegend
from
'
./graph/legend.vue
'
;
import
GraphLegend
from
'
./graph/legend.vue
'
;
import
GraphFlag
from
'
./graph/flag.vue
'
;
import
GraphFlag
from
'
./graph/flag.vue
'
;
import
GraphDeployment
from
'
./graph/deployment.vue
'
;
import
GraphDeployment
from
'
./graph/deployment.vue
'
;
import
monitoringPaths
from
'
./monitoring_paths.vue
'
;
import
MonitoringMixin
from
'
../mixins/monitoring_mixins
'
;
import
MonitoringMixin
from
'
../mixins/monitoring_mixins
'
;
import
eventHub
from
'
../event_hub
'
;
import
eventHub
from
'
../event_hub
'
;
import
measurements
from
'
../utils/measurements
'
;
import
measurements
from
'
../utils/measurements
'
;
import
{
formatRelevantDigits
}
from
'
../../lib/utils/number_utils
'
;
import
{
timeScaleFormat
}
from
'
../utils/date_time_formatters
'
;
import
{
timeScaleFormat
}
from
'
../utils/date_time_formatters
'
;
import
bp
from
'
../../breakpoints
'
;
import
bp
from
'
../../breakpoints
'
;
...
@@ -39,36 +39,40 @@
...
@@ -39,36 +39,40 @@
graphHeight
:
450
,
graphHeight
:
450
,
graphWidth
:
600
,
graphWidth
:
600
,
graphHeightOffset
:
120
,
graphHeightOffset
:
120
,
xScale
:
{},
yScale
:
{},
margin
:
{},
margin
:
{},
data
:
[]
,
breakpointHandler
:
Breakpoints
.
get
()
,
unitOfDisplay
:
''
,
unitOfDisplay
:
''
,
areaColorRgb
:
'
#8fbce8
'
,
areaColorRgb
:
'
#8fbce8
'
,
lineColorRgb
:
'
#1f78d1
'
,
lineColorRgb
:
'
#1f78d1
'
,
yAxisLabel
:
''
,
yAxisLabel
:
''
,
legendTitle
:
''
,
legendTitle
:
''
,
reducedDeploymentData
:
[],
reducedDeploymentData
:
[],
area
:
''
,
line
:
''
,
measurements
:
measurements
.
large
,
measurements
:
measurements
.
large
,
currentData
:
{
currentData
:
{
time
:
new
Date
(),
time
:
new
Date
(),
value
:
0
,
value
:
0
,
},
},
current
YCoordinate
:
0
,
current
DataIndex
:
0
,
currentXCoordinate
:
0
,
currentXCoordinate
:
0
,
currentFlagPosition
:
0
,
currentFlagPosition
:
0
,
metricUsage
:
''
,
metricUsage
:
''
,
showFlag
:
false
,
showFlag
:
false
,
showDeployInfo
:
true
,
showDeployInfo
:
true
,
timeSeries
:
[],
};
};
},
},
components
:
{
components
:
{
<<<<<<<
HEAD
:
app
/
assets
/
javascripts
/
monitoring
/
components
/
graph
.
vue
GraphLegend
,
GraphLegend
,
GraphFlag
,
GraphFlag
,
GraphDeployment
,
GraphDeployment
,
=======
monitoringLegends
,
monitoringFlag
,
monitoringDeployment
,
monitoringPaths
,
>>>>>>>
Refactored
the
monitoring_column
component
to
process
all
of
the
time
series
:
app
/
assets
/
javascripts
/
monitoring
/
components
/
monitoring_column
.
vue
},
},
computed
:
{
computed
:
{
...
@@ -104,17 +108,14 @@
...
@@ -104,17 +108,14 @@
this
.
margin
=
measurements
.
small
.
margin
;
this
.
margin
=
measurements
.
small
.
margin
;
this
.
measurements
=
measurements
.
small
;
this
.
measurements
=
measurements
.
small
;
}
}
this
.
data
=
query
.
result
[
0
].
values
;
this
.
unitOfDisplay
=
query
.
unit
||
''
;
this
.
unitOfDisplay
=
query
.
unit
||
''
;
this
.
yAxisLabel
=
this
.
graphData
.
y_label
||
'
Values
'
;
this
.
yAxisLabel
=
this
.
graphData
.
y_label
||
'
Values
'
;
this
.
legendTitle
=
query
.
label
||
'
Average
'
;
this
.
legendTitle
=
query
.
label
||
'
Average
'
;
this
.
graphWidth
=
this
.
$refs
.
baseSvg
.
clientWidth
-
this
.
graphWidth
=
this
.
$refs
.
baseSvg
.
clientWidth
-
this
.
margin
.
left
-
this
.
margin
.
right
;
this
.
margin
.
left
-
this
.
margin
.
right
;
this
.
graphHeight
=
this
.
graphHeight
-
this
.
margin
.
top
-
this
.
margin
.
bottom
;
this
.
graphHeight
=
this
.
graphHeight
-
this
.
margin
.
top
-
this
.
margin
.
bottom
;
if
(
this
.
data
!==
undefined
)
{
this
.
renderAxesPaths
();
this
.
renderAxesPaths
();
this
.
formatDeployments
();
this
.
formatDeployments
();
}
},
},
handleMouseOverGraph
(
e
)
{
handleMouseOverGraph
(
e
)
{
...
@@ -123,16 +124,17 @@
...
@@ -123,16 +124,17 @@
point
.
y
=
e
.
clientY
;
point
.
y
=
e
.
clientY
;
point
=
point
.
matrixTransform
(
this
.
$refs
.
graphData
.
getScreenCTM
().
inverse
());
point
=
point
.
matrixTransform
(
this
.
$refs
.
graphData
.
getScreenCTM
().
inverse
());
point
.
x
=
point
.
x
+=
7
;
point
.
x
=
point
.
x
+=
7
;
const
timeValueOverlay
=
this
.
xScale
.
invert
(
point
.
x
);
const
firstTimeSeries
=
this
.
timeSeries
[
0
];
const
overlayIndex
=
bisectDate
(
this
.
data
,
timeValueOverlay
,
1
);
const
timeValueOverlay
=
firstTimeSeries
.
timeSeriesScaleX
.
invert
(
point
.
x
);
const
d0
=
this
.
data
[
overlayIndex
-
1
];
const
overlayIndex
=
bisectDate
(
firstTimeSeries
.
values
,
timeValueOverlay
,
1
);
const
d1
=
this
.
data
[
overlayIndex
];
const
d0
=
firstTimeSeries
.
values
[
overlayIndex
-
1
];
const
d1
=
firstTimeSeries
.
values
[
overlayIndex
];
if
(
d0
===
undefined
||
d1
===
undefined
)
return
;
if
(
d0
===
undefined
||
d1
===
undefined
)
return
;
const
evalTime
=
timeValueOverlay
-
d0
[
0
]
>
d1
[
0
]
-
timeValueOverlay
;
const
evalTime
=
timeValueOverlay
-
d0
[
0
]
>
d1
[
0
]
-
timeValueOverlay
;
this
.
currentData
=
evalTime
?
d1
:
d0
;
this
.
currentData
=
evalTime
?
d1
:
d0
;
this
.
currentXCoordinate
=
Math
.
floor
(
this
.
xScale
(
this
.
currentData
.
time
));
this
.
currentDataIndex
=
evalTime
?
overlayIndex
:
(
overlayIndex
-
1
);
this
.
currentXCoordinate
=
Math
.
floor
(
firstTimeSeries
.
timeSeriesScaleX
(
this
.
currentData
.
time
));
const
currentDeployXPos
=
this
.
mouseOverDeployInfo
(
point
.
x
);
const
currentDeployXPos
=
this
.
mouseOverDeployInfo
(
point
.
x
);
this
.
currentYCoordinate
=
this
.
yScale
(
this
.
currentData
.
value
);
if
(
this
.
currentXCoordinate
>
(
this
.
graphWidth
-
200
))
{
if
(
this
.
currentXCoordinate
>
(
this
.
graphWidth
-
200
))
{
this
.
currentFlagPosition
=
this
.
currentXCoordinate
-
103
;
this
.
currentFlagPosition
=
this
.
currentXCoordinate
-
103
;
...
@@ -145,17 +147,45 @@
...
@@ -145,17 +147,45 @@
}
else
{
}
else
{
this
.
showFlag
=
true
;
this
.
showFlag
=
true
;
}
}
this
.
metricUsage
=
`
${
formatRelevantDigits
(
this
.
currentData
.
value
)}
${
this
.
unitOfDisplay
}
`
;
},
},
renderAxesPaths
()
{
renderAxesPaths
()
{
this
.
timeSeries
=
this
.
columnData
.
queries
[
0
].
result
.
map
((
timeSeries
)
=>
{
const
timeSeriesScaleX
=
d3
.
time
.
scale
()
.
range
([
0
,
this
.
graphWidth
-
70
]);
const
timeSeriesScaleY
=
d3
.
scale
.
linear
()
.
range
([
this
.
graphHeight
-
this
.
graphHeightOffset
,
0
]);
timeSeriesScaleX
.
domain
(
d3
.
extent
(
timeSeries
.
values
,
d
=>
d
.
time
));
timeSeriesScaleY
.
domain
([
0
,
d3
.
max
(
timeSeries
.
values
.
map
(
d
=>
d
.
value
))]);
const
lineFunction
=
d3
.
svg
.
line
()
.
x
(
d
=>
timeSeriesScaleX
(
d
.
time
))
.
y
(
d
=>
timeSeriesScaleY
(
d
.
value
));
const
areaFunction
=
d3
.
svg
.
area
()
.
x
(
d
=>
timeSeriesScaleX
(
d
.
time
))
.
y0
(
this
.
graphHeight
-
this
.
graphHeightOffset
)
.
y1
(
d
=>
timeSeriesScaleY
(
d
.
value
))
.
interpolate
(
'
linear
'
);
return
{
linePath
:
lineFunction
(
timeSeries
.
values
),
areaPath
:
areaFunction
(
timeSeries
.
values
),
timeSeriesScaleX
,
timeSeriesScaleY
,
values
:
timeSeries
.
values
,
};
});
const
axisXScale
=
d3
.
time
.
scale
()
const
axisXScale
=
d3
.
time
.
scale
()
.
range
([
0
,
this
.
graphWidth
]);
.
range
([
0
,
this
.
graphWidth
]);
this
.
y
Scale
=
d3
.
scale
.
linear
()
const
axisY
Scale
=
d3
.
scale
.
linear
()
.
range
([
this
.
graphHeight
-
this
.
graphHeightOffset
,
0
]);
.
range
([
this
.
graphHeight
-
this
.
graphHeightOffset
,
0
]);
axisXScale
.
domain
(
d3
.
extent
(
this
.
data
,
d
=>
d
.
time
));
this
.
yScale
.
domain
([
0
,
d3
.
max
(
this
.
data
.
map
(
d
=>
d
.
value
))]);
axisXScale
.
domain
(
d3
.
extent
(
this
.
timeSeries
[
0
].
values
,
d
=>
d
.
time
));
axisYScale
.
domain
([
0
,
d3
.
max
(
this
.
timeSeries
[
0
].
values
.
map
(
d
=>
d
.
value
))]);
const
xAxis
=
d3
.
svg
.
axis
()
const
xAxis
=
d3
.
svg
.
axis
()
.
scale
(
axisXScale
)
.
scale
(
axisXScale
)
...
@@ -164,7 +194,7 @@
...
@@ -164,7 +194,7 @@
.
orient
(
'
bottom
'
);
.
orient
(
'
bottom
'
);
const
yAxis
=
d3
.
svg
.
axis
()
const
yAxis
=
d3
.
svg
.
axis
()
.
scale
(
this
.
y
Scale
)
.
scale
(
axisY
Scale
)
.
ticks
(
measurements
.
yTicks
)
.
ticks
(
measurements
.
yTicks
)
.
orient
(
'
left
'
);
.
orient
(
'
left
'
);
...
@@ -180,25 +210,6 @@
...
@@ -180,25 +210,6 @@
.
attr
(
'
class
'
,
'
axis-tick
'
);
.
attr
(
'
class
'
,
'
axis-tick
'
);
}
// Avoid adding the class to the first tick, to prevent coloring
}
// Avoid adding the class to the first tick, to prevent coloring
});
// This will select all of the ticks once they're rendered
});
// This will select all of the ticks once they're rendered
this
.
xScale
=
d3
.
time
.
scale
()
.
range
([
0
,
this
.
graphWidth
-
70
]);
this
.
xScale
.
domain
(
d3
.
extent
(
this
.
data
,
d
=>
d
.
time
));
const
areaFunction
=
d3
.
svg
.
area
()
.
x
(
d
=>
this
.
xScale
(
d
.
time
))
.
y0
(
this
.
graphHeight
-
this
.
graphHeightOffset
)
.
y1
(
d
=>
this
.
yScale
(
d
.
value
))
.
interpolate
(
'
linear
'
);
const
lineFunction
=
d3
.
svg
.
line
()
.
x
(
d
=>
this
.
xScale
(
d
.
time
))
.
y
(
d
=>
this
.
yScale
(
d
.
value
));
this
.
line
=
lineFunction
(
this
.
data
);
this
.
area
=
areaFunction
(
this
.
data
);
},
},
},
},
...
@@ -248,12 +259,15 @@
...
@@ -248,12 +259,15 @@
:area-color-rgb=
"areaColorRgb"
:area-color-rgb=
"areaColorRgb"
:legend-title=
"legendTitle"
:legend-title=
"legendTitle"
:y-axis-label=
"yAxisLabel"
:y-axis-label=
"yAxisLabel"
:metric-usage=
"metricUsage"
:time-series=
"timeSeries"
:unit-of-display=
"unitOfDisplay"
:current-data-index=
"currentDataIndex"
/>
/>
<svg
<svg
class=
"graph-data"
class=
"graph-data"
:viewBox=
"innerViewBox"
:viewBox=
"innerViewBox"
ref=
"graphData"
>
ref=
"graphData"
>
<<<<<<<
HEAD:app
/
assets
/
javascripts
/
monitoring
/
components
/
graph
.
vue
<path
<path
class=
"metric-area"
class=
"metric-area"
:d=
"area"
:d=
"area"
...
@@ -269,6 +283,25 @@
...
@@ -269,6 +283,25 @@
transform=
"translate(-5, 20)"
>
transform=
"translate(-5, 20)"
>
</path>
</path>
<graph-deployment
<graph-deployment
=======
<monitoring-paths
v-for=
"(path, index) in timeSeries"
:key=
"index"
:generated-line-path=
"path.linePath"
:generated-area-path=
"path.areaPath"
:line-color=
"lineColorRgb"
:area-color=
"areaColorRgb"
/>
<rect
class=
"prometheus-graph-overlay"
:width=
"(graphWidth - 70)"
:height=
"(graphHeight - 100)"
transform=
"translate(-5, 20)"
ref=
"graphOverlay"
@
mousemove=
"handleMouseOverGraph($event)"
>
</rect>
<monitoring-deployment
>
>>>>>> Refactored the monitoring_column component to process all of the time series:app/assets/javascripts/monitoring/components/monitoring_column.vue
:show-deploy-info="showDeployInfo"
:show-deploy-info="showDeployInfo"
:deployment-data="reducedDeploymentData"
:deployment-data="reducedDeploymentData"
:graph-height="graphHeight"
:graph-height="graphHeight"
...
@@ -277,7 +310,6 @@
...
@@ -277,7 +310,6 @@
<graph-flag
<graph-flag
v-if=
"showFlag"
v-if=
"showFlag"
:current-x-coordinate=
"currentXCoordinate"
:current-x-coordinate=
"currentXCoordinate"
:current-y-coordinate=
"currentYCoordinate"
:current-data=
"currentData"
:current-data=
"currentData"
:current-flag-position=
"currentFlagPosition"
:current-flag-position=
"currentFlagPosition"
:graph-height=
"graphHeight"
:graph-height=
"graphHeight"
...
...
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