简体   繁体   English

如何使用 Splunk SDK Java 连接我的 splunk?

[英]How can I connect my splunk using Splunk SDK Java?

I am getting Getting URI can't be null when trying with the url尝试使用 url 时,我得到 URI 不能为空

Below is my code,下面是我的代码,

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());
      }

Getting Exception " URI can't be null " Service service = Service.connect(loginArgs);获取异常“ URI 不能为空Service service = Service.connect(loginArgs);

What is wrong with my code?我的代码有什么问题?

Since your using http and not https you don't need to use HttpService.setSslSecurityProtocol.由于您使用的是 http 而不是 https,因此您不需要使用 HttpService.setSslSecurityProtocol。

Instead add the scheme to your ServiceArgs example : loginArgs.setScheme("http");而是将方案添加到您的 ServiceArgs 示例中: loginArgs.setScheme("http");

And don't include http:// or https:// in the URL you pass to setHost.并且不要在传递给 setHost 的 URL 中包含 http:// 或 https://。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM