Skip to content

Commit

Permalink
Merge pull request #11351 from richard-cox/fixes-following-grafana-bump
Browse files Browse the repository at this point in the history
Fix two monitoring issues after chart bump
  • Loading branch information
richard-cox committed Sep 27, 2024
1 parent af56c27 commit d33a223
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
24 changes: 17 additions & 7 deletions shell/components/AlertTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default {
];
return {
inStore: this.$store.getters['currentProduct'].inStore,
alertManagerPoller: new Poller(
this.loadAlertManagerEvents,
ALERTMANAGER_POLL_RATE_MS,
Expand All @@ -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` }
);
},
async loadAlertManagerEvents() {
let alertEvents;
try {
alertEvents = await this.fetchAlertManagerEvents('v2');
} catch (err) {
alertEvents = await this.fetchAlertManagerEvents('v1').then((res) => res?.data);
}
if (alertsEvents.data) {
this.allAlerts = alertsEvents.data;
if (alertEvents) {
this.allAlerts = alertEvents;
}
},
Expand Down
10 changes: 6 additions & 4 deletions shell/components/GrafanaDashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit d33a223

Please sign in to comment.