Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
admin-dashboard
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container registry
Model registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ai3
tools
admin-dashboard
Commits
72764a67
Commit
72764a67
authored
2 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Show active (paging) alerts
parent
0a934763
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/dashboard.js
+53
-3
53 additions, 3 deletions
src/dashboard.js
src/index.html
+1
-1
1 addition, 1 deletion
src/index.html
with
54 additions
and
4 deletions
src/dashboard.js
+
53
−
3
View file @
72764a67
...
...
@@ -8,6 +8,20 @@ const prom = new PrometheusDriver({
const
accountsQuery
=
"
sum(max(accounts_count) by (shard,type,status)) by (type)
"
;
const
alertsURL
=
"
https://alerts.autistici.org/alerts.json
"
;
const
alertsQuery
=
{
filters
:
[
"
@state=active
"
,
"
severity=page
"
],
gridLabel
:
""
,
gridSortReverse
:
false
,
gridLimits
:
{},
sortOrder
:
""
,
sortLabel
:
""
,
sortReverse
:
false
,
defaultGroupLimit
:
5
,
groupLimits
:
{}
};
const
accountNiceNames
=
{
mail
:
"
email accounts
"
,
web
:
"
websites
"
,
...
...
@@ -33,16 +47,52 @@ function queryAccounts(el) {
.
catch
((
err
)
=>
{
dashboardError
(
'
Failed to fetch account metrics
'
,
err
);
});
};
}
function
queryAlerts
(
el
)
{
fetch
(
alertsURL
,
{
method
:
'
POST
'
,
body
:
JSON
.
stringify
(
alertsQuery
),
credentials
:
'
include
'
})
.
then
((
resp
)
=>
{
if
(
!
resp
.
ok
)
{
throw
new
Error
(
'
HTTP request failed
'
);
}
return
resp
.
json
();
})
.
then
((
result
)
=>
{
if
(
result
.
status
!=
"
success
"
)
{
throw
new
Error
(
'
JSON API request failed
'
);
}
var
numFiring
=
result
.
totalAlerts
;
var
txt
=
'
No active alerts.
'
;
if
(
numFiring
>
0
)
{
txt
=
''
+
numFiring
+
'
active alerts!
'
;
}
var
p
=
document
.
createElement
(
'
p
'
);
p
.
appendChild
(
document
.
createTextNode
(
txt
));
el
.
append
(
p
);
})
.
catch
((
err
)
=>
{
dashboardError
(
'
Failed to fetch active alerts
'
,
err
);
});
}
function
dashboardError
(
msg
,
err
)
{
var
p
=
document
.
createElement
(
'
p
'
);
p
.
appendChild
(
document
.
createTextNode
(
msg
+
'
:
'
+
err
.
error
));
var
errmsg
=
err
.
error
;
if
(
!
errmsg
)
{
errmsg
=
err
.
message
;
}
p
.
appendChild
(
document
.
createTextNode
(
msg
+
'
:
'
+
errmsg
));
document
.
getElementById
(
'
errors
'
).
append
(
p
);
}
;
}
window
.
addEventListener
(
'
load
'
,
()
=>
{
console
.
log
(
'
Populating data items...
'
);
queryAccounts
(
document
.
getElementById
(
'
accountInfo
'
));
queryAlerts
(
document
.
getElementById
(
'
alertInfo
'
));
});
This diff is collapsed.
Click to expand it.
src/index.html
+
1
−
1
View file @
72764a67
...
...
@@ -72,7 +72,7 @@ body {
<h3>
System information
</h3>
<div
id=
"
sys
Info"
></div>
<div
id=
"
alert
Info"
></div>
<ul>
<li><a
href=
"https://admin.autistici.org/"
>
service-dashboard
</a>
- map of services and hosts
</li>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment