diff --git a/docs/changelog.d/+services-check-show-all-alerts.bugfix.md b/docs/changelog.d/+services-check-show-all-alerts.bugfix.md new file mode 100644 index 0000000..221748a --- /dev/null +++ b/docs/changelog.d/+services-check-show-all-alerts.bugfix.md @@ -0,0 +1 @@ +Fix services-check to display all firing alerts for a given alert name, not just the first one. diff --git a/mise-tasks/services-check b/mise-tasks/services-check index 454b769..1e90f93 100755 --- a/mise-tasks/services-check +++ b/mise-tasks/services-check @@ -100,16 +100,17 @@ for a in alerts: if [ -z "$firing" ]; then echo -e "${GREEN}OK${NC}" else - local summary runbook - summary=$(echo "$firing" | head -1 | cut -d'|' -f1) - runbook=$(echo "$firing" | head -1 | cut -d'|' -f2) echo -e "${RED}FIRING${NC}" - if [ -n "$summary" ]; then - echo -e " $summary" - fi - if [ -n "$runbook" ]; then - echo -e " Runbook: $runbook" - fi + local runbook_printed=false + while IFS='|' read -r summary runbook; do + if [ -n "$summary" ]; then + echo -e " $summary" + fi + if [ -n "$runbook" ] && [ "$runbook_printed" = false ]; then + echo -e " Runbook: $runbook" + runbook_printed=true + fi + done <<< "$firing" FAILED=1 fi }