Splunk Java SDK 需要太多时间才能获得结果

发布于 01-09 01:49 字数 1045 浏览 3 评论 0原文

我正在尝试从 Splunk 获取 10 个事件。但是当 UI 返回结果不到 1 秒时,需要超过 40 分钟,

        String token = "token";
    String host = "splunk.mycompany.com";
    Map<String, Object> result = new HashMap<>();
    result.put("host", host);
    result.put("token", token);
    HttpService.setSslSecurityProtocol(SSLSecurityProtocol.TLSv1_2);

    Service service = new Service(result);
    Job job = service.getJobs().create("search index=some_index earliest=-1h |head 10");
    while (!job.isReady()) {
        try {
            Thread.sleep(500); // 500 ms
        } catch (Exception e) {
            // Handle exception here.
        }
    }

    // Read results
    try {
        ResultsReader reader = new ResultsReaderXml(job.getEvents());

        // Iterate over events and print _raw field
        reader.forEach(event -> System.out.println(event.get("_raw")));

    } catch (Exception e) {
        // Handle exception here.
    }

这可能是什么原因?它还可能因超时异常而失败

此代码来自 Splunk java sdk GitHub 页面。由于 NDA,令牌、主机等从真实更改为存根。

I am trying to get 10 events from Splunk. But it takes more than 40 minutes when UI returns results less than 1 sec

        String token = "token";
    String host = "splunk.mycompany.com";
    Map<String, Object> result = new HashMap<>();
    result.put("host", host);
    result.put("token", token);
    HttpService.setSslSecurityProtocol(SSLSecurityProtocol.TLSv1_2);

    Service service = new Service(result);
    Job job = service.getJobs().create("search index=some_index earliest=-1h |head 10");
    while (!job.isReady()) {
        try {
            Thread.sleep(500); // 500 ms
        } catch (Exception e) {
            // Handle exception here.
        }
    }

    // Read results
    try {
        ResultsReader reader = new ResultsReaderXml(job.getEvents());

        // Iterate over events and print _raw field
        reader.forEach(event -> System.out.println(event.get("_raw")));

    } catch (Exception e) {
        // Handle exception here.
    }

What can be a cause of this? Also it may fail with timeout exception

This code is from Splunk java sdk GitHub page. Token, host, etc. are changed from real to stub due to NDA.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

她如夕阳2025-01-16 01:49:48

问题出在楼主身上。与 DevOps 团队合作并解决了这个问题

The problem was with the host. Worked with DevOps team and solved it

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文