![]() This configuration is named "Splunk Enterprise: Python Debugger". Visual Studio Code attaches to your modified code using a debug configuration created by the supported add-on. It is recommended to either remove debug code or disable debugging options for production. Important: enabling debugging can delay execution and introduce artificial latency. * Enabling debugging can delay execution and introduce artificial latency. The debugger can be configured for an app by creating a new file with the name nf in the $SPLUNK_HOME/etc/apps//local/ directory. If a connection is not made during this time period, the Python code will continue to run as normal.īreakpoints can be set in Visual Studio Code, or you can use the following line to force a breakpoint anywhere in your Python code: dbg.set_breakpoint()Ĭonfigure debugging with nf (optional) The timeout parameter specifies how long, in seconds, the debug server will wait for Visual Studio Code to connect to the running process. Starts the debug server for your code.This makes is possible for your code to import the necessary modules without copying them to your project. ![]() Appends the path of the supporting add-on to the Python path.Place the following in your Python file you would like to debug: import sys, os In order to debug your Python code, some minor changes need to be made. This will attach Visual Studio Code to the running process in Splunk Enterprise and enable a familiar debug experience. Basically, the code needs to be running in order Visual Studio Code to attach.įinally, start the debugger in Visual Studio Code. If you are debugging a custom alert action, create a search to trigger the action. If you are debugging a custom search command, start a Splunk search and invoke the command. For instance, if you are debugging a modular input, create an instance of the input and enable it. Next, start the component you want to debug on the Splunk Enterprise server. These lines of code enable the Visual Studio Code debugger to connect and debug the Python code running in Splunk Enterprise. The server running Splunk Enterprise requires the Visual Studio Code Supporting Add-on for Splunk.įirst, on the Splunk Enterprise side, you will need to add a few lines of Python code to the component you want to debug. The workstation running Visual Studio Code requires the Visual Studio Code Extension for Splunk. Technically these things can run on the same logical machine however, Visual Studio Code can run on a workstation while Splunk Enterprise runs in a remote data center or even a public cloud.Įach component requires specific software. A machine running Splunk Enterprise software.A machine, like a workstation, running Visual Studio Code. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |