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
2559a880
Commit
2559a880
authored
May 31, 2017
by
kushalpandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prometheus Metrics Bundle
parent
33fe2af4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
0 deletions
+82
-0
app/assets/javascripts/prometheus_metrics/index.js
app/assets/javascripts/prometheus_metrics/index.js
+7
-0
app/assets/javascripts/prometheus_metrics/prometheus_metrics.js
...sets/javascripts/prometheus_metrics/prometheus_metrics.js
+75
-0
No files found.
app/assets/javascripts/prometheus_metrics/index.js
0 → 100644
View file @
2559a880
import
PrometheusMetrics
from
'
./prometheus_metrics
'
;
$
(()
=>
{
const
prometheusMetrics
=
new
PrometheusMetrics
(
'
.js-prometheus-metrics-monitoring
'
);
prometheusMetrics
.
init
();
prometheusMetrics
.
loadActiveMetrics
();
});
app/assets/javascripts/prometheus_metrics/prometheus_metrics.js
0 → 100644
View file @
2559a880
/* eslint-disable class-methods-use-this, promise/catch-or-return */
export
default
class
PrometheusMetrics
{
constructor
(
wrapperSelector
)
{
this
.
backOffRequestCounter
=
0
;
this
.
$wrapper
=
$
(
wrapperSelector
);
this
.
$monitoredMetricsPanel
=
this
.
$wrapper
.
find
(
'
.js-panel-monitored-metrics
'
);
this
.
$monitoredMetricsCount
=
this
.
$monitoredMetricsPanel
.
find
(
'
.js-monitored-count
'
);
this
.
$monitoredMetricsLoading
=
this
.
$monitoredMetricsPanel
.
find
(
'
.js-loading-metrics
'
);
this
.
$monitoredMetricsEmpty
=
this
.
$monitoredMetricsPanel
.
find
(
'
.js-empty-metrics
'
);
this
.
$monitoredMetricsList
=
this
.
$monitoredMetricsPanel
.
find
(
'
.js-metrics-list
'
);
this
.
$panelToggle
=
this
.
$wrapper
.
find
(
'
.js-panel-toggle
'
);
this
.
activeMetricsEndpoint
=
this
.
$monitoredMetricsPanel
.
data
(
'
active-metrics
'
);
}
init
()
{
this
.
$panelToggle
.
on
(
'
click
'
,
e
=>
this
.
handlePanelToggle
(
e
));
}
handlePanelToggle
(
e
)
{
const
$toggleBtn
=
$
(
e
.
currentTarget
);
const
$currentPanelBody
=
$toggleBtn
.
parents
(
'
.panel
'
).
find
(
'
.panel-body
'
);
if
(
$currentPanelBody
.
is
(
'
:visible
'
))
{
$currentPanelBody
.
addClass
(
'
hidden
'
);
$toggleBtn
.
removeClass
(
'
fa-caret-down
'
).
addClass
(
'
fa-caret-right
'
);
}
else
{
$currentPanelBody
.
removeClass
(
'
hidden
'
);
$toggleBtn
.
removeClass
(
'
fa-caret-right
'
).
addClass
(
'
fa-caret-down
'
);
}
}
populateActiveMetrics
(
metrics
)
{
let
totalMonitoredMetrics
=
0
;
metrics
.
forEach
((
metric
)
=>
{
this
.
$monitoredMetricsList
.
append
(
`<li>
${
metric
.
group
}
<span class="badge-count">
${
metric
.
active_metrics
}
</span></li>`
);
totalMonitoredMetrics
+=
metric
.
active_metrics
;
});
this
.
$monitoredMetricsCount
.
text
(
totalMonitoredMetrics
);
this
.
$monitoredMetricsLoading
.
addClass
(
'
hidden
'
);
this
.
$monitoredMetricsList
.
removeClass
(
'
hidden
'
);
}
loadActiveMetrics
()
{
this
.
$monitoredMetricsLoading
.
removeClass
(
'
hidden
'
);
gl
.
utils
.
backOff
((
next
,
stop
)
=>
{
$
.
getJSON
(
this
.
activeMetricsEndpoint
)
.
done
((
res
)
=>
{
if
(
res
&&
res
.
success
)
{
stop
(
res
);
}
else
{
this
.
backOffRequestCounter
=
this
.
backOffRequestCounter
+=
1
;
if
(
this
.
backOffRequestCounter
<
3
)
{
next
();
}
else
{
stop
(
res
);
}
}
})
.
fail
(
stop
);
})
.
then
((
res
)
=>
{
if
(
res
&&
res
.
data
&&
res
.
data
.
length
)
{
this
.
populateActiveMetrics
(
res
.
data
);
}
else
{
this
.
$monitoredMetricsLoading
.
addClass
(
'
hidden
'
);
this
.
$monitoredMetricsEmpty
.
removeClass
(
'
hidden
'
);
}
});
}
}
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