メトリクス (metrics)

metrics エンドポイントは、アプリケーションメトリクスへのアクセスを提供します。

メトリクス名の取得

使用可能なメトリクスの名前を取得するには、次の curl ベースの例に示すように、GET リクエストを /actuator/metrics に作成します。

$ 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" ]
}

レスポンス構造

レスポンスには、メトリクス名の詳細が含まれます。次の表に、レスポンスの構造を示します。

パス タイプ 説明

names

Array

既知のメトリクスの名前。

メトリクスの取得

メトリクスを取得するには、次の curl ベースの例に示すように、GET リクエストを /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

{
  "name" : "jvm.memory.max",
  "description" : "The maximum amount of memory in bytes that can be used for memory management",
  "baseUnit" : "bytes",
  "measurements" : [ {
    "statistic" : "VALUE",
    "value" : 2.399141885E9
  } ],
  "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'" ]
  } ]
}

クエリパラメーター

エンドポイントは、クエリパラメーターを使用して、タグを使用してメトリクスにドリルダウンします。次の表に、サポートされている単一のクエリパラメーターを示します。

パラメーター 説明

tag

name:value 形式のドリルダウンに使用するタグ。

レスポンス構造

レスポンスには、メトリクスの詳細が含まれます。次の表に、レスポンスの構造を示します。

パス タイプ 説明

name

String

メトリクスの名前

description

String

メトリクスの説明

baseUnit

String

メトリクスの基本単位

measurements

Array

メトリクスの測定

measurements[].statistic

String

測定の統計。(TOTALTOTAL_TIMECOUNTMAXVALUEUNKNOWNACTIVE_TASKSDURATION)。

measurements[].value

Number

測定値。

availableTags

Array

ドリルダウンに使用できるタグ。

availableTags[].tag

String

タグの名前。

availableTags[].values

Array

タグの可能な値。

ドリルダウン

メトリクスにドリルダウンするには、次の curl ベースの例に示すように、tag クエリパラメーターを使用して GET リクエストを /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 メトリクスを取得します。area タグの値は nonheap で、id 属性の値は Compressed Class Space です。結果のレスポンスは次のようになります。

HTTP/1.1 200 OK
Content-Disposition: inline;filename=f.txt
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 263

{
  "name" : "jvm.memory.max",
  "description" : "The maximum amount of memory in bytes that can be used for memory management",
  "baseUnit" : "bytes",
  "measurements" : [ {
    "statistic" : "VALUE",
    "value" : 1.073741824E9
  } ],
  "availableTags" : [ ]
}