-
Notifications
You must be signed in to change notification settings - Fork 87
feat: Add Pyroscope tools #170
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
I tried to copy the e2e tests that Loki uses, but it was challenging predicting the order in which the LLM would call the tools. When testing |
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.
Thanks Bryan, this is looking great. A couple of things:
- yeah the e2e tests can be a bit fiddly, we can add those later on no problem. Would you be able to add some integration tests instead? See
tools/loki_test.go
for an example. - could you update the README to include the new tools in the table & list of features?
Otherwise this LGTM!
Thanks for the PR @bryanhuhta! If you'd like, feel free to push a commit with your e2e tests and I'd be happy to help troubleshoot. Alternatively, we could tackle the e2e testing in a separate PR since the integration tests should be enough for this one. |
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.
Found a typo, otherwise I think this look great as a first pass.
I do think fetch_pyroscope_profile
probably need a bit more examples in the description before it can be super useful, at least in my limited testing a lot of prompting is need to get an actual profile result
tools/pyroscope.go
Outdated
} | ||
|
||
var ListPyroscopeProfileTypes = mcpgrafana.MustTool( | ||
"list_pyroscope_label_values", |
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.
The name is incorrect 😅
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.
This prompted me to open an issue with mcp-go mark3labs/mcp-go#390
right now it silently overrides the tools if two share the same name
@edwardcqian We have a pretty effective prompt that powers our Flame Graph AI feature in Profiles Drilldown which I considered reusing (at least in spirit, if not exactly). However, I ultimately decided to try keep it more open ended to allow users to guide themselves along the exploration of the profile, rather than being forced down a prescribed path. I'm happy to tweak the prompt to improve the experience, but I would like to do it in a way that leaves most of the prompting up to the user. What are some problems you faced when you tested it out? Was it difficult to get the LLM to actually fetch a profile? Or did you have challenges getting it to perform an analysis on the profile? |
I had some trouble getting it to query profiles. It's not quite doing the data source discovery -> label search + value -> profile type -> query flow without being asked. Maybe LLMs are a little more aware of metrics querying than profiles? 🤔 |
Can you share some sample prompts? I had a similar experience if I used prompts like
Usually the LLM would default to analyzing Prometheus CPU metrics (not usually helpful). But if I was a bit more prescriptive like
I could reliably get various models to fetch a CPU profile and analyze it. |
I'm testing with ops, so it's a little bit more challenging than a test environment. I'm asking "Analyze memory usage in the "service" service in "cluster" cluster, "namespace" namespace (please use pyroscope if possible)." (forgot this repo is public, removing internal specific terms 😅) What helped is specifically call out the other tools in
With this it ended up actually getting something. |
@edwardcqian Can you take another peek? In 7e56cb5 I updated the prompt to include your changes. |
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.
Lgtm, we can add e2e test in another PR
Adds basic tools to interact with Pyroscope data:
ListPyroscopeLabelNames
- used to find which label names are availableListPyroscopeLabelValues
- used to find which label values are available for a label nameListPyroscopeProfileTypes
- used to discover which profile types are availableFetchPyroscopeProfile
- the meat and potatoes, can fetch a profile in DOT format for analysis (akin to Flame Graph AI in Profiles Drilldown)Demos:
demo.mov
demo.mp4
To do:
cc @Rperry2174 @petethepig