-
Notifications
You must be signed in to change notification settings - Fork 25
feat: Prometheus playbook action #2800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
✅ Deploy Preview for flanksource-demo-stable ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
WalkthroughThis PR extends the playbook system with support for a new "prometheus" action type. Changes include type definitions for the new action category, service-level mapping logic to identify prometheus actions, and UI simplifications for SQL result display formatting. Changes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
725772a to
a63ef65
Compare
❌ Deploy Preview for clerk-saas-ui failed. Why did it fail? →
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/api/types/playbooks.ts (1)
132-132: LGTM! Consider stronger typing for prometheus field.The optional prometheus field follows the established pattern. While
anyis consistent with other action type fields, consider defining a more specific type in a future refactor for better type safety.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/api/services/playbooks.tssrc/api/types/playbooks.tssrc/components/Playbooks/Runs/Actions/PlaybooksActionsResults.tsx
🔇 Additional comments (2)
src/api/types/playbooks.ts (1)
66-66: LGTM!The prometheus action type is correctly added to the type union.
src/components/Playbooks/Runs/Actions/PlaybooksActionsResults.tsx (1)
233-236: The simplified logic is correct. SQL action results have a defined structure where therowsproperty is always an array of objects (as confirmed by test cases). TheformatSqlRowsToMarkdownfunction appropriately handles non-array inputs by returningnull, triggering the fallback "No rows returned". This defensive handling is suitable for validation.
| : actionSpec?.prometheus | ||
| ? "prometheus" | ||
| : actionSpec?.pod | ||
| ? "pod" | ||
| : actionSpec?.logs | ||
| ? "logs" | ||
| : "exec"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
# First, let's look at the context around the change in playbooks.ts
cat -n src/api/services/playbooks.ts | sed -n '150,180p'Repository: flanksource/flanksource-ui
Length of output: 1087
🏁 Script executed:
# Search for action type handling patterns
rg -n 'action\.type|actionType' --type=ts --type=tsx -g '!**/node_modules/**' | head -30Repository: flanksource/flanksource-ui
Length of output: 97
🏁 Script executed:
# Search for existing action type conditionals/switches
rg -n -B2 -A5 'case.*"sql"|case.*"mysql"|case.*"pod"|case.*"logs"|case.*"exec"' --type=ts --type=tsx -g '!**/node_modules/**'Repository: flanksource/flanksource-ui
Length of output: 97
🏁 Script executed:
# Search for prometheus-related code in UI components
rg -n 'prometheus' --type=ts --type=tsx -g '!**/node_modules/**'Repository: flanksource/flanksource-ui
Length of output: 97
🏁 Script executed:
# Look for where action type is used in result preprocessing
rg -n 'preprocessResult|resultPreprocess|formatResult' --type=ts --type=tsx -g '!**/node_modules/**' | head -20Repository: flanksource/flanksource-ui
Length of output: 97
🏁 Script executed:
# Search for action type handling without type restrictions
rg -n 'action\.type|actionType' --type=ts -g '!**/node_modules/**' | head -40Repository: flanksource/flanksource-ui
Length of output: 1636
🏁 Script executed:
# Search for switch/case statements handling action types
rg -n -B2 -A5 'case\s+"(sql|mysql|pod|logs|exec|http|gitops)' --type=ts -g '!**/node_modules/**' | head -50Repository: flanksource/flanksource-ui
Length of output: 2230
🏁 Script executed:
# Look for result preprocessing/formatting functions
rg -n -B3 -A10 'getResultForAction|formatActionResult|handleActionResult' --type=ts -g '!**/node_modules/**'Repository: flanksource/flanksource-ui
Length of output: 52
🏁 Script executed:
# Search for prometheus references specifically
rg -n 'prometheus' --type=ts -g '!**/node_modules/**'Repository: flanksource/flanksource-ui
Length of output: 2729
🏁 Script executed:
# Look at how other action types like 'sql' are handled in UI
rg -n -B5 -A5 '"sql".*:' --type=ts -g '!**/node_modules/**' | head -60Repository: flanksource/flanksource-ui
Length of output: 1030
Add missing "prometheus" case to action result preprocessing in PlaybooksActionsResults.tsx.
The prometheus action type is now returned from playbooks.ts but the result preprocessing switch statement in src/components/Playbooks/Runs/Actions/PlaybooksActionsResults.tsx (line 152) is missing a handler for it. Currently, only "http", "exec", "sql", and a default case exist. Add an explicit "prometheus" case to ensure prometheus action results are properly preprocessed and displayed in the UI, rather than falling through to the default handler.
🤖 Prompt for AI Agents
In src/components/Playbooks/Runs/Actions/PlaybooksActionsResults.tsx around line
152, the switch that preprocesses action results lacks an explicit "prometheus"
case so prometheus results fall through to the default handler; add a
"prometheus" case that mirrors the preprocessing used for other structured
action types (e.g., parse JSON if the action result contains JSON, or otherwise
keep the raw text) and assign the preprocessed result into the same
variable/shape the rest of the component expects so prometheus results are
rendered correctly instead of using the default renderer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine. we don't need special handling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adityathebe, understood! The default handler will be used for prometheus action results.
| if (action.type === "sql") { | ||
| tab.displayContentType = "application/sql"; | ||
| tab.className = "overflow-auto whitespace-pre"; | ||
| tab.className = "whitespace-pre"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
# First, let's find and examine the PlaybooksActionsResults.tsx file
find . -name "PlaybooksActionsResults.tsx" -type fRepository: flanksource/flanksource-ui
Length of output: 137
🏁 Script executed:
# Get the file size first
wc -l ./src/components/Playbooks/Runs/Actions/PlaybooksActionsResults.tsxRepository: flanksource/flanksource-ui
Length of output: 141
🏁 Script executed:
# Read the file to examine the relevant sections
cat -n ./src/components/Playbooks/Runs/Actions/PlaybooksActionsResults.tsx | sed -n '220,240p'Repository: flanksource/flanksource-ui
Length of output: 891
🏁 Script executed:
# Check around line 321 to see the parent container overflow settings
cat -n ./src/components/Playbooks/Runs/Actions/PlaybooksActionsResults.tsx | sed -n '310,335p'Repository: flanksource/flanksource-ui
Length of output: 985
🏁 Script executed:
# Check around lines 390-398 to see CodeBlock component usage
cat -n ./src/components/Playbooks/Runs/Actions/PlaybooksActionsResults.tsx | sed -n '380,405p'Repository: flanksource/flanksource-ui
Length of output: 952
🏁 Script executed:
# Find the CodeBlock component to understand its overflow handling
find . -name "*CodeBlock*" -type f | head -20Repository: flanksource/flanksource-ui
Length of output: 181
🏁 Script executed:
# Read the CodeBlock component to understand overflow handling
cat -n ./src/ui/Code/CodeBlock.tsxRepository: flanksource/flanksource-ui
Length of output: 4282
🏁 Script executed:
# Let's check the renderResult function to see how className is used
cat -n ./src/components/Playbooks/Runs/Actions/PlaybooksActionsResults.tsx | sed -n '370,380p'Repository: flanksource/flanksource-ui
Length of output: 454
🏁 Script executed:
# Check how the className is passed through - look at the full renderTabContent function
cat -n ./src/components/Playbooks/Runs/Actions/PlaybooksActionsResults.tsx | sed -n '363,376p'Repository: flanksource/flanksource-ui
Length of output: 611
🏁 Script executed:
# Find where renderTabContent is called and what className is passed
cat -n ./src/components/Playbooks/Runs/Actions/PlaybooksActionsResults.tsx | sed -n '340,360p'Repository: flanksource/flanksource-ui
Length of output: 801
🏁 Script executed:
# Let's verify what className is actually passed and used - check the default className value parameter
cat -n ./src/components/Playbooks/Runs/Actions/PlaybooksActionsResults.tsx | sed -n '250,280p'Repository: flanksource/flanksource-ui
Length of output: 1128
🏁 Script executed:
# Check the function signature to see what the default className parameter is
cat -n ./src/components/Playbooks/Runs/Actions/PlaybooksActionsResults.tsx | sed -n '125,165p'Repository: flanksource/flanksource-ui
Length of output: 1524
🏁 Script executed:
# Let's see how the className parameter is actually used in CodeBlock
grep -n "className" ./src/ui/Code/CodeBlock.tsx | head -20Repository: flanksource/flanksource-ui
Length of output: 892
🏁 Script executed:
# Let's trace through what happens for SQL syntax highlighting
# Check if there are any tests that show SQL query display behavior
cat -n ./src/ui/Code/__tests__/CodeBlock.unit.test.tsxRepository: flanksource/flanksource-ui
Length of output: 681
🏁 Script executed:
# Let's check the Tabs component to understand how contentClassName is used
find . -name "Tabs.tsx" -o -name "Tabs.jsx" | head -5Repository: flanksource/flanksource-ui
Length of output: 92
🏁 Script executed:
# Read the Tabs component
cat -n ./src/ui/Tabs/Tabs.tsxRepository: flanksource/flanksource-ui
Length of output: 4187
Add horizontal overflow handling for SQL query display.
The tab.className = "whitespace-pre" at line 228 handles whitespace preservation but doesn't add overflow handling. Combined with the parent Tabs container only having overflow-y-auto (line 321), long SQL queries will overflow horizontally without a scrollbar. Consider adding overflow-x-auto or overflow-auto to the tab className for SQL query tabs to ensure long queries are scrollable.
🤖 Prompt for AI Agents
In src/components/Playbooks/Runs/Actions/PlaybooksActionsResults.tsx around line
228, the tab element currently sets className to "whitespace-pre" which
preserves spacing but allows long SQL to overflow horizontally; update the
className to include horizontal overflow handling (e.g., "whitespace-pre
overflow-x-auto" or "whitespace-pre overflow-auto") so long queries become
horizontally scrollable and keep other existing classes intact.
Summary by CodeRabbit
New Features
Improvements
✏️ Tip: You can customize this high-level summary in your review settings.