【问题标题】:How can I connect my splunk using Splunk SDK Java?如何使用 Splunk SDK Java 连接我的 splunk?
【发布时间】:2018-01-23 15:57:09
【问题描述】:

在尝试使用 url 时,我得到 URI 不能为空

下面是我的代码,

HttpService.setSslSecurityProtocol(SSLSecurityProtocol.SSLv3);
 //Tried the below one also
 //HttpService.setSslSecurityProtocol(SSLSecurityProtocol.TLSv1_2);

      ServiceArgs loginArgs  = new ServiceArgs();
      loginArgs.setUsername("username");
      loginArgs.setPassword("password");
      loginArgs.setHost("my splunk url"); //for eg http://splunkdet.mysite.com:8000/login
      loginArgs.setPort(8000);

      Service service = Service.connect(loginArgs);

      for (Application app: service.getApplications().values()) {
       System.out.println(app.getName());
      }

获取异常“URI 不能为空Service service = Service.connect(loginArgs);

我的代码有什么问题?

【问题讨论】:

标签: java splunk splunk-query splunk-formula splunk-sdk


【解决方案1】:

由于您使用的是 http 而不是 https,因此您不需要使用 HttpService.setSslSecurityProtocol。

而是将方案添加到您的 ServiceArgs 示例:loginArgs.setScheme("http");

并且不要在传递给 setHost 的 URL 中包含 http:// 或 https://。

【讨论】:

    猜你喜欢
    • 2023-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多