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
93ba3fdd
Commit
93ba3fdd
authored
Sep 05, 2017
by
Jose Ivan Vargas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small fixes to code and specs
parent
75b8f64a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
41 deletions
+25
-41
app/assets/javascripts/monitoring/utils/multiple_time_series.js
...sets/javascripts/monitoring/utils/multiple_time_series.js
+14
-20
config/prometheus/additional_metrics.yml
config/prometheus/additional_metrics.yml
+0
-17
spec/javascripts/monitoring/graph/legend_spec.js
spec/javascripts/monitoring/graph/legend_spec.js
+4
-3
spec/javascripts/monitoring/mock_data.js
spec/javascripts/monitoring/mock_data.js
+7
-1
No files found.
app/assets/javascripts/monitoring/utils/multiple_time_series.js
View file @
93ba3fdd
...
@@ -2,8 +2,8 @@ import d3 from 'd3';
...
@@ -2,8 +2,8 @@ import d3 from 'd3';
import
_
from
'
underscore
'
;
import
_
from
'
underscore
'
;
function
pickColorFromNameNumber
(
colorName
,
colorNumber
)
{
function
pickColorFromNameNumber
(
colorName
,
colorNumber
)
{
let
lineColor
=
'
#1f78d1
'
;
let
lineColor
=
''
;
let
areaColor
=
'
#8fbce8
'
;
let
areaColor
=
''
;
const
color
=
colorName
!=
null
?
colorName
:
colorNumber
;
const
color
=
colorName
!=
null
?
colorName
:
colorNumber
;
switch
(
color
)
{
switch
(
color
)
{
case
'
blue
'
:
case
'
blue
'
:
...
@@ -55,13 +55,9 @@ export default function createTimeSeries(queryData, graphWidth, graphHeight, gra
...
@@ -55,13 +55,9 @@ export default function createTimeSeries(queryData, graphWidth, graphHeight, gra
const
maxValueFromSeries
=
_
.
max
(
maxValues
,
val
=>
val
.
maxValue
);
const
maxValueFromSeries
=
_
.
max
(
maxValues
,
val
=>
val
.
maxValue
);
let
timeSeriesNumber
=
1
;
let
timeSeriesNumber
=
1
;
let
lineColor
=
'
#1f78d1
'
;
let
areaColor
=
'
#8fbce8
'
;
const
lineColors
=
[
'
#1f78d1
'
,
'
#fc9403
'
,
'
#db3b21
'
,
'
#1aaa55
'
,
'
#6666c4
'
];
const
areaColors
=
[
'
#8fbce8
'
,
'
#feca81
'
,
'
#ed9d90
'
,
'
#8dd5aa
'
,
'
#d1d1f0
'
];
return
queryData
.
result
.
map
((
timeSeries
,
index
)
=>
{
return
queryData
.
result
.
map
((
timeSeries
,
index
)
=>
{
let
metricTag
=
'
series
'
;
let
metricTag
=
''
;
let
pathColors
=
null
;
let
pathColors
=
null
;
const
timeSeriesScaleX
=
d3
.
time
.
scale
()
const
timeSeriesScaleX
=
d3
.
time
.
scale
()
.
range
([
0
,
graphWidth
-
70
]);
.
range
([
0
,
graphWidth
-
70
]);
...
@@ -84,29 +80,27 @@ export default function createTimeSeries(queryData, graphWidth, graphHeight, gra
...
@@ -84,29 +80,27 @@ export default function createTimeSeries(queryData, graphWidth, graphHeight, gra
.
y0
(
graphHeight
-
graphHeightOffset
)
.
y0
(
graphHeight
-
graphHeightOffset
)
.
y1
(
d
=>
timeSeriesScaleY
(
d
.
value
));
.
y1
(
d
=>
timeSeriesScaleY
(
d
.
value
));
lineColor
=
lineColors
[
timeSeriesNumber
-
1
];
areaColor
=
areaColors
[
timeSeriesNumber
-
1
];
if
(
queryData
.
series
!=
null
)
{
if
(
queryData
.
series
!=
null
)
{
const
seriesCustomizationData
=
queryData
.
series
[
index
];
const
seriesCustomizationData
=
queryData
.
series
[
index
];
metricTag
=
timeSeries
.
metric
[
Object
.
keys
(
timeSeries
.
metric
)[
0
]]
||
''
;
const
timeSeriesMetricLabel
=
timeSeries
.
metric
[
Object
.
keys
(
timeSeries
.
metric
)[
0
]]
;
if
(
seriesCustomizationData
!=
null
)
{
if
(
seriesCustomizationData
!=
null
)
{
if
(
metricTag
=
seriesCustomizationData
.
value
||
timeSeriesMetricLabel
;
seriesCustomizationData
.
value
===
metricTag
&&
if
(
seriesCustomizationData
.
color
!=
null
)
{
seriesCustomizationData
.
color
!=
null
)
{
pathColors
=
pickColorFromNameNumber
(
seriesCustomizationData
.
color
.
toLowerCase
(),
null
);
pathColors
=
pickColorFromNameNumber
(
seriesCustomizationData
.
color
.
toLowerCase
(),
null
);
}
}
}
else
{
metricTag
=
timeSeriesMetricLabel
||
`series
${
timeSeriesNumber
}
`
;
}
}
}
}
if
(
pathColors
==
null
)
{
if
(
pathColors
==
null
)
{
pathColors
=
pickColorFromNameNumber
(
null
,
timeSeriesNumber
);
pathColors
=
pickColorFromNameNumber
(
null
,
timeSeriesNumber
);
if
(
timeSeriesNumber
<=
5
)
{
}
timeSeriesNumber
=
timeSeriesNumber
+=
1
;
}
else
{
if
(
timeSeriesNumber
<=
5
)
{
timeSeriesNumber
=
1
;
timeSeriesNumber
=
timeSeriesNumber
+=
1
;
}
}
else
{
timeSeriesNumber
=
1
;
}
}
return
{
return
{
...
...
config/prometheus/additional_metrics.yml
View file @
93ba3fdd
...
@@ -131,20 +131,3 @@
...
@@ -131,20 +131,3 @@
-
query_range
:
'
sum(rate(container_cpu_usage_seconds_total{container_name!="POD",%{environment_filter}}[2m]))
/
count(container_cpu_usage_seconds_total{container_name!="POD",%{environment_filter}})
*
100'
-
query_range
:
'
sum(rate(container_cpu_usage_seconds_total{container_name!="POD",%{environment_filter}}[2m]))
/
count(container_cpu_usage_seconds_total{container_name!="POD",%{environment_filter}})
*
100'
label
:
Average
label
:
Average
unit
:
"
%"
unit
:
"
%"
-
title
:
"
CPU
usage
by
CPU"
required_metrics
:
-
container_cpu_usage_seconds_total
weight
:
1
queries
:
-
query_range
:
'
avg(rate(container_cpu_usage_seconds_total{%{environment_filter}}[2m]))
by
(cpu)
*
100'
unit
:
Average (%)
label
:
cpu
series
:
-
value
:
cpu00
color
:
red
-
value
:
cpu01
color
:
blue
-
value
:
cpu02
color
:
purple
-
value
:
cpu03
color
:
orange
spec/javascripts/monitoring/graph/legend_spec.js
View file @
93ba3fdd
...
@@ -38,7 +38,7 @@ function getTextFromNode(component, selector) {
...
@@ -38,7 +38,7 @@ function getTextFromNode(component, selector) {
return
component
.
$el
.
querySelector
(
selector
).
firstChild
.
nodeValue
.
trim
();
return
component
.
$el
.
querySelector
(
selector
).
firstChild
.
nodeValue
.
trim
();
}
}
f
describe
(
'
GraphLegend
'
,
()
=>
{
describe
(
'
GraphLegend
'
,
()
=>
{
describe
(
'
Computed props
'
,
()
=>
{
describe
(
'
Computed props
'
,
()
=>
{
it
(
'
textTransform
'
,
()
=>
{
it
(
'
textTransform
'
,
()
=>
{
const
component
=
createComponent
(
defaultValuesComponent
);
const
component
=
createComponent
(
defaultValuesComponent
);
...
@@ -89,11 +89,12 @@ fdescribe('GraphLegend', () => {
...
@@ -89,11 +89,12 @@ fdescribe('GraphLegend', () => {
expect
(
component
.
$el
.
querySelectorAll
(
'
.rect-axis-text
'
).
length
).
toEqual
(
2
);
expect
(
component
.
$el
.
querySelectorAll
(
'
.rect-axis-text
'
).
length
).
toEqual
(
2
);
});
});
it
(
'
contains text to signal the usage, title and time
'
,
()
=>
{
it
(
'
contains text to signal the usage, title and time
with multiple time series
'
,
()
=>
{
const
component
=
createComponent
(
defaultValuesComponent
);
const
component
=
createComponent
(
defaultValuesComponent
);
const
titles
=
component
.
$el
.
querySelectorAll
(
'
.legend-metric-title
'
);
const
titles
=
component
.
$el
.
querySelectorAll
(
'
.legend-metric-title
'
);
expect
(
titles
[
1
].
textContent
.
indexOf
(
'
series
'
)).
not
.
toEqual
(
-
1
);
expect
(
titles
[
0
].
textContent
.
indexOf
(
'
hundred(s)
'
)).
not
.
toEqual
(
-
1
);
expect
(
titles
[
1
].
textContent
.
indexOf
(
'
2xx
'
)).
not
.
toEqual
(
-
1
);
expect
(
getTextFromNode
(
component
,
'
.y-label-text
'
)).
toEqual
(
component
.
yAxisLabel
);
expect
(
getTextFromNode
(
component
,
'
.y-label-text
'
)).
toEqual
(
component
.
yAxisLabel
);
});
});
...
...
spec/javascripts/monitoring/mock_data.js
View file @
93ba3fdd
...
@@ -6346,7 +6346,13 @@ export const singleRowMetricsMultipleSeries = [
...
@@ -6346,7 +6346,13 @@ export const singleRowMetricsMultipleSeries = [
}
}
]
]
},
},
]
],
'
series
'
:
[
{
'
value
'
:
'
hundred(s)
'
,
'
color
'
:
'
green
'
,
},
],
}
}
]
]
},
},
...
...
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