Splunk Dev

Import cProfile to use in Custom generating command

srinidh
New Member

I have to use cProfile for the profiling details for my custom generating command. I could not install cProfile in the Splunk python. SO could anybody help if they know how to install python lib in splunk and use it for custom command

0 Karma

livehybrid
SplunkTrust
SplunkTrust

Hi @srinidh 

I believe cProfile is included in the standard python distribution with Splunk Enterprise as 'profile.py' in /opt/splunk/lib/python3.9 (and python3.7)/profile.py

Try importing it using 

import profile as cProfile

to see if this resolves for you and allows you to use it as you would expect?

Please let me know how you get on and consider adding karma to this or any other answer if it has helped.
Regards

Will

0 Karma

srinidh
New Member

using 

import profile as cProfile

we can't use the cProfiles enable and disable as the profile module doesn't support. I require the profiling for a generating command so using this profile I had to configure profiling two times, one for profiling - Convert generator to list for profiling and one for yielding generator objects to Splunk. So any idea? 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Include the library in the bin directory of the app that contains your custom command.

---
If this reply helps you, Karma would be appreciated.

srinidh
New Member

I was getting 

ModuleNotFoundError: No module named '_lsprof' if I do that.
How to include the cPython modules like these in Splunk 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

It's been a while since I've done this, but it may help to put the library in the app's bin/lib directory.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Introduction to Splunk AI

How are you using AI in Splunk? Whether you see AI as a threat or opportunity, AI is here to stay. Lucky for ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Maximizing the Value of Splunk ES 8.x

Splunk Enterprise Security (ES) continues to be a leader in the Gartner Magic Quadrant, reflecting its pivotal ...