为什么我不能为 JIRA 查询超过 1000 个结果?
Why can't I query more than 1000 results for JIRA?
I'm using the Logstash Input Plugin exec to 运行 a command periodically to get JIRA data. Even if I set maxResults=99999, only 1000 results are returned. Here is my code right now:
input {
exec {
command => "curl -u username:password https://mycompany.atlassian.net/rest/api/latest/search?project=project&maxResults=8500"
interval => 300
type => "issues"
}
} output {
elasticsearch {
hosts => "localhost:9200"
index => "jira"
}
}
I found online that if you 运行 around 10 execs, and you set startAt to 0, 1000, 2000, etc, you get around 10000 responses. Is this faster than just one exec that pulls 8000 requests? How do I return more than 1000 responses with 1 exec?
Unfortunately it is not possible to change this value as it falls under customizations which are not allowed in Atlassian Cloud.
看来最好的方法是使用startAt
方法。
@alpert 的回答是正确的,但我会添加更多细节。
JIRA 的 REST API(以及大多数 api 的一般)支持分页以防止 API 的客户端给应用程序带来过多的负载。这意味着您不能仅通过 1 个 REST 调用提取所有问题数据。
您只能使用分页查询参数 startAt 和 maxResults 检索最多 1000 个问题中的 "pages" 个。请参阅 分页 部分 here。
如果您 运行 JIRA 独立服务器,那么您可以调整 JIRA returns 的最大结果数,但对于云实例,这是不可能的。请参阅此 KB article 了解更多信息。
您的 logstash 配置表明您定期将项目的所有 JIRA 问题转储到 ElasticSearch 中。可能有比使用 JIRA GET /issue REST API 调用更好的方法来实现您想要做的事情。那么,您在 ElasticSearch 中使用这些数据做什么?
可能有一种方法可以在 JIRA 中完成您需要的操作,或者您可以寻找一种更方便的方法来导出所有 JIRA 数据,例如通过使用 export functionality.
<?php
$username="JIRA Email";
$password="JIRA Password";
$handle = curl_init();
$project_url="https://jirasite.atlassian.net/rest/api/2/search?jql=project='project id'&maxResults=100";
$project_url=trim($project_url);
curl_setopt($handle, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt_array($handle, array(
CURLOPT_URL => $project_url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_MAXREDIRS => 10,
CURLOPT_HTTPHEADER => array("content-type:application/json"),
CURLOPT_HEADER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_ENCODING => '',
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_USERPWD => $username . ':' . $password
));
$response = curl_exec($handle);
print_r($response);
?>
回应将是
{"expand":"schema,names","startAt":0,"maxResults":100,"total":52,"issues":[{"expand" :......
I'm using the Logstash Input Plugin exec to 运行 a command periodically to get JIRA data. Even if I set maxResults=99999, only 1000 results are returned. Here is my code right now:
input {
exec {
command => "curl -u username:password https://mycompany.atlassian.net/rest/api/latest/search?project=project&maxResults=8500"
interval => 300
type => "issues"
}
} output {
elasticsearch {
hosts => "localhost:9200"
index => "jira"
}
}
I found online that if you 运行 around 10 execs, and you set startAt to 0, 1000, 2000, etc, you get around 10000 responses. Is this faster than just one exec that pulls 8000 requests? How do I return more than 1000 responses with 1 exec?
Unfortunately it is not possible to change this value as it falls under customizations which are not allowed in Atlassian Cloud.
看来最好的方法是使用startAt
方法。
@alpert 的回答是正确的,但我会添加更多细节。
JIRA 的 REST API(以及大多数 api 的一般)支持分页以防止 API 的客户端给应用程序带来过多的负载。这意味着您不能仅通过 1 个 REST 调用提取所有问题数据。
您只能使用分页查询参数 startAt 和 maxResults 检索最多 1000 个问题中的 "pages" 个。请参阅 分页 部分 here。
如果您 运行 JIRA 独立服务器,那么您可以调整 JIRA returns 的最大结果数,但对于云实例,这是不可能的。请参阅此 KB article 了解更多信息。
您的 logstash 配置表明您定期将项目的所有 JIRA 问题转储到 ElasticSearch 中。可能有比使用 JIRA GET /issue REST API 调用更好的方法来实现您想要做的事情。那么,您在 ElasticSearch 中使用这些数据做什么?
可能有一种方法可以在 JIRA 中完成您需要的操作,或者您可以寻找一种更方便的方法来导出所有 JIRA 数据,例如通过使用 export functionality.
<?php
$username="JIRA Email";
$password="JIRA Password";
$handle = curl_init();
$project_url="https://jirasite.atlassian.net/rest/api/2/search?jql=project='project id'&maxResults=100";
$project_url=trim($project_url);
curl_setopt($handle, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt_array($handle, array(
CURLOPT_URL => $project_url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_MAXREDIRS => 10,
CURLOPT_HTTPHEADER => array("content-type:application/json"),
CURLOPT_HEADER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_ENCODING => '',
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_USERPWD => $username . ':' . $password
));
$response = curl_exec($handle);
print_r($response);
?> 回应将是 {"expand":"schema,names","startAt":0,"maxResults":100,"total":52,"issues":[{"expand" :......