Skip to content
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

Adding HolmesGPT plugin #2822

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ Following is an example of some of plugin files in this directory. Other files a
| log_stern.yml | View resource logs using stern | pods | Ctrl-l | |
| log_jq.yml | View resource logs using jq | pods | Ctrl-j | kubectl-plugins/kubectl-jq |
| log_full.yml | get full logs from pod/container | pods/containers | Ctrl-l | |

| ai-incident-investigation.yaml | Run AI investigation on application issues to find the root cause in seconds | all | Shift-h/o | [HolmesGPT](https://github.com/robusta-dev/holmesgpt) |
[1]: https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/#ephemeral-container
[2]: https://github.com/nicolaka/netshoot
61 changes: 61 additions & 0 deletions plugins/ai-incident-investigaton.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
plugins:
# Author: Pavan Gudiwada
# Investigate incidents in your cluster to quickly find the root cause using HolmesGPT
# Requires HolmesGPT to be installed and configured (https://github.com/robusta-dev/holmesgpt) on your system
# Open any K9s view, then:
# Shift+H to run an investigation with default ask command
# Shift+O to customize the question before running an investigation.
holmesgpt:
shortCut: Shift-H
description: Ask HolmesGPT
scopes:
- all
command: bash
background: false
confirm: false
args:
- -c
- |
holmes ask "why is $NAME of $RESOURCE_NAME in -n $NAMESPACE not working as expected"

echo "Press 'q' to exit"
while : ; do
read -n 1 k <&1
if [[ $k = q ]] ; then
break
fi
done
custom-holmesgpt:
shortCut: Shift-Q
description: Custom HolmesGPT Ask
scopes:
- all
command: bash
background: false
confirm: false
args:
- -c
- |
INSTRUCTIONS="# Edit the line below. Lines starting with '#' will be ignored."
DEFAULT_ASK_COMMAND="why is $NAME of $RESOURCE_NAME in -n $NAMESPACE not working as expected"

QUESTION_FILE=$(mktemp)

echo "$INSTRUCTIONS" > "$QUESTION_FILE"
echo "$DEFAULT_ASK_COMMAND" >> "$QUESTION_FILE"

# Open the line in the default text editor
${EDITOR:-nano} "$QUESTION_FILE"

# Read the modified line, ignoring lines starting with '#'
user_input=$(grep -v '^#' "$QUESTION_FILE")

echo running: holmes ask "\"$user_input\""
holmes ask "$user_input"
echo "Press 'q' to exit"
while : ; do
read -n 1 k <&1
if [[ $k = q ]] ; then
break
fi
done