Metrics API

With the metrics service, you can request and receive metrics data for specific containers.

Request

Request to receive data from the container.

Request

Hono Command: command//<name>:<namespace>:edge:containers/req//request

Ditto Message:

NameValueDescription
topic<name>/<namespace>:edge:containers/things/live/messages/requestInformation about the affected Thing and the type of operation
path/features/Metrics/inbox/messages/requestA path to the Metrics Feature, it’s message channel, and request command
HeadersAdditional headers
response-requiredtrue/falseIf response is required
content-typeapplication/jsonThe content type
correlation-idcontainer UUIDThe container UUID
Value
frequencyTime interval of how often the metrics data will be published as duration string (e.g. 5s)
filterFilter defines the type of metric data to be reported
idAn array of identifiers whose metric data to be reported, supported are: cpu.utilization, memory.utilization, memory.total, memory.used, io.readBytes, io.writeBytes, net.readBytes, net.writeBytes, pids
originatorMetrics data originator

Example : Request metrics data with a specified filter and frequency.

Topic: command//edge:device:edge:containers/req//request

{
	"topic":"edge/device:edge:containers/things/live/messages/request",
	"headers":{
		"response-required":true,
		"content-type":"application/json",
		"correlation-id":"<UUID>"
	},
	"path":"/features/Metrics/inbox/messages/request",
	"value":{
		"filter":[
			{
				"id":null,
				"originator":"SYSTEM"
			}
		],
		"frequency":"2s"
	}
}
Response

Hono Command : command//<name>:<namespace>:edge:containers/res//request

Ditto Message:

NameValueDescription
topic<name>/<namespace>:edge:containers/things/live/messages/requestInformation about the affected Thing and the type of operation
path/features/Metrics/outbox/messages/requestA path to the Metrics Feature, it’s message channel, and request command
HeadersAdditional headers
content-typeapplication/jsonThe content type
correlation-id<UUID>The same correlation id as the sent request message
StatusStatus of the request metrics operation

Example : The response of the request metrics data operation.

Topic: `command//edge:device:edge:containers/res//request``

{
	"topic":"edge/device:edge:containers/things/live/messages/request",
	"headers":{
		"content-type":"application/json",
		"correlation-id":"<UUID>"
	},
	"path":"/features/Metrics/outbox/messages/request",
	"status": 204
}

Data

Metrics data from a container based on the frequency specified in the request.

Response

Hono Command : command//<name>:<namespace>:edge:containers/res//data

Ditto Message:

NameValueDescription
topic<name>/<namespace>:edge:containers/things/live/messages/dataInformation about the affected Thing and the type of operation
path/features/Metrics/outbox/messages/dataA path to the Metrics Feature and it’s message channel.
HeadersAdditional headers
content-typeapplication/jsonThe content type
ValueThe value of the received data from the container in json format
timestampThe timestamp in ms when this measure data is published
shapshotAll the measurements collected per originator
originatorThe originator for whose metric data to be reported
measurementsAn array of measurements identifier and value for originator
idThe identifier whose metric data to be reported, supported are: cpu.utilization, memory.utilization, memory.total, memory.used, io.readBytes, io.writeBytes, net.readBytes, net.writeBytes, pids
valueThe measured value per metric ID

Example : Metrics data from a container.

Topic: `command//edge:device:edge:containers/res//data``

{
	"topic":"edge/device:edge:containers/things/live/messages/data",
	"headers":{
		"content-type":"application/json",
	},
	"path":"/features/Metrics/outbox/messages/data",
	"value":{
		"snapshot":[
			{
				"originator":"Container:test",
				"measurements":[
					{
						"id":"memory.total",
						"value":10371616768
					},
					{
						"id":"memory.used",
						"value":1396736
					},
					{
						"id":"memory.utilization",
						"value":0.01346690714903206
					},
					{
						"id":"net.readBytes",
						"value":180
					},
					{
						"id":"net.writeBytes",
						"value":0
					},
					{
						"id":"pids",
						"value":6
					}
				]
			},
			{
				"originator":"Container:test2",
				"measurements":[
					{
						"id":"cpu.utilization",
						"value":8.751566666666667
					},
					{
						"id":"memory.total",
						"value":10371616768
					},
					{
						"id":"memory.used",
						"value":4759552
					},
					{
						"id":"memory.utilization",
						"value":0.04589016453717083
					},
					{
						"id":"io.readBytes",
						"value":0
					},
					{
						"id":"io.writeBytes",
						"value":4096
					},
					{
						"id":"net.readBytes",
						"value":610
					},
					{
						"id":"net.writeBytes",
						"value":202
					},
					{
						"id":"pids",
						"value":14
					}
				]
			}
		],
		"timestamp":1234567890
	}
}
Last modified June 28, 2024