如何使用 Python 在 Splunk API 中为一次性搜索设置 TTL?

How do I set TTL for oneshot search in Splunk API using Python?

我间歇性地从 Splunk API 返回以下错误(大约 40% 的时间搜索按预期工作):

HTTP 503 Service Unavailable -- Search not executed: This search could not be dispatched because the role-based disk usage quota of search artifacts for user "[REDACTED]" has been reached (usage=1067MB, quota=1000MB). Use the [[/app/search/job_manager|Job Manager]] to delete some of your search artifacts, or ask your Splunk administrator to increase the disk quota of search artifacts for your role in authorize.conf., usage=1067MB, quota=1000MB, user=[REDACTED], concurrency_category="historical", concurrency_context="user_instance-wide"

在 splunk api 中搜索的默认 ttl 是 10 分钟(至少对我的公司而言)。我被告知我需要降低我的搜索的 TTL(这是大量的)并且我将停止 运行 out of space。我没有管理员访问权限,因此无法即时增加我的 space 或清除 space(据我所知)。我可以找到有关如何使用保存的搜索来降低 TTL 的代码,但我使用的是一次性搜索。我转行不合理

如何降低一次性搜索的 ttl? 这是我现在拥有的似乎没有降低 TTL 的东西:

#setup splunk connection
service = client.connect(
    host=HOST,
    port=PORT,
    username=suser,
    password=spass,
    autologin=True,
    )
#setup arguments
kwargs_oneshot = {"count" :  "0",
                  "earliest_time": begin,
                  "latest_time": end,
                  "set_ttl":60
                 }
#setup search job    
oneshotsearch_results = service.jobs.oneshot(query, **kwargs_oneshot)
# Get the results and display them using the ResultsReader
reader = results.ResultsReader(oneshotsearch_results)

而不是 set_ttl,我相信您需要 ttltimeout。参见 https://docs.splunk.com/Documentation/Splunk/latest/RESTREF/RESTsearch#search.2Fjobs

此外,请考虑减少搜索量或 运行 减少搜索频率。