简体   繁体   English

通过API获取Jenkins指标数据

[英]Get Jenkins Metrics data through API

What I need with the API call API调用需要什么

API调用需要什么

I need the timeline info for each of the builds via the API call for Jenkins metrics plugin. 我需要通过Jenkins指标插件的API调用获取每个构建的时间线信息。 I am using a web API to get data for my jobs in my jenkins. 我正在使用Web API来获取詹金斯中的工作数据。 However, calling $JenkinsUrl/metrics/APIkey is leading me nowhere. 但是,调用$JenkinsUrl/metrics/APIkey却无济于事。 Any idea how can I achieve the information? 知道如何获取信息吗?

All three bits of timeline info for each build (queue time, building time, total time) are available via the "get build" API. 每个构建的时间轴信息的所有三位(队列时间,构建时间,总时间)可通过“获取构建” API获得。

On the screen where it shows "8.1 sec waiting in the queue" etc, click on the "REST API" link in the page footer, then "JSON API", then add &depth=2 to the end of the resulting API URL. 在显示“ 8.1 sec等待队列”等的屏幕上,单击页面页脚中的“ REST API”链接,然后单击“ JSON API”,然后在结果API URL的末尾添加&depth=2

note, if you're searching for specific values in the API json, that the times will be in milliseconds. 请注意,如果您要在API json中搜索特定值,则时间将以毫秒为单位。 after you parse the json, build time is under the "duration" property, and the other two are in the array under the "actions" property. 解析json之后,构建时间在“ d​​uration”属性下,而其他两个在数组中的“ actions”属性下。 for me, it was the third element of the array, but that may vary (find the one with _class "jenkins.metrics.impl.TimeInQueueAction"): 对我而言,它是数组的第三个元素,但可能有所不同(使用_class“ jenkins.metrics.impl.TimeInQueueAction”查找该元素):

{
  "_class": "jenkins.metrics.impl.TimeInQueueAction",
  "queuingDurationMillis": 16,
  "totalDurationMillis": 4365
}

so in my example the build time was 4349 and the queue time was 16, so the total time was 4349 + 16 = 4365 milliseconds. 因此在我的示例中,构建时间为4349,队列时间为16,因此总时间为4349 + 16 = 4365毫秒。

Instead of adding &depth=2 to the end of the url, you might be able to get exactly the three values you want by appending this to the url: &tree=duration,actions[queuingDurationMillis,totalDurationMillis] 无需在网址末尾添加&depth=2 ,您可以通过将其附加到网址中来获取所需的三个值: &tree=duration,actions[queuingDurationMillis,totalDurationMillis]

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

相关问题 如何通过API获取正在运行的jenkins作业的进度条数据 - how to get progress bar data for a running jenkins job through the API 如何通过api获取所有jenkins用户 - how to get all the jenkins users through api 如何通过 API 从 amoCRM 获取数据? - How to get data from amoCRM through API? 创建一个 API 来连接 ArangoDB 和 Prometheus 以获取 ArangoDB 内部数据的指标并在 Prometheus 中公开 - Creating an API to connect between ArangoDB and Prometheus to get the metrics of the data inside ArangoDB and expose it in Prometheus 如何使用 api 获取 Azure apim 的指标 - How to get metrics of Azure apim using an api 通过api发送内部版本号作为json参数,获取詹金斯工作的控制台输出 - Get console output of a jenkins job by sending the build number as a json parameter through api 通过REST API获取报告数据以HTML形式显示为数据表 - Get report data to display as data table in HTML through REST API 我可以通过FileMaker数据API获得文件的ScriptName吗? - Can I get ScriptNames for a file through the FileMaker data API? AngularJS通过JSON API从用户获取相关数据 - AngularJS get related data from user through JSON API 如何通过API获取超过1000的速率限制的数据? - How to get more data than the rate limit of 1000 through API?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM