Run this in the devtools console of a Grafana tab. I guess with minor modifications it could be adapted to run in nodejs, on schedule.
(async () => {
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
const aids = await fetch(`/api/alerts/`).then(v => v.json());
let alerts = (await Promise.all(
aids.map(({ id, dashboardSlug }) => sleep(Math.random() * 10000).then(() => fetch(`/api/alerts/${id}`))
.then(v => v.json()).then(v => ({ dashboardSlug, response: v })))))
.map((v) => ({ ...v, exprs: v.response.Settings.conditions.map(v => [v.operator.type, v.query.model.expr, v.evaluator.type, v.evaluator.params[0]]) }));
const byBoardAgg = alerts.reduce((byBoard, a) => {
byBoard[a.dashboardSlug] = [...(byBoard[a.dashboardSlug] || []), a.exprs];
return byBoard;
}, {})
console.log(byBoardAgg)
}
)();