{"id":13696655,"url":"https://github.com/splunk/splunk-sdk-java","last_synced_at":"2025-10-11T09:57:11.286Z","repository":{"id":1518645,"uuid":"1777352","full_name":"splunk/splunk-sdk-java","owner":"splunk","description":"Splunk Software Development Kit for Java","archived":false,"fork":false,"pushed_at":"2024-04-25T12:43:15.000Z","size":40616,"stargazers_count":151,"open_issues_count":10,"forks_count":122,"subscribers_count":50,"default_branch":"master","last_synced_at":"2025-05-03T17:43:44.804Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://dev.splunk.com","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/splunk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-05-20T16:36:20.000Z","updated_at":"2025-04-23T23:22:24.000Z","dependencies_parsed_at":"2023-10-03T17:05:12.803Z","dependency_job_id":"3f0391b4-3cdd-4e07-a68e-c671af1b0407","html_url":"https://github.com/splunk/splunk-sdk-java","commit_stats":{"total_commits":1465,"total_committers":48,"mean_commits":"30.520833333333332","dds":0.7986348122866894,"last_synced_commit":"3e1cbf6df6d7b5732af44dd229ed85e924d090ae"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/splunk/splunk-sdk-java","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splunk%2Fsplunk-sdk-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splunk%2Fsplunk-sdk-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splunk%2Fsplunk-sdk-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splunk%2Fsplunk-sdk-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/splunk","download_url":"https://codeload.github.com/splunk/splunk-sdk-java/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splunk%2Fsplunk-sdk-java/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279006747,"owners_count":26084185,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T18:00:44.291Z","updated_at":"2025-10-11T09:57:11.256Z","avatar_url":"https://github.com/splunk.png","language":"Java","readme":"[![Java SDK Test](https://github.com/splunk/splunk-sdk-java/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/splunk/splunk-sdk-java/actions/workflows/test.yml)\n# The Splunk Software Development Kit for Java\n\n#### Version 1.9.5\n\nThe Splunk Software Development Kit (SDK) for Java contains library code and\nexamples designed to enable developers to build applications using Splunk.\n\nSplunk is a search engine and analytic environment that uses a distributed\nmap-reduce architecture to efficiently index, search and process large\ntime-varying data sets.\n\nThe Splunk product is popular with system administrators for aggregation and\nmonitoring of IT machine data, security, compliance and a wide variety of\nother scenarios that share a requirement to efficiently index, search, analyze\nand generate real-time notifications from large volumes of time series data.\n\nThe Splunk developer platform enables developers to take advantage of the\nsame technology used by the Splunk product to build exciting new applications\nthat are enabled by Splunk's unique capabilities.\n\n\n## Getting started with the Splunk SDK for Java\n\nThe Splunk SDK for Java contains library code and examples that show how to\nprogrammatically interact with Splunk for a variety of scenarios including\nsearching, saved searches, data inputs, and many more, along with building\ncomplete applications.\n\nThe information in this Readme provides steps to get going quickly, but for more\nin-depth information be sure to visit the\n[Splunk Developer Portal](http://dev.splunk.com/view/java-sdk/SP-CAAAECN).\n\n### Requirements\n\nHere's what you need to get going with the Splunk SDK for Java.\n\n#### Splunk\n\nIf you haven't already installed Splunk, download it\n[here](http://www.splunk.com/download). For more about installing and running\nSplunk and system requirements, see\n[Installing \u0026 Running Splunk](http://dev.splunk.com/view/SP-CAAADRV). The Splunk SDK for Java has been tested with Splunk Enterprise 9.0 and 8.2.\n\n#### Splunk SDK for Java\n\n[Get the Splunk SDK for Java](http://dev.splunk.com/view/SP-CAAAECN)\u0026mdash;download the SDK as a ZIP, then extract the files and build the SDK. Or, download the JAR and add it to your project.\n\nIf you want to contribute to the SDK, clone the repository from [GitHub](https://github.com/splunk/splunk-sdk-java).\n\n#### Java using Maven\n\nYou can use [Apache Maven](http://maven.apache.org/) to build your Splunk SDK for Java projects. With a few updates to your project's `pom.xml` file, it will retrieve all necessary dependencies and seamlessly build your project.\n\nTo add the Splunk SDK for Java `.JAR` file as a dependency:\n\n1. Add the repository to your project's `pom.xml` file:\n\n```xml\n\u003crepositories\u003e\n  ...\n  \u003crepository\u003e\n    \u003cid\u003esplunk-artifactory\u003c/id\u003e\n    \u003cname\u003eSplunk Releases\u003c/name\u003e\n    \u003curl\u003ehttp://splunk.jfrog.io/splunk/ext-releases-local\u003c/url\u003e\n  \u003c/repository\u003e\n\u003c/repositories\u003e\n```\n\n2. Add the dependency to the `pom.xml` file:\n\n```xml\n\u003cdependencies\u003e\n  ...\n  \u003cdependency\u003e\n    \u003cgroupId\u003ecom.splunk\u003c/groupId\u003e\n    \u003cartifactId\u003esplunk\u003c/artifactId\u003e\n    \u003cversion\u003e1.9.5\u003c/version\u003e\n  \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\nBe sure to update the version number to match the version of the Splunk SDK for Java that you are using.\n\n\u003e Note: You can make similar changes to use [Gradle](http://www.gradle.org/) as well.\n\n### Building the SDK and documentation\n\nTo build the SDK, open a command prompt in the **/splunk-sdk-java**\ndirectory and enter:\n\n    mvn\n\nor\n\n    mvn package\n\nThis command builds all of the .class and .jar files. If you just want to build\nthe .class files, enter:\n\n    mvn compile\n\nTo remove all build artifacts from the repository, enter:\n\n    mvn clean\n\nTo build the documentation for the SDK, it is being automatically generated with \u003cb\u003emvn package\u003c/b\u003e, otherwise enter:\n\n    cd splunk\n    mvn javadoc:javadoc\n\n### Usage\n#### Login using username and password\n```java\nimport com.splunk.Service;\nimport com.splunk.ServiceArgs;\n\n/**\n * Login using username and password\n */\npublic class SplunkLogin {\n\n    static Service service = null;\n    public static void main(String args[]) {\n        ServiceArgs loginArgs = new ServiceArgs();\n        loginArgs.setPort(8089);\n        loginArgs.setHost(\"localhost\");\n        loginArgs.setScheme(\"https\");\n        loginArgs.setUsername(\"USERNAME\"); // Use your username\n        loginArgs.setPassword(\"PASSWORD\"); // Use your password\n\n        // Initialize the SDK client\n        service = Service.connect(loginArgs);\n    }\n}\n```\n\n#### Login using Session Token\n```java\nimport com.splunk.Service;\nimport com.splunk.ServiceArgs;\n\n/**\n * Login using Session token\n */\npublic class SplunkLogin {\n\n    static Service service = null;\n    /**\n     * Session Token.\n     * Actual token length would be longer than this token length.\n     */\n    static String token = \"1k_Ostpl6NBe4iVQ5d6I3Ohla_U5\";\n    \n    public static void main(String args[]) {\n        ServiceArgs loginArgs = new ServiceArgs();\n        loginArgs.setPort(8089);\n        loginArgs.setHost(\"localhost\");\n        loginArgs.setScheme(\"https\");\n        loginArgs.setToken(String.format(\"Splunk %s\", token));\n\n        // Initialize the SDK client\n        service = Service.connect(loginArgs);\n    }\n}\n```\n* Login using username and password will create Session token internally.\n* Login using Credentials (username \u0026 password) OR directly using Session token are similar.\n* In above two approaches, there is one limitation that expiration time of Session token cannot be extended. User has to re-login every time when token expires.\n* To overcome this limitation, **Authentication** token is used instead of Session token.\n* In **Authentication** token, user has a provision to set token expiration time. Splunk allows user to set relative/absolute time for token expiration.\n* In other words, **Authentication** token is configurable whereas Session token cannot be configured.\n\n#### Login using Authentication Token (RECOMMENDED)\n```java\nimport com.splunk.Service;\nimport com.splunk.ServiceArgs;\n\n/**\n * Login using Authentication token\n */\npublic class SplunkLogin {\n\n    static Service service = null;\n    /**\n     * Authentication Token.\n     * Actual token length would be longer than this token length.\n     */\n    static String token = \"1k_Ostpl6NBe4iVQ5d6I3Ohla_U5\";\n    \n    public static void main(String args[]) {\n        ServiceArgs loginArgs = new ServiceArgs();\n        loginArgs.setPort(8089);\n        loginArgs.setHost(\"localhost\");\n        loginArgs.setScheme(\"https\");\n        loginArgs.setToken(String.format(\"Bearer %s\", token));\n\n        // Initialize the SDK client\n        service = Service.connect(loginArgs);\n    }\n}\n```\n\n#### Example of running a simple search by first creating the search job\n```java\nimport com.splunk.Job;\nimport com.splunk.ResultsReader;\nimport com.splunk.ResultsReaderXml;\nimport com.splunk.Service;\nimport com.splunk.ServiceArgs;\n\n/**\n * Logged in using Authentication token.\n * Assuming that authentication token is already created from Splunk web.\n * Create Job using search creation.\n * Read results and print _raw fields\n */\npublic class SearchExample {\n\n    static Service service = null;\n\n    /**\n     * Authentication Token.\n     * Actual token length would be longer than this token length.\n     */\n    static String token = \"1k_Ostpl6NBe4iVQ5d6I3Ohla_U5\";\n    \n    public static void main(String args[]) {\n\n        ServiceArgs loginArgs = new ServiceArgs();\n        loginArgs.setPort(8089);\n        loginArgs.setHost(\"localhost\");\n        loginArgs.setScheme(\"https\");\n        loginArgs.setToken(String.format(\"Bearer %s\", token));\n\n        // Initialize the SDK client\n        service = Service.connect(loginArgs);\n\n        // Run a simple search by first creating the search job\n        Job job = service.getJobs().create(\"search index=_internal | head 10\");\n\n        // Waiting for search results to be ready\n        while (!job.isReady()) {\n            try {\n                Thread.sleep(500); // 500 ms\n            } catch (Exception e) {\n                // Handle exception here.\n            }\n        }\n\n        // Read results\n        try {\n            ResultsReader reader = new ResultsReaderXml(job.getEvents());\n\n            // Iterate over events and print _raw field\n            reader.forEach(event -\u003e System.out.println(event.get(\"_raw\")));\n\n        } catch (Exception e) {\n            // Handle exception here.\n        }\n    }\n}\n```\n\nFor more information on authentication using tokens, please visit [Splunk Docs](https://docs.splunk.com/Documentation/Splunk/latest/Security/Setupauthenticationwithtokens).\n\n### Unit tests\n\nThe Splunk SDK for Java includes several unit tests that are run at\nthe command line.\n\n#### Set up the .splunkrc file\n\nTo connect to Splunk, many of the SDK examples and unit tests take command-line\narguments that specify values for the host, port, and login credentials for\nSplunk. For convenience during development, you can store these arguments as\nkey-value pairs in a text file named **.splunkrc**. Then, the SDK examples and\nunit tests use the values from the **.splunkrc** file when you don't specify\nthem.\n\nTo use this convenience file, create a text file with the following format:\n\n    # Splunk host (default: localhost)\n    host=localhost\n    # Splunk admin port (default: 8089)\n    port=8089\n    # Splunk username\n    username=admin\n    # Splunk password\n    password=changeme\n    # Access scheme (default: https)\n    scheme=https\n    # Your version of Splunk (default: 5.0)\n    version=5.0\n\nSave the file as **.splunkrc** in the current user's home directory.\n\n*   For example, on Mac OS X, save the file as:\n\n        ~/.splunkrc\n\n*   On Windows, save the file as:\n\n        C:\\Users\\currentusername\\.splunkrc\n\n    You might get errors in Windows when you try to name the file because\n    \".splunkrc\" looks like a nameless file with an extension. You can use\n    the command line to create this file\u0026mdash;go to the\n    **C:\\Users\\currentusername** directory and enter the following command:\n\n        Notepad.exe .splunkrc\n\n    Click **Yes**, then continue creating the file.\n\n**Note**: Storing login credentials in the **.splunkrc** file is only for\nconvenience during development. This file isn't part of the Splunk platform and\nshouldn't be used for storing user credentials for production. And, if you're\nat all concerned about the security of your credentials, just enter them at\nthe command line rather than saving them in this file.\n\n#### Run unit tests\n\nTo run the SDK unit tests, open a command prompt in the **/splunk-sdk-java**\ndirectory and enter:\n\n    mvn test\n\nYou can also run specific test classes by passing the class to the -Dtest=\noption, e.g.,\n\n    mvn test -Dtest=AtomFeedTest\n\nThe maven configuration can also produce an HTML report of all the tests automatically when **mvn package / mvn test** are executed.\nAlternate way to generate report is using below command under splunk directory:\n\n    mvn jacoco:report\n\nThe report will be written in **/splunk-sdk-java/splunk/target/site/surefire-report.html**.\n\nIt's also possible to run the units within Java IDEs such as IntelliJ and\nEclipse. For example, to open the Splunk SDK for Java project in Eclipse:\n\n1. Click **File**, **Import**.\n2. Click **General**, **Existing Projects into Workspace**, then click\n   **Next**.\n3. In **Select root directory**, type the path to the Splunk SDK for Java root\n   directory (or click **Browse** to locate it), then click **Finish**.\n\n#### Measure code coverage\n\nMeasurement of code coverage is generated along with \u003cb\u003emvn package / mvn test\u003c/b\u003e:\n\n    mvn jacoco:report\n\nTo view the coverage report, open\n**/splunk-sdk-java/splunk/target/test-report/index.html** in your web browser.\n\n## Repository\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cb\u003e/argsGenerator\u003c/b\u003e\u003c/td\u003e\n\u003ctd\u003eThis directory is created by the build and contains intermediate build\nouputs\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e\u003cb\u003e/splunk/target\u003c/b\u003e\u003c/td\u003e\n\u003ctd\u003eThis directory is created by the build and contains intermediate build\nouputs\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e\u003cb\u003e/splunk/src/main\u003c/b\u003e\u003c/td\u003e\n\u003ctd\u003eSource for \u003ccode\u003ecom.splunk\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e\u003cb\u003e/splunk/src/test\u003c/b\u003e\u003c/td\u003e\n\u003ctd\u003eSource for unit tests\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003c/table\u003e\n\n### Changelog\n\nThe **CHANGELOG.md** file in the root of the repository contains a description\nof changes for each version of the SDK. You can also find it online at\n[https://github.com/splunk/splunk-sdk-java/blob/master/CHANGELOG.md](https://github.com/splunk/splunk-sdk-java/blob/master/CHANGELOG.md).\n\n### Branches\n\nThe **master** branch always represents a stable and released version of the SDK.\nYou can read more about our branching model on our Wiki at\n[https://github.com/splunk/splunk-sdk-java/wiki/Branching-Model](https://github.com/splunk/splunk-sdk-java/wiki/Branching-Model).\n\n## Documentation and resources\n\nIf you need to know more:\n\n* For all things developer with Splunk, your main resource is the [Splunk Developer Portal](http://dev.splunk.com).\n\n* For conceptual and how-to documentation, see the [Overview of the Splunk SDK for Java](http://dev.splunk.com/view/SP-CAAAECN).\n\n* For API reference documentation, see the [Splunk SDK for Java Reference](http://docs.splunk.com/Documentation/JavaSDK).\n\n* For more about the Splunk REST API, see the [REST API Reference](http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI).\n\n* For more about about Splunk in general, see [Splunk\u003eDocs](http://docs.splunk.com/Documentation/Splunk).\n\n* For more about this SDK's repository, see our [GitHub Wiki](https://github.com/splunk/splunk-sdk-java/wiki/).\n\n## Community\n\nStay connected with other developers building on Splunk.\n\n\u003ctable\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e\u003cb\u003eEmail\u003c/b\u003e\u003c/td\u003e\n\u003ctd\u003edevinfo@splunk.com\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e\u003cb\u003eIssues\u003c/b\u003e\n\u003ctd\u003e\u003cspan\u003ehttps://github.com/splunk/splunk-sdk-java/issues/\u003c/span\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e\u003cb\u003eAnswers\u003c/b\u003e\n\u003ctd\u003e\u003cspan\u003ehttp://splunk-base.splunk.com/tags/java/\u003c/span\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e\u003cb\u003eBlog\u003c/b\u003e\n\u003ctd\u003e\u003cspan\u003ehttp://blogs.splunk.com/dev/\u003c/span\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e\u003cb\u003eTwitter\u003c/b\u003e\n\u003ctd\u003e@splunkdev\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003c/table\u003e\n\n\n### How to contribute\n\nIf you would like to contribute to the SDK, go here for more information:\n\n* [Splunk and open source](http://dev.splunk.com/view/opensource/SP-CAAAEDM)\n\n* [Individual contributions](http://dev.splunk.com/goto/individualcontributions)\n\n* [Company contributions](http://dev.splunk.com/view/companycontributions/SP-CAAAEDR)\n\n### Support\n\n1. You will be granted support if you or your company are already covered\n   under an existing maintenance/support agreement. Send an email to\n   _support@splunk.com_ and include \"Splunk SDK for Java\" in the subject line.\n\n2. If you are not covered under an existing maintenance/support agreement, you\n   can find help through the broader community at:\n\n   \u003cul\u003e\n   \u003cli\u003e\u003ca href='http://splunk-base.splunk.com/answers/'\u003eSplunk Answers\u003c/a\u003e (use\n    the \u003cb\u003esdk\u003c/b\u003e, \u003cb\u003ejava\u003c/b\u003e, \u003cb\u003epython\u003c/b\u003e, and \u003cb\u003ejavascript\u003c/b\u003e tags to\n    identify your questions)\u003c/li\u003e\n   \u003cli\u003e\u003ca href='http://groups.google.com/group/splunkdev'\u003eSplunkdev Google\n    Group\u003c/a\u003e\u003c/li\u003e\n   \u003c/ul\u003e\n3. Splunk will NOT provide support for SDKs if the core library (the\n   code in the \u003cb\u003esplunk\u003c/b\u003e directory) has been modified. If you modify an SDK\n   and want support, you can find help through the broader community and Splunk\n   answers (see above). We would also like to know why you modified the core\n   library\u0026mdash;please send feedback to _devinfo@splunk.com_.\n4. File any issues on [GitHub](https://github.com/splunk/splunk-sdk-java/issues).\n\n\n### Contact Us\n\nYou can reach the Developer Platform team at _devinfo@splunk.com_.\n\n## License\n\nThe Splunk Java Software Development Kit is licensed under the Apache\nLicense 2.0. Details can be found in the LICENSE file.\n","funding_links":[],"categories":["Java"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsplunk%2Fsplunk-sdk-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsplunk%2Fsplunk-sdk-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsplunk%2Fsplunk-sdk-java/lists"}