![]() ![]() By default this is turned off (with a value of "none"). This setting controls the display of a terminal (console window) for debugging. The default value of this setting is true. ![]() If this is not desired, then change the value from true to false. The setting "stopOnEntry":true will cause the debugger to break at the first line of the python program being debugged. Initialize this setting with the arguments to be passed to the python program. Debugging Django, Flask and similar applicationsĭebugging a standard python application is possible by adding the standard configuration settings in the launch.json file as follows: ”, resulting in the use of the python interpreter configured in settings.json.Pausing (breaking into) running programs.The following debugging capabilities are supported: Choose the "Splunk Enterprise: Python Debugger" configurationThe extension supports debugging of a number of types of python applications.Select debug from the Visual Studio Code side bar.Once your Python code is running, perform the following steps in Visual Studio Code: It is necessary to open the folder in order for Visual Studio Code to read the debug configuration created by the supporting add-on.Īfter launching Visual Studio Code, choose Open folder. Step 1 - open your Splunk Enterprise folder in Visual Studio Code 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 |