This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

System Metrics

Customize the reporting of system metrics.

1 - System metrics configuration

Customize the reporting of system metrics.

Properties

To control all aspects of the system metrics behavior.

PropertyTypeDefaultDescription
frequencystringInitial system metrics reporting frequency as a sequence of decimal numbers, each with optional fraction and a unit suffix, such as: 300ms, 1.5h, 10m30s, etc., time units are: ns, us (or µs), ms, s, m, h
Local connectivity
brokerstringtcp://localhost:1883Address of the MQTT server/broker that the system metrics will connect for the local communication, the format is: scheme://host:port
usernamestringUsername that is a part of the credentials
passwordstringPassword that is a part of the credentials
Local connectivity - TLS
caCertstringPEM encoded CA certificates file
clientCertstringPEM encoded certificate file to authenticate to the MQTT server/broker
clientKeystringPEM encoded unencrypted private key file to authenticate to the MQTT server/broker
Logging
logFilestringlog/system-metrics.logPath to the file where log messages are written
logLevelstringINFOAll log messages at this or higher level will be logged, the log levels in descending order are: ERROR, WARN, INFO, DEBUG and TRACE
logFileCountint5Log file maximum rotations count
logFileMaxAgeint28Log file rotations maximum age in days, use 0 to not remove old log files
logFileSizeint2Log file size in MB before it gets rotated

Example

The minimal required configuration that enables the auto reporting of system metrics.

{
    "frequency": "60s",
    "logFile": "/var/log/system-metrics/system-metrics.log"
}

Template

The configuration can be further adjusted according to the use case. The following template illustrates all possible properties with their default values.

{
    "frequency" : "",
    "broker": "tcp://localhost:1883",
    "username": "",
    "password": "",
    "caCert": "",
    "clientCert": "",
    "cleintKey": "",
    "logFile": "log/system-metrics.log",
    "logLevel": "INFO",
    "logFileCount": 5,
    "logFileMaxAge": 28,
    "logFileSize": 2
}

2 - System Metrics API

The system metrics service provides the ability to request and receive metrics data.

Request

Request to receive metrics data.

Request

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

Ditto Message:

NameValueDescription
topic<name>/<namespace>/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 UUIDUsed for correlating protocol messages, the same correlation-id as the sent back response message
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 specified filter and frequency.

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

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

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

Ditto Message:

NameValueDescription
topic<name>/<namespace>/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 request message
StatusStatus of the operation request the metrics data

Example : Successful response of a request metrics message.

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

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

Data

Metrics data reported by the device.

Response

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

Ditto Message:

NameValueDescription
topic<name>/<namespace>/things/live/messages/dataInformation about the affected Thing and the type of operation
path/features/Metrics/outbox/messages/dataA path to the Metrics Feature, it’s message channel, and metrics data
HeadersAdditional headers
content-typeapplication/jsonThe content type
ValueThe value of the received data from the device in json format
timestampThe timestamp in ms when this measure data is published
snapshotAll the measurements collected at a concrete time 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, cpu.load1, cpu.load5, cpu.load15, memory.utilization, memory.total, memory.available, memory.used, io.readBytes, io.writeBytes
valueThe measured value per metric ID

Example : Metrics data from the device.

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

{
	"topic":"edge/device/things/live/messages/data",
	"headers":{
		"content-type":"application/json",
	},
	"path":"/features/Metrics/outbox/messages/data",
	"value":{
		"snapshot":[
			{
				"originator":"SYSTEM",
				"measurements":[
					{
						"id":"cpu.utilization",
						"value":1.1555555555484411
					},
					{
						"id":"cpu.load1",
						"value":0.17
					},
					{
						"id":"cpu.load5",
						"value":0.27
					},
					{
						"id":"cpu.load15",
						"value":0.24
					},
					{
						"id":"memory.total",
						"value":10371616768
					},
					{
						"id":"memory.available",
						"value":5281644544
					},
					{
						"id":"memory.used",
						"value":4563206144
					},
					{
						"id":"memory.utilization",
						"value":43.99705702662538
					}
				]
			}
		],
		"timestamp":1234567890
	}
}