Skip to content

Commit 888d28f

Browse files
tmshortclaude
andcommitted
🐛 Fix Prometheus alert parsing to include level-3 headers
The sed pattern '/^##/' was incorrectly matching both level-2 (##) and level-3 (###) markdown headers, causing it to stop at "### Firing Alerts" instead of continuing to "## Performance". This resulted in empty alert sections even when alerts were present. Changed pattern to '/^## /' (with space) to match only level-2 headers. **Impact:** - analyze-profiles.sh now correctly extracts and displays all alerts - compare-profiles.sh now correctly detects alerts in both test runs **Example:** Before: "No Prometheus alerts detected" (incorrect) After: Shows both pending alerts: - operator-controller-memory-growth: 132.4kB/sec - operator-controller-memory-usage: 107.9MB 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent bdd64ec commit 888d28f

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

hack/tools/memory-profiling/analyze-profiles.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,9 @@ if [ -f "${OUTPUT_DIR}/e2e-summary.md" ]; then
261261
EOF
262262

263263
# Extract the Alerts section from the markdown file
264-
# Look for "## Alerts" section and extract until next ## section or end
265-
ALERTS_SECTION=$(sed -n '/^## Alerts/,/^##/p' "${OUTPUT_DIR}/e2e-summary.md" | sed '$d' | tail -n +2)
264+
# Look for "## Alerts" section and extract until next ## (level-2 header) section
265+
# Note: Use '/^## /' with space to match level-2 headers only, not level-3 (###)
266+
ALERTS_SECTION=$(sed -n '/^## Alerts/,/^## /p' "${OUTPUT_DIR}/e2e-summary.md" | sed '$d' | tail -n +2)
266267

267268
if [ -n "${ALERTS_SECTION}" ] && [ "${ALERTS_SECTION}" != "None." ]; then
268269
cat >> "${REPORT_FILE}" << EOF

hack/tools/memory-profiling/compare-profiles.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ EOF
289289
if [ -f "${TEST1_DIR}/e2e-summary.md" ] || [ -f "${TEST2_DIR}/e2e-summary.md" ]; then
290290
# Test 1 alerts
291291
if [ -f "${TEST1_DIR}/e2e-summary.md" ]; then
292-
ALERTS1_SECTION=$(sed -n '/^## Alerts/,/^##/p' "${TEST1_DIR}/e2e-summary.md" | sed '$d' | tail -n +2)
292+
# Use '/^## /' with space to match level-2 headers only, not level-3 (###)
293+
ALERTS1_SECTION=$(sed -n '/^## Alerts/,/^## /p' "${TEST1_DIR}/e2e-summary.md" | sed '$d' | tail -n +2)
293294
if [ -n "${ALERTS1_SECTION}" ] && [ "${ALERTS1_SECTION}" != "None." ]; then
294295
ALERTS1="Present"
295296
else
@@ -301,7 +302,8 @@ if [ -f "${TEST1_DIR}/e2e-summary.md" ] || [ -f "${TEST2_DIR}/e2e-summary.md" ];
301302

302303
# Test 2 alerts
303304
if [ -f "${TEST2_DIR}/e2e-summary.md" ]; then
304-
ALERTS2_SECTION=$(sed -n '/^## Alerts/,/^##/p' "${TEST2_DIR}/e2e-summary.md" | sed '$d' | tail -n +2)
305+
# Use '/^## /' with space to match level-2 headers only, not level-3 (###)
306+
ALERTS2_SECTION=$(sed -n '/^## Alerts/,/^## /p' "${TEST2_DIR}/e2e-summary.md" | sed '$d' | tail -n +2)
305307
if [ -n "${ALERTS2_SECTION}" ] && [ "${ALERTS2_SECTION}" != "None." ]; then
306308
ALERTS2="Present"
307309
else

0 commit comments

Comments
 (0)