logs.expectBreadcrumbText('Logs');
});
- it('should show two tabs', () => {
- logs.getTabsCount().should('eq', 2);
+ it('should show three tabs', () => {
+ logs.getTabsCount().should('eq', 3);
});
it('should show cluster logs tab at first', () => {
it('should show audit logs as a second tab', () => {
logs.getTabText(1).should('eq', 'Audit Logs');
});
+
+ it('should show daemon logs as a third tab', () => {
+ logs.getTabText(2).should('eq', 'Daemon Logs');
+ });
});
describe('audit logs respond to pool creation and deletion test', () => {
i18n>Performance</a>
<ng-template ngbNavContent>
<cd-grafana [grafanaPath]="rbdDashboardUrl"
+ [type]="'metrics'"
uid="YhCYGcuZz"
grafanaStyle="one">
</cd-grafana>
<cd-rbd-tabs></cd-rbd-tabs>
<cd-grafana [grafanaPath]="'rbd-overview?'"
+ [type]="'metrics'"
uid="41FrpeUiz"
grafanaStyle="two">
</cd-grafana>
i18n>Performance Details</a>
<ng-template ngbNavContent>
<cd-grafana [grafanaPath]="'mds-performance?var-mds_servers=mds.' + grafanaId"
+ [type]="'metrics'"
uid="tbO9LAiZz"
grafanaStyle="one">
</cd-grafana>
i18n>Performance Details</a>
<ng-template ngbNavContent>
<cd-grafana [grafanaPath]="'host-details?var-ceph_hosts=' + selectedHostname"
+ [type]="'metrics'"
uid="rtOg0AiWz"
grafanaStyle="four">
</cd-grafana>
i18n>Overall Performance</a>
<ng-template ngbNavContent>
<cd-grafana [grafanaPath]="'host-overview?'"
+ [type]="'metrics'"
uid="y0KGL0iZz"
grafanaStyle="two">
</cd-grafana>
</div>
</ng-template>
</li>
+ <li ngbNavItem="daemon-logs">
+ <a ngbNavLink
+ i18n>Daemon Logs</a>
+ <ng-template ngbNavContent>
+ <ng-container *ngIf="lokiServiceStatus$ | async as lokiServiceStatus; else daemonLogsTpl">
+ <div *ngIf="promtailServiceStatus$ | async as promtailServiceStatus; else daemonLogsTpl">
+ <cd-grafana [grafanaPath]="'explore?'"
+ [type]="'logs'"
+ uid="CrAHE0iZz"
+ grafanaStyle="two">
+ </cd-grafana>
+ </div>
+ </ng-container>
+ </ng-template>
+ </li>
</ul>
<div [ngbNavOutlet]="nav"></div>
(click)="resetFilter()"
i18n>Reset filter.</a>
</ng-template>
+
+<ng-template #daemonLogsTpl>
+ <cd-alert-panel type="info"
+ title="Loki/Promtail service not running"
+ i18n-title>
+ <ng-container i18n>Please start the loki and promtail service to see these logs.</ng-container>
+ </cd-alert-panel>
+</ng-template>
import { Component, NgZone, OnDestroy, OnInit } from '@angular/core';
import { NgbDateStruct } from '@ng-bootstrap/ng-bootstrap';
+import { Observable } from 'rxjs';
+import { map } from 'rxjs/operators';
+import { CephServiceService } from '~/app/shared/api/ceph-service.service';
import { LogsService } from '~/app/shared/api/logs.service';
import { Icons } from '~/app/shared/enum/icons.enum';
icons = Icons;
clogText: string;
auditLogText: string;
+ lokiServiceStatus$: Observable<boolean>;
+ promtailServiceStatus$: Observable<boolean>;
interval: number;
priorities: Array<{ name: string; value: string }> = [
constructor(
private logsService: LogsService,
+ private cephService: CephServiceService,
private datePipe: DatePipe,
private ngZone: NgZone
) {}
ngOnInit() {
this.getInfo();
this.ngZone.runOutsideAngular(() => {
+ this.getDaemonDetails();
this.interval = window.setInterval(() => {
this.ngZone.run(() => {
this.getInfo();
clearInterval(this.interval);
}
+ getDaemonDetails() {
+ this.lokiServiceStatus$ = this.cephService.getDaemons('loki').pipe(
+ map((data: any) => {
+ return data.length > 0 && data[0].status === 1;
+ })
+ );
+ this.promtailServiceStatus$ = this.cephService.getDaemons('promtail').pipe(
+ map((data: any) => {
+ return data.length > 0 && data[0].status === 1;
+ })
+ );
+ }
+
getInfo() {
this.logsService.getLogs().subscribe((data: any) => {
this.contentData = data;
i18n>Performance Details</a>
<ng-template ngbNavContent>
<cd-grafana [grafanaPath]="'osd-device-details?var-osd=osd.' + osd['id']"
+ [type]="'metrics'"
uid="CrAHE0iZz"
grafanaStyle="three">
</cd-grafana>
i18n>Overall Performance</a>
<ng-template ngbNavContent>
<cd-grafana [grafanaPath]="'osd-overview?'"
+ [type]="'metrics'"
uid="lo02I1Aiz"
grafanaStyle="four">
</cd-grafana>
i18n>Performance Details</a>
<ng-template ngbNavContent>
<cd-grafana grafanaPath="ceph-pool-detail?var-pool_name={{selection.pool_name}}"
+ [type]="'metrics'"
uid="-xyV8KCiz"
grafanaStyle="three">
</cd-grafana>
i18n>Overall Performance</a>
<ng-template ngbNavContent>
<cd-grafana [grafanaPath]="'ceph-pools-overview?'"
+ [type]="'metrics'"
uid="z99hzWtmk"
grafanaStyle="two">
</cd-grafana>
i18n>Performance Details</a>
<ng-template ngbNavContent>
<cd-grafana [grafanaPath]="'rgw-instance-detail?var-rgw_servers=rgw.' + this.serviceId"
+ [type]="'metrics'"
uid="x5ARzZtmk"
grafanaStyle="one">
</cd-grafana>
i18n>Overall Performance</a>
<ng-template ngbNavContent>
<cd-grafana [grafanaPath]="'rgw-overview?'"
+ [type]="'metrics'"
uid="WAkugZpiz"
grafanaStyle="two">
</cd-grafana>
i18n>Sync Performance</a>
<ng-template ngbNavContent>
<cd-grafana [grafanaPath]="'radosgw-sync-overview?'"
+ [type]="'metrics'"
uid="rgw-sync-overview"
grafanaStyle="two">
</cd-grafana>
let fixture: ComponentFixture<GrafanaComponent>;
const expected_url =
'http:localhost:3000/d/foo/somePath&refresh=2s&var-datasource=Dashboard1&kiosk&from=now-1h&to=now';
+ const expected_logs_url =
+ 'http:localhost:3000/explore?orgId=1&left=["now-1h","now","Loki",{"refId":"A"}]&kiosk';
configureTestBed({
declarations: [GrafanaComponent, AlertPanelComponent, LoadingPanelComponent, DocComponent],
fixture = TestBed.createComponent(GrafanaComponent);
component = fixture.componentInstance;
component.grafanaPath = 'somePath';
+ component.type = 'metrics';
component.uid = 'foo';
});
describe('with grafana initialized', () => {
beforeEach(() => {
TestBed.inject(SettingsService)['settings'] = { 'api/grafana/url': 'http:localhost:3000' };
+ component.type = 'metrics';
fixture.detectChanges();
});
expect(component.dashboardExist).toBe(true);
});
});
+
+ describe('with loki datasource', () => {
+ beforeEach(() => {
+ TestBed.inject(SettingsService)['settings'] = { 'api/grafana/url': 'http:localhost:3000' };
+ component.type = 'logs';
+ component.grafanaPath = 'explore?';
+ fixture.detectChanges();
+ });
+
+ it('should have found out that Loki Log Search exists', () => {
+ expect(component.grafanaExist).toBe(true);
+ expect(component.baseUrl).toBe('http:localhost:3000/d/');
+ expect(component.loading).toBe(false);
+ expect(component.url).toBe(expected_logs_url);
+ expect(component.grafanaSrc).toEqual({
+ changingThisBreaksApplicationSecurity: expected_logs_url
+ });
+ });
+ });
});
panelStyle: any;
grafanaExist = false;
mode = '&kiosk';
- datasource = 'Dashboard1';
+ datasource: string;
loading = true;
styles: Record<string, string> = {};
dashboardExist = true;
icons = Icons;
readonly DEFAULT_TIME: string = 'from=now-1h&to=now';
+ @Input()
+ type: string;
@Input()
grafanaPath: string;
@Input()
four: 'grafana_four'
};
+ this.datasource = this.type === 'metrics' ? 'Dashboard1' : 'Loki';
+
this.settingsService.ifSettingConfigured('api/grafana/url', (url) => {
this.grafanaExist = true;
this.loading = false;
this.settingsService
.validateGrafanaDashboardUrl(this.uid)
.subscribe((data: any) => (this.dashboardExist = data === 200));
- this.url =
- this.baseUrl +
- this.uid +
- '/' +
- this.grafanaPath +
- '&refresh=2s' +
- `&var-datasource=${this.datasource}` +
- this.mode +
- '&' +
- this.time;
+ if (this.type === 'metrics') {
+ this.url = `${this.baseUrl}${this.uid}/${this.grafanaPath}&refresh=2s&var-datasource=${this.datasource}${this.mode}&${this.time}`;
+ } else {
+ this.url = `${this.baseUrl.slice(0, -2)}${this.grafanaPath}orgId=1&left=["now-1h","now","${
+ this.datasource
+ }",{"refId":"A"}]${this.mode}`;
+ }
this.grafanaSrc = this.sanitizer.bypassSecurityTrustResourceUrl(this.url);
}