} from '~/app/shared/services/feature-toggles.service';
import { RefreshIntervalService } from '~/app/shared/services/refresh-interval.service';
import { SummaryService } from '~/app/shared/services/summary.service';
+import { PrometheusListHelper } from '~/app/shared/helpers/prometheus-list-helper';
@Component({
selector: 'cd-dashboard',
templateUrl: './dashboard.component.html',
styleUrls: ['./dashboard.component.scss']
})
-export class DashboardComponent implements OnInit, OnDestroy {
+export class DashboardComponent extends PrometheusListHelper implements OnInit, OnDestroy {
detailsCardData: DashboardDetails = {};
osdSettingsService: any;
osdSettings: any;
healthData$: Observable<Object>;
prometheusAlerts$: Observable<AlertmanagerAlert[]>;
- isAlertmanagerConfigured = false;
icons = Icons;
showAlerts = false;
flexHeight = true;
public prometheusService: PrometheusService,
private refreshIntervalService: RefreshIntervalService
) {
+ super(prometheusService);
this.permissions = this.authStorageService.getPermissions();
this.enabledFeature$ = this.featureToggles.get();
}
ngOnInit() {
+ super.ngOnInit();
this.interval = this.refreshIntervalService.intervalData$.subscribe(() => {
this.getHealth();
this.triggerPrometheusAlerts();
triggerPrometheusAlerts() {
this.prometheusService.ifAlertmanagerConfigured(() => {
- this.isAlertmanagerConfigured = true;
-
this.prometheusService.getAlerts().subscribe((alerts) => {
this.alerts = alerts;
this.crticialActiveAlerts = alerts.filter(
}
getPrometheusData(selectedTime: any) {
- if (this.timerGetPrometheusDataSub) {
- this.timerGetPrometheusDataSub.unsubscribe();
- }
- this.timerGetPrometheusDataSub = timer(0, this.timerTime).subscribe(() => {
- selectedTime = this.updateTimeStamp(selectedTime);
-
- for (const queryName in queries) {
- if (queries.hasOwnProperty(queryName)) {
- const query = queries[queryName];
- let interval = selectedTime.step;
-
- if (query.includes('rate') && selectedTime.step < 20) {
- interval = 20;
- } else if (query.includes('rate')) {
- interval = selectedTime.step * 2;
+ this.prometheusService.ifPrometheusConfigured(() => {
+ if (this.timerGetPrometheusDataSub) {
+ this.timerGetPrometheusDataSub.unsubscribe();
+ }
+ this.timerGetPrometheusDataSub = timer(0, this.timerTime).subscribe(() => {
+ selectedTime = this.updateTimeStamp(selectedTime);
+
+ for (const queryName in queries) {
+ if (queries.hasOwnProperty(queryName)) {
+ const query = queries[queryName];
+ let interval = selectedTime.step;
+
+ if (query.includes('rate') && selectedTime.step < 20) {
+ interval = 20;
+ } else if (query.includes('rate')) {
+ interval = selectedTime.step * 2;
+ }
+
+ const intervalAdjustedQuery = query.replace(/\[(.*?)\]/g, `[${interval}s]`);
+
+ this.prometheusService
+ .getPrometheusData({
+ params: intervalAdjustedQuery,
+ start: selectedTime['start'],
+ end: selectedTime['end'],
+ step: selectedTime['step']
+ })
+ .subscribe((data: any) => {
+ if (data.result.length) {
+ this.queriesResults[queryName] = data.result[0].values;
+ }
+ });
}
-
- const intervalAdjustedQuery = query.replace(/\[(.*?)\]/g, `[${interval}s]`);
-
- this.prometheusService
- .getPrometheusData({
- params: intervalAdjustedQuery,
- start: selectedTime['start'],
- end: selectedTime['end'],
- step: selectedTime['step']
- })
- .subscribe((data: any) => {
- if (data.result.length) {
- this.queriesResults[queryName] = data.result[0].values;
- }
- });
}
- }
+ });
});
}