Skip to content

Commit

Permalink
holmes to use grep logs more by tweaking instruction, move to grep -E (
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheeproid authored Nov 27, 2024
1 parent 743e62c commit 3d88e0d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions holmes/plugins/prompts/_general_instructions.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ If investigating Kubernetes problems:
* run as many kubectl commands as you need to gather more information, then respond.
* if possible, do so repeatedly on different Kubernetes objects.
* for example, for deployments first run kubectl on the deployment then a replicaset inside it, then a pod inside that.
* if the user wants to find a specific term in a pod's logs, use kubectl_logs_grep
* use both kubectl_previous_logs and kubectl_logs when reading logs. Treat the output of both as a single unified logs stream
* when investigating a pod that crashed or application errors, always run kubectl_describe and fetch the logs
* do not give an answer like "The pod is pending" as that doesn't state why the pod is pending and how to fix it.
Expand Down
5 changes: 2 additions & 3 deletions holmes/plugins/toolsets/kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ toolsets:
description: "Run `kubectl logs` on a single container within a Kubernetes pod. This is to get the logs of a specific container in a multi-container pod."
command: "kubectl logs {{pod_name}} -c {{container_name}} -n {{ namespace }} "


- name: "kubectl_logs_grep"
description: "Search for a specific term in the logs of a single Kubernetes pod. Only provide a pod name, not a deployment or other resource."
command: "kubectl logs {{ name }} -n {{ namespace }} | grep {{ search_term }}"
description: "Search for a specific pattern(s) in a log by running `kubectl logs` and 'grep -E' on a single Kubernetes pod. Handles long logs better is output is not truncated."
command: "kubectl logs {{ pod_name }} -n {{ namespace }} | grep -E {{ extended_regexp_pattern }}"

- name: "kubectl_events"
description: "Retrieve the events for a specific Kubernetes resource. `resource_type` can be any kubernetes resource type: 'pod', 'service', 'deployment, 'job'', 'node', etc."
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"toolset_name":"kubernetes/core","tool_name":"kubectl_find_resource","match_params":{"kind":"pod","keyword":"customer-orders-67889fd856-k94k7"}}
default customer-orders-67889fd856-k94k7 1/1 Running 0 16m 10.244.0.11 kind-control-plane <none> <none> app=robusta-runner,pod-template-hash=746d848db9,robustaComponent=runner
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{"toolset_name":"kubernetes/core","tool_name":"kubectl_logs_grep","match_params":{"name":"customer-orders-67889fd856-k94k7","namespace":"default","search_term":"render time"}}
Command `kubectl logs customer-orders-67889fd856-k94k7 -n default | grep 'render time'` failed with return code 1
{"toolset_name":"kubernetes/core","tool_name":"kubectl_logs_grep","match_params":{"pod_name":"customer-orders-67889fd856-k94k7","namespace":"default","extended_regexp_pattern":"render time"}}
Command `kubectl logs customer-orders-67889fd856-k94k7 -n default | grep -E 'render time'` failed with return code 1
stdout:

stderr:
Defaulted container "curl-sidecar" out of: curl-sidecar, fastapi-app
error: error from server (NotFound): pods "customer-orders-67889fd856-k94k7" not found in namespace "default"

0 comments on commit 3d88e0d

Please sign in to comment.