指标(指标)
这指标Endpoint 提供访问应用指标以诊断应用记录的指标。
该端点不应被“抓取”或用作生产环境中的指标后端。
其目的是显示当前注册的指标,让用户了解可用的指标、当前值,以及触发某些作是否会导致某些值发生变化。
如果你想通过应用收集的指标来诊断,应该使用外部指标后端。
在这种情况下,指标端点依然有用。
检索度量名称
要检索可用度量的名称,请设置获取请求/执行器/度量如以下基于卷度的示例所示:
$ curl 'http://localhost:8080/actuator/metrics' -i -X GET
最终的响应类似于以下内容:
HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 154
{
"names" : [ "jvm.buffer.count", "jvm.buffer.memory.used", "jvm.buffer.total.capacity", "jvm.memory.committed", "jvm.memory.max", "jvm.memory.used" ]
}
检索度量
要获取度量,请设置获取请求/actuator/metrics/{metric.name}如以下基于卷度的示例所示:
$ curl 'http://localhost:8080/actuator/metrics/jvm.memory.max' -i -X GET
前例检索了关于名为 的度量的信息jvm.memory.max.
最终的响应类似于以下内容:
HTTP/1.1 200 OK
Content-Disposition: inline;filename=f.txt
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 555
{
"availableTags" : [ {
"tag" : "area",
"values" : [ "heap", "nonheap" ]
}, {
"tag" : "id",
"values" : [ "CodeHeap 'profiled nmethods'", "G1 Old Gen", "CodeHeap 'non-profiled nmethods'", "G1 Survivor Space", "Compressed Class Space", "Metaspace", "G1 Eden Space", "CodeHeap 'non-nmethods'" ]
} ],
"baseUnit" : "bytes",
"description" : "The maximum amount of memory in bytes that can be used for memory management",
"measurements" : [ {
"statistic" : "VALUE",
"value" : 2.936012797E9
} ],
"name" : "jvm.memory.max"
}
钻探
要深入分析指标,可以做一个获取请求/actuator/metrics/{metric.name}使用标记查询参数,如下面的基于卷度的示例所示:
$ curl 'http://localhost:8080/actuator/metrics/jvm.memory.max?tag=area%3Anonheap&tag=id%3ACompressed+Class+Space' -i -X GET
上述示例检索jvm.memory.max度量,其中面积标签的值为非堆以及身份证属性的值为压缩班级空间.
最终的响应类似于以下内容:
HTTP/1.1 200 OK
Content-Disposition: inline;filename=f.txt
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 263
{
"availableTags" : [ ],
"baseUnit" : "bytes",
"description" : "The maximum amount of memory in bytes that can be used for memory management",
"measurements" : [ {
"statistic" : "VALUE",
"value" : 1.073741824E9
} ],
"name" : "jvm.memory.max"
}