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
61abdb15
Commit
61abdb15
authored
Apr 25, 2017
by
Jose Ivan Vargas Lopez
Committed by
Phil Hughes
Apr 25, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Metrics graph error fix
parent
9852cae8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
29 deletions
+38
-29
app/assets/javascripts/monitoring/prometheus_graph.js
app/assets/javascripts/monitoring/prometheus_graph.js
+34
-29
changelogs/unreleased/metrics-graph-error-fix.yml
changelogs/unreleased/metrics-graph-error-fix.yml
+4
-0
No files found.
app/assets/javascripts/monitoring/prometheus_graph.js
View file @
61abdb15
...
@@ -22,6 +22,7 @@ class PrometheusGraph {
...
@@ -22,6 +22,7 @@ class PrometheusGraph {
const
hasMetrics
=
$prometheusContainer
.
data
(
'
has-metrics
'
);
const
hasMetrics
=
$prometheusContainer
.
data
(
'
has-metrics
'
);
this
.
docLink
=
$prometheusContainer
.
data
(
'
doc-link
'
);
this
.
docLink
=
$prometheusContainer
.
data
(
'
doc-link
'
);
this
.
integrationLink
=
$prometheusContainer
.
data
(
'
prometheus-integration
'
);
this
.
integrationLink
=
$prometheusContainer
.
data
(
'
prometheus-integration
'
);
this
.
state
=
''
;
$
(
document
).
ajaxError
(()
=>
{});
$
(
document
).
ajaxError
(()
=>
{});
...
@@ -38,8 +39,9 @@ class PrometheusGraph {
...
@@ -38,8 +39,9 @@ class PrometheusGraph {
this
.
configureGraph
();
this
.
configureGraph
();
this
.
init
();
this
.
init
();
}
else
{
}
else
{
const
prevState
=
this
.
state
;
this
.
state
=
'
.js-getting-started
'
;
this
.
state
=
'
.js-getting-started
'
;
this
.
updateState
();
this
.
updateState
(
prevState
);
}
}
}
}
...
@@ -53,26 +55,26 @@ class PrometheusGraph {
...
@@ -53,26 +55,26 @@ class PrometheusGraph {
}
}
init
()
{
init
()
{
this
.
getData
().
then
((
metricsResponse
)
=>
{
return
this
.
getData
().
then
((
metricsResponse
)
=>
{
let
enoughData
=
true
;
let
enoughData
=
true
;
if
(
typeof
metricsResponse
===
'
undefined
'
)
{
enoughData
=
false
;
}
else
{
Object
.
keys
(
metricsResponse
.
metrics
).
forEach
((
key
)
=>
{
Object
.
keys
(
metricsResponse
.
metrics
).
forEach
((
key
)
=>
{
let
currentKey
;
if
(
key
===
'
cpu_values
'
||
key
===
'
memory_values
'
)
{
if
(
key
===
'
cpu_values
'
||
key
===
'
memory_values
'
)
{
currentKey
=
metricsResponse
.
metrics
[
key
];
const
currentData
=
(
metricsResponse
.
metrics
[
key
])[
0
];
if
(
Object
.
keys
(
currentKey
).
length
===
0
)
{
if
(
currentData
.
values
.
length
<=
2
)
{
enoughData
=
false
;
enoughData
=
false
;
}
}
}
}
});
});
if
(
!
enoughData
)
{
}
this
.
state
=
'
.js-loading
'
;
if
(
enoughData
)
{
this
.
updateStat
e
();
$
(
prometheusStatesContainer
).
hid
e
();
}
else
{
$
(
prometheusParentGraphContainer
).
show
();
this
.
transformData
(
metricsResponse
);
this
.
transformData
(
metricsResponse
);
this
.
createGraph
();
this
.
createGraph
();
}
}
}).
catch
(()
=>
{
new
Flash
(
'
An error occurred when trying to load metrics. Please try again.
'
);
});
});
}
}
...
@@ -342,6 +344,8 @@ class PrometheusGraph {
...
@@ -342,6 +344,8 @@ class PrometheusGraph {
getData
()
{
getData
()
{
const
maxNumberOfRequests
=
3
;
const
maxNumberOfRequests
=
3
;
this
.
state
=
'
.js-loading
'
;
this
.
updateState
();
return
gl
.
utils
.
backOff
((
next
,
stop
)
=>
{
return
gl
.
utils
.
backOff
((
next
,
stop
)
=>
{
$
.
ajax
({
$
.
ajax
({
url
:
metricsEndpoint
,
url
:
metricsEndpoint
,
...
@@ -352,12 +356,11 @@ class PrometheusGraph {
...
@@ -352,12 +356,11 @@ class PrometheusGraph {
this
.
backOffRequestCounter
=
this
.
backOffRequestCounter
+=
1
;
this
.
backOffRequestCounter
=
this
.
backOffRequestCounter
+=
1
;
if
(
this
.
backOffRequestCounter
<
maxNumberOfRequests
)
{
if
(
this
.
backOffRequestCounter
<
maxNumberOfRequests
)
{
next
();
next
();
}
else
{
}
else
if
(
this
.
backOffRequestCounter
>=
maxNumberOfRequests
)
{
stop
({
stop
(
new
Error
(
'
loading
'
));
status
:
resp
.
status
,
metrics
:
data
,
});
}
}
}
else
if
(
!
data
.
success
)
{
stop
(
new
Error
(
'
loading
'
));
}
else
{
}
else
{
stop
({
stop
({
status
:
resp
.
status
,
status
:
resp
.
status
,
...
@@ -373,8 +376,9 @@ class PrometheusGraph {
...
@@ -373,8 +376,9 @@ class PrometheusGraph {
return
resp
.
metrics
;
return
resp
.
metrics
;
})
})
.
catch
(()
=>
{
.
catch
(()
=>
{
const
prevState
=
this
.
state
;
this
.
state
=
'
.js-unable-to-connect
'
;
this
.
state
=
'
.js-unable-to-connect
'
;
this
.
updateState
();
this
.
updateState
(
prevState
);
});
});
}
}
...
@@ -382,19 +386,20 @@ class PrometheusGraph {
...
@@ -382,19 +386,20 @@ class PrometheusGraph {
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
];
if
(
metricValues
!==
undefined
)
{
this
.
graphSpecificProperties
[
key
].
data
=
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
],
}));
}));
}
}
}
});
});
}
}
updateState
()
{
updateState
(
prevState
)
{
const
$statesContainer
=
$
(
prometheusStatesContainer
);
const
$statesContainer
=
$
(
prometheusStatesContainer
);
$
(
prometheusParentGraphContainer
).
hide
();
$
(
prometheusParentGraphContainer
).
hide
();
if
(
prevState
)
{
$
(
`
${
prevState
}
`
,
$statesContainer
).
addClass
(
'
hidden
'
);
}
$
(
`
${
this
.
state
}
`
,
$statesContainer
).
removeClass
(
'
hidden
'
);
$
(
`
${
this
.
state
}
`
,
$statesContainer
).
removeClass
(
'
hidden
'
);
$
(
prometheusStatesContainer
).
show
();
$
(
prometheusStatesContainer
).
show
();
}
}
...
...
changelogs/unreleased/metrics-graph-error-fix.yml
0 → 100644
View file @
61abdb15
---
title
:
Fixed Prometheus monitoring graphs not showing empty states in certain scenarios
merge_request
:
author
:
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