mirror of https://github.com/rancher/dashboard.git
Fix two monitoring issues after chart bump
- Alerts - v1 endpoint no longer available - Granfana charts now have unique class names (used to determine if loading inidicator should be hidden)
This commit is contained in:
parent
be747fd1fb
commit
5840507eaf
|
|
@ -49,6 +49,7 @@ export default {
|
|||
];
|
||||
|
||||
return {
|
||||
inStore: this.$store.getters['currentProduct'].inStore,
|
||||
alertManagerPoller: new Poller(
|
||||
this.loadAlertManagerEvents,
|
||||
ALERTMANAGER_POLL_RATE_MS,
|
||||
|
|
@ -69,15 +70,24 @@ export default {
|
|||
},
|
||||
|
||||
methods: {
|
||||
async loadAlertManagerEvents() {
|
||||
const inStore = this.$store.getters['currentProduct'].inStore;
|
||||
const alertsEvents = await this.$store.dispatch(
|
||||
`${ inStore }/request`,
|
||||
{ url: `/k8s/clusters/${ this.currentCluster.id }/api/v1/namespaces/${ this.monitoringNamespace }/services/http:${ this.alertServiceEndpoint }:9093/proxy/api/v1/alerts` }
|
||||
async fetchAlertManagerEvents(version) {
|
||||
return await this.$store.dispatch(
|
||||
`${ this.inStore }/request`,
|
||||
{ url: `/k8s/clusters/${ this.currentCluster.id }/api/v1/namespaces/${ this.monitoringNamespace }/services/http:${ this.alertServiceEndpoint }:9093/proxy/api/${ version }/alerts` }
|
||||
);
|
||||
},
|
||||
|
||||
if (alertsEvents.data) {
|
||||
this.allAlerts = alertsEvents.data;
|
||||
async loadAlertManagerEvents() {
|
||||
let alertEvents;
|
||||
|
||||
try {
|
||||
alertEvents = await this.fetchAlertManagerEvents('v2');
|
||||
} catch (err) {
|
||||
alertEvents = await this.fetchAlertManagerEvents('v1').then((res) => res?.data);
|
||||
}
|
||||
|
||||
if (alertEvents) {
|
||||
this.allAlerts = alertEvents;
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -114,10 +114,12 @@ export default {
|
|||
this.interval = setInterval(() => {
|
||||
try {
|
||||
const graphWindow = this.$refs.frame?.contentWindow;
|
||||
const errorElements = graphWindow.document.getElementsByClassName('alert-error');
|
||||
const errorCornerElements = graphWindow.document.getElementsByClassName('panel-info-corner--error');
|
||||
const panelInFullScreenElements = graphWindow.document.getElementsByClassName('panel-in-fullscreen');
|
||||
const panelContainerElements = graphWindow.document.getElementsByClassName('panel-container');
|
||||
|
||||
// Note. getElementsByClassName won't work, following a grafana bump class names are now unique - for example css-2qng6u-panel-container
|
||||
const errorElements = graphWindow.document.querySelectorAll('[class$="alert-error');
|
||||
const errorCornerElements = graphWindow.document.querySelectorAll('[class$="panel-info-corner--error');
|
||||
const panelInFullScreenElements = graphWindow.document.querySelectorAll('[class$="panel-in-fullscreen');
|
||||
const panelContainerElements = graphWindow.document.querySelectorAll('[class$="panel-container');
|
||||
const error = errorElements.length > 0 || errorCornerElements.length > 0;
|
||||
const loaded = panelInFullScreenElements.length > 0 || panelContainerElements.length > 0;
|
||||
const errorMessageElms = graphWindow.document.getElementsByTagName('pre');
|
||||
|
|
|
|||
Loading…
Reference in New Issue