icon/x Created with Sketch.

Splunk Cookie Policy

We use our own and third-party cookies to provide you with a great online experience. We also use these cookies to improve our products and services, support our marketing campaigns, and advertise to you on our website and other websites. Some cookies may continue to collect information after you have left our website. Learn more (including how to update your settings) here.
Accept Cookie Policy

Accept License Agreements

This app is provided by a third party and your right to use the app is in accordance with the license provided by that third-party licensor. Splunk is not responsible for any third-party apps and does not provide any warranty or support. If you have any questions, complaints or claims with respect to this app, please contact the licensor directly.

Thank You

Downloading Microsoft Visual Studio Code Supporting Add-on for Splunk
SHA256 checksum (microsoft-visual-studio-code-supporting-add-on-for-splunk_012.tgz) 4d09579241aab20975076bd8de3fd80f4eaf571c7bf0577bdc16118686b4cd16
To install your download
For instructions specific to your download, click the Details tab after closing this window.

Flag As Inappropriate

Microsoft Visual Studio Code Supporting Add-on for Splunk

Splunk AppInspect Passed
Admins: Please read about Splunk Enterprise 8.0 and the Python 2.7 end-of-life changes and impact on apps and upgradeshere.
Overview
Details
The Microsoft Visual Studio Code Supporting Add-on for Splunk provides support for debugging user Python code contained in apps, add-ons, custom search commands, custom REST handlers, modular visualizations, or any user Python code run within Splunk Enterprise.

Microsoft Visual Studio Code Supporting Add-on for Splunk

The Microsoft Visual Studio Code Supporting Add-on for Splunk provides support for debugging user Python code contained in apps, add-ons, custom search commands, custom REST handlers, modular visualizations, or any user Python code run within Splunk Enterprise. The supporting add-on can automatically create a debug configuration for your Splunk Enterprise project and provides helper methods for the Visual Studio Code Python Debug Adapter.

Requirements

Microsoft Visual Studio Code - a free cross-platform code editor from Microsoft
Splunk Enterprise
Microsoft Visual Studio Code Supporting Add-on for Splunk (this add-on)
Visual Studio Code Splunk extension

For more information about the Visual Studio Code Splunk extension, refer to the Wiki.

Modifying your code

In order to debug your Python code, some minor changes need to be made. Place the following in your Python file you would like to debug:

import sys, os
sys.path.append(os.path.join(os.environ['SPLUNK_HOME'],'etc','apps','SA-VSCode','bin'))
import splunk_debug as dbg
dbg.enable_debugging(timeout=25)

The above code does 2 main things:

  1. Appends the path of the supporting add-on to the Python path. This makes is possible for your code to import the necessary modules without copying them to your project.
  2. Starts the debug server for your code. The timeout parameter specifies how long, in seconds, the debug server will wait for Visual Studio Code to connect to the running process. If a connection is not made during this time period, the Python code will continue to run as normal.

Setting a break point (optional)

Breakpoints 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()

Configure debugging with debug.conf (optional)

The debugger can be configured for an app by creating a new file with the name debug.conf in the $SPLUNK_HOME/etc/apps/[app_directory]/local/ directory.

debug.conf

[debug]
enabled = <boolean>
* Set whether an app allows debugging
* Enabling debugging can delay execution and introduce artificial latency.  It is recommended to either remove debug code or disable debugging options for production.
* Default: true

Important: enabling debugging can delay execution and introduce artificial latency. It is recommended to either remove debug code or disable debugging options for production.

Starting the Visual Studio Code Debugger

Visual Studio Code attaches to your modified code using a debug configuration created by the supported add-on. This configuration is named "Splunk Enterprise: Python Debugger".

Step 1 - open your Splunk Enterprise folder 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.
After launching Visual Studio Code, choose Open folder...

Step 2 – start the debugger

Once your Python code is running, perform the following steps in Visual Studio Code:

  1. Select debug from the Visual Studio Code side bar
  2. Choose the "Splunk Enterprise: Python Debugger" configuration
  3. Click the start debugging button

Release Notes

Version 0.1.2
Jan. 11, 2020

Added support for a debug.conf file to control the debugger. See the details page for more information.

12
Installs
59
Downloads
Share Subscribe LOGIN TO DOWNLOAD

Subscribe Share

AppInspect Tooling

Splunk AppInspect evaluates Splunk apps against a set of Splunk-defined criteria to assess the validity and security of an app package and components.

Are you a developer?

As a Splunkbase app developer, you will have access to all Splunk development resources and receive a 10GB license to build an app that will help solve use cases for customers all over the world. Splunkbase has 1000+ apps and add-ons from Splunk, our partners and our community. Find an app or add-on for most any data source and user need, or simply create your own with help from our developer portal.

Follow Us:
© 2005-2020 Splunk Inc. All rights reserved.
Splunk®, Splunk>®, Listen to Your Data®, The Engine for Machine Data®, Hunk®, Splunk Cloud™, Splunk Light™, SPL™ and Splunk MINT™ are trademarks and registered trademarks of Splunk Inc. in the United States and other countries. All other brand names, product names, or trademarks belong to their respective owners.