Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
61abdb15
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
61abdb15
编写于
4月 25, 2017
作者:
J
Jose Ivan Vargas Lopez
提交者:
Phil Hughes
4月 25, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Metrics graph error fix
上级
9852cae8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
38 addition
and
29 deletion
+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
未找到文件。
app/assets/javascripts/monitoring/prometheus_graph.js
浏览文件 @
61abdb15
...
...
@@ -22,6 +22,7 @@ class PrometheusGraph {
const
hasMetrics
=
$prometheusContainer
.
data
(
'
has-metrics
'
);
this
.
docLink
=
$prometheusContainer
.
data
(
'
doc-link
'
);
this
.
integrationLink
=
$prometheusContainer
.
data
(
'
prometheus-integration
'
);
this
.
state
=
''
;
$
(
document
).
ajaxError
(()
=>
{});
...
...
@@ -38,8 +39,9 @@ class PrometheusGraph {
this
.
configureGraph
();
this
.
init
();
}
else
{
const
prevState
=
this
.
state
;
this
.
state
=
'
.js-getting-started
'
;
this
.
updateState
();
this
.
updateState
(
prevState
);
}
}
...
...
@@ -53,26 +55,26 @@ class PrometheusGraph {
}
init
()
{
this
.
getData
().
then
((
metricsResponse
)
=>
{
return
this
.
getData
().
then
((
metricsResponse
)
=>
{
let
enoughData
=
true
;
Object
.
keys
(
metricsResponse
.
metrics
).
forEach
((
key
)
=>
{
let
currentKey
;
if
(
key
===
'
cpu_values
'
||
key
===
'
memory_values
'
)
{
currentKey
=
metricsResponse
.
metrics
[
key
];
if
(
Object
.
keys
(
currentKey
).
length
===
0
)
{
enoughData
=
false
;
}
}
});
if
(
!
enoughData
)
{
this
.
state
=
'
.js-loading
'
;
this
.
updateState
();
if
(
typeof
metricsResponse
===
'
undefined
'
)
{
enoughData
=
false
;
}
else
{
Object
.
keys
(
metricsResponse
.
metrics
).
forEach
((
key
)
=>
{
if
(
key
===
'
cpu_values
'
||
key
===
'
memory_values
'
)
{
const
currentData
=
(
metricsResponse
.
metrics
[
key
])[
0
];
if
(
currentData
.
values
.
length
<=
2
)
{
enoughData
=
false
;
}
}
});
}
if
(
enoughData
)
{
$
(
prometheusStatesContainer
).
hide
();
$
(
prometheusParentGraphContainer
).
show
();
this
.
transformData
(
metricsResponse
);
this
.
createGraph
();
}
}).
catch
(()
=>
{
new
Flash
(
'
An error occurred when trying to load metrics. Please try again.
'
);
});
}
...
...
@@ -342,6 +344,8 @@ class PrometheusGraph {
getData
()
{
const
maxNumberOfRequests
=
3
;
this
.
state
=
'
.js-loading
'
;
this
.
updateState
();
return
gl
.
utils
.
backOff
((
next
,
stop
)
=>
{
$
.
ajax
({
url
:
metricsEndpoint
,
...
...
@@ -352,12 +356,11 @@ class PrometheusGraph {
this
.
backOffRequestCounter
=
this
.
backOffRequestCounter
+=
1
;
if
(
this
.
backOffRequestCounter
<
maxNumberOfRequests
)
{
next
();
}
else
{
stop
({
status
:
resp
.
status
,
metrics
:
data
,
});
}
else
if
(
this
.
backOffRequestCounter
>=
maxNumberOfRequests
)
{
stop
(
new
Error
(
'
loading
'
));
}
}
else
if
(
!
data
.
success
)
{
stop
(
new
Error
(
'
loading
'
));
}
else
{
stop
({
status
:
resp
.
status
,
...
...
@@ -373,8 +376,9 @@ class PrometheusGraph {
return
resp
.
metrics
;
})
.
catch
(()
=>
{
const
prevState
=
this
.
state
;
this
.
state
=
'
.js-unable-to-connect
'
;
this
.
updateState
();
this
.
updateState
(
prevState
);
});
}
...
...
@@ -382,19 +386,20 @@ class PrometheusGraph {
Object
.
keys
(
metricsResponse
.
metrics
).
forEach
((
key
)
=>
{
if
(
key
===
'
cpu_values
'
||
key
===
'
memory_values
'
)
{
const
metricValues
=
(
metricsResponse
.
metrics
[
key
])[
0
];
if
(
metricValues
!==
undefined
)
{
this
.
graphSpecificProperties
[
key
].
data
=
metricValues
.
values
.
map
(
metric
=>
({
time
:
new
Date
(
metric
[
0
]
*
1000
),
value
:
metric
[
1
],
}));
}
this
.
graphSpecificProperties
[
key
].
data
=
metricValues
.
values
.
map
(
metric
=>
({
time
:
new
Date
(
metric
[
0
]
*
1000
),
value
:
metric
[
1
],
}));
}
});
}
updateState
()
{
updateState
(
prevState
)
{
const
$statesContainer
=
$
(
prometheusStatesContainer
);
$
(
prometheusParentGraphContainer
).
hide
();
if
(
prevState
)
{
$
(
`
${
prevState
}
`
,
$statesContainer
).
addClass
(
'
hidden
'
);
}
$
(
`
${
this
.
state
}
`
,
$statesContainer
).
removeClass
(
'
hidden
'
);
$
(
prometheusStatesContainer
).
show
();
}
...
...
changelogs/unreleased/metrics-graph-error-fix.yml
0 → 100644
浏览文件 @
61abdb15
---
title
:
Fixed Prometheus monitoring graphs not showing empty states in certain scenarios
merge_request
:
author
:
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录