Skip to content

Commit e6f0eb1

Browse files
authored
feat(ui): add filters on monitoring status page (#5456)
* feat(ui): add filters on monitoring status page Signed-off-by: Yvonnick Esnault <[email protected]>
1 parent 234d775 commit e6f0eb1

File tree

13 files changed

+232
-197
lines changed

13 files changed

+232
-197
lines changed

engine/api/api.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,6 @@ func (a *API) Serve(ctx context.Context) error {
630630
go event.DequeueEvent(ctx, a.mustDB())
631631
}
632632

633-
// here the generated name of API is ready, we set ServerName with that
634-
a.Common.ServiceName = event.GetCDSName()
635-
636633
log.Info(ctx, "Initializing internal routines...")
637634
a.GoRoutines.Run(ctx, "maintenance.Subscribe", func(ctx context.Context) {
638635
if err := a.listenMaintenance(ctx); err != nil {

engine/api/status.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func VersionHandler() service.Handler {
3333
// Status returns status, implements interface service.Service
3434
func (api *API) Status(ctx context.Context) *sdk.MonitoringStatus {
3535
m := api.NewMonitoringStatus()
36+
m.ServiceName = event.GetCDSName()
3637

3738
m.AddLine(sdk.MonitoringStatusLine{Component: "Hostname", Value: event.GetHostname(), Status: sdk.MonitoringStatusOK})
3839
m.AddLine(sdk.MonitoringStatusLine{Component: "CDSName", Value: api.Name(), Status: sdk.MonitoringStatusOK})
@@ -126,21 +127,19 @@ func (api *API) computeGlobalStatus(srvs []sdk.Service) sdk.MonitoringStatus {
126127
})
127128
}
128129
}
129-
130-
if strings.Contains(l.Component, "CDSName") {
131-
t := resume[s.Type]
132-
t.nbOK += nbOK
133-
t.nbWarn += nbWarn
134-
t.nbAlerts += nbAlert
135-
t.nbSrv++
136-
resume[s.Type] = t
137-
138-
nbg.nbOK += nbOK
139-
nbg.nbWarn += nbWarn
140-
nbg.nbAlerts += nbAlert
141-
nbg.nbSrv++
142-
}
143130
}
131+
132+
t := resume[s.Type]
133+
t.nbOK += nbOK
134+
t.nbWarn += nbWarn
135+
t.nbAlerts += nbAlert
136+
t.nbSrv++
137+
resume[s.Type] = t
138+
139+
nbg.nbOK += nbOK
140+
nbg.nbWarn += nbWarn
141+
nbg.nbAlerts += nbAlert
142+
nbg.nbSrv++
144143
}
145144

146145
if versionOk {

engine/cdn/cdn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func (s *Service) Serve(c context.Context) error {
172172
return err
173173
}
174174

175-
s.RunTcpLogServer(ctx)
175+
s.runTCPLogServer(ctx)
176176

177177
log.Info(ctx, "Initializing HTTP router")
178178
s.initRouter(ctx)

engine/cdn/cdn_log.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var (
2929
keyServiceLogIncomingQueue = cache.Key("cdn", "log", "incoming", "service")
3030
)
3131

32-
func (s *Service) RunTcpLogServer(ctx context.Context) {
32+
func (s *Service) runTCPLogServer(ctx context.Context) {
3333
// Init hatcheries cache
3434
if err := s.refreshHatcheriesPK(ctx); err != nil {
3535
log.Error(ctx, "unable to init hatcheries cache: %v", err)
@@ -49,7 +49,7 @@ func (s *Service) RunTcpLogServer(ctx context.Context) {
4949
_ = listener.Close()
5050
}()
5151

52-
for i := int64(0); i <= s.Cfg.NbJobLogsGoroutines; i++ {
52+
for i := int64(0); i < s.Cfg.NbJobLogsGoroutines; i++ {
5353
s.GoRoutines.Run(ctx, fmt.Sprintf("cdn-worker-job-%d", i), func(ctx context.Context) {
5454
if err := s.dequeueJobLogs(ctx); err != nil {
5555
log.Error(ctx, "dequeueJobLogs: unable to dequeue redis incoming job logs: %v", err)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- +migrate Up
2+
3+
alter table "service" drop column monitoring_status;
4+
5+
-- +migrate Down
6+
7+
alter table "service" add column monitoring_status JSONB;

engine/worker/internal/register.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (w *CurrentWorker) Unregister(ctx context.Context) error {
7070
return nil
7171
}
7272

73-
// LoopPath return the list of evailable command in path
73+
// LoopPath returns the list of available binaries in path
7474
func LoopPath(w *CurrentWorker, reqs []sdk.Requirement) []string {
7575
binaries := []string{}
7676
for _, req := range reqs {

ui/src/app/model/monitoring.model.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,25 @@ export class MonitoringStatusLine {
1313
status: string;
1414
component: string;
1515
value: string;
16+
type: string;
17+
service: string;
18+
hostname: string;
19+
session: string;
20+
consumer: string;
21+
}
22+
23+
export class MonitoringStatusLineUtil {
24+
public static color(monitoringMetricsLine: MonitoringStatusLine): string {
25+
switch (monitoringMetricsLine.status) {
26+
case 'OK':
27+
return 'green';
28+
case 'AL':
29+
return 'red';
30+
case 'WARN':
31+
return 'orange';
32+
}
33+
return 'blue';
34+
}
1635
}
1736

1837
export interface MonitoringMetricsLabel {
@@ -35,3 +54,4 @@ export interface MonitoringMetricsLine {
3554
type: number;
3655
metric: MonitoringMetricsMetric[];
3756
}
57+

ui/src/app/views/admin/service/list/service.list.component.ts

Lines changed: 65 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ChangeDetectionStrategy, ChangeDetectorRef, Component } from '@angular/core';
2-
import { MonitoringStatus, MonitoringStatusLine } from 'app/model/monitoring.model';
2+
import { MonitoringStatus, MonitoringStatusLine, MonitoringStatusLineUtil } from 'app/model/monitoring.model';
3+
import { Column, ColumnType, Filter } from 'app/shared/table/data-table.component';
34
import { forkJoin, Observable } from 'rxjs';
45
import { finalize, tap } from 'rxjs/operators';
56
import { Global, Service } from '../../../../model/service.model';
@@ -20,7 +21,8 @@ export class ServiceListComponent {
2021
services: Array<Service>;
2122
profiles: any;
2223
goroutines: any;
23-
filteredStatusLines: Array<MonitoringStatusLine>;
24+
columns: Array<Column<MonitoringStatusLine>>;
25+
filteredStatusLines: Filter<MonitoringStatusLine>;
2426
globals: Array<Global> = [];
2527
globalStatus: Global;
2628
globalVersion: Global;
@@ -33,6 +35,67 @@ export class ServiceListComponent {
3335
) {
3436
this.loading = true;
3537

38+
this.columns = [
39+
<Column<MonitoringStatusLine>>{
40+
name: 'common_type',
41+
selector: (c: MonitoringStatusLine) => c.type
42+
},
43+
<Column<MonitoringStatusLine>>{
44+
name: 'common_service',
45+
selector: (c: MonitoringStatusLine) => c.service
46+
},
47+
<Column<MonitoringStatusLine>>{
48+
name: 'common_component',
49+
selector: (c: MonitoringStatusLine) => c.component
50+
},
51+
<Column<MonitoringStatusLine>>{
52+
name: 'common_hostname',
53+
selector: (c: MonitoringStatusLine) => c.hostname
54+
},
55+
<Column<MonitoringStatusLine>>{
56+
name: 'common_status',
57+
type: ColumnType.LABEL,
58+
selector: (c: MonitoringStatusLine) => {
59+
return {
60+
class: MonitoringStatusLineUtil.color(c),
61+
value: c.status
62+
};
63+
}
64+
},
65+
<Column<MonitoringStatusLine>>{
66+
name: 'common_value',
67+
selector: (c: MonitoringStatusLine) => c.value
68+
},
69+
<Column<MonitoringStatusLine>>{
70+
name: 'common_consumer',
71+
selector: (c: MonitoringStatusLine) => c.consumer
72+
},
73+
<Column<MonitoringStatusLine>>{
74+
name: 'common_session',
75+
selector: (c: MonitoringStatusLine) => c.session
76+
}
77+
];
78+
79+
this.filteredStatusLines = f => {
80+
const lowerFilter = f.toLowerCase();
81+
return (line: MonitoringStatusLine) => {
82+
if (f === 'NOTICE') {
83+
return line.status.indexOf('AL') !== -1 || line.status.indexOf('WARN') !== -1;
84+
}
85+
if (f === 'AL' || f === 'WARN' || f === 'OK') {
86+
return line.status.toLowerCase().indexOf(lowerFilter) !== -1;
87+
}
88+
return line.status.toLowerCase().indexOf(lowerFilter) !== -1 ||
89+
line.component.toLowerCase().indexOf(lowerFilter) !== -1 ||
90+
line.value.toLowerCase().indexOf(lowerFilter) !== -1 ||
91+
line.type.toLowerCase().indexOf(lowerFilter) !== -1 ||
92+
(line.service && line.service.toLowerCase().indexOf(lowerFilter) !== -1) ||
93+
(line.hostname && line.hostname.toLowerCase().indexOf(lowerFilter) !== -1) ||
94+
(line.session && line.session.toLowerCase().indexOf(lowerFilter) !== -1) ||
95+
(line.consumer && line.consumer.toLowerCase().indexOf(lowerFilter) !== -1);
96+
}
97+
};
98+
3699
forkJoin(
37100
this.refreshProfiles(),
38101
this.refreshStatus(),
@@ -81,7 +144,6 @@ export class ServiceListComponent {
81144
refreshStatus(): Observable<any> {
82145
return this._monitoringService.getStatus().pipe(tap(r => {
83146
this.status = r;
84-
this.filterChange();
85147
}));
86148
}
87149

@@ -118,33 +180,4 @@ export class ServiceListComponent {
118180
this.goroutines = data;
119181
}));
120182
}
121-
122-
filterChange(): void {
123-
if (!this.filter) {
124-
this.filteredStatusLines = this.status.lines;
125-
return;
126-
}
127-
128-
if (this.filter === 'NOTICE') {
129-
this.filteredStatusLines = this.status.lines.filter(line => {
130-
return line.status.indexOf('AL') !== -1 || line.status.indexOf('WARN') !== -1
131-
});
132-
return
133-
}
134-
135-
if (this.filter === 'AL' || this.filter === 'WARN' || this.filter === 'OK') {
136-
this.filteredStatusLines = this.status.lines.filter(line => {
137-
return line.status.indexOf(this.filter) !== -1
138-
});
139-
return
140-
}
141-
142-
const lowerFilter = this.filter.toLowerCase();
143-
144-
this.filteredStatusLines = this.status.lines.filter(line => {
145-
return line.status.toLowerCase().indexOf(lowerFilter) !== -1 ||
146-
line.component.toLowerCase().indexOf(lowerFilter) !== -1 ||
147-
line.value.toLowerCase().indexOf(lowerFilter) !== -1
148-
});
149-
}
150183
}

0 commit comments

Comments
 (0)