Container Metrics
Container Metrics
Container-level metrics, such as CPU utilization or memory usage, can be retrieved on-demand and continuously by enabling the container metrics events.
This is done by sending a request to the topic command//<namespaceId>:<gatewayId>:<deviceId>:edge:containers/req/<correlationId>/request
:
- Enable Container Metrics with a frequency of
5s
:
{
"topic": "dummy-namespace/dummy-gateway:dummy-device-id:edge:containers/things/live/messages/request",
"headers": {
"timeout": "10",
"response-required": true,
"content-type": "application/json",
"correlation-id": "3fdc463c-293c-4f39-ab19-24aef7944550"
},
"path": "/features/Metrics/inbox/messages/request",
"value": {
"frequency": "5s"
}
}
Example command line:
mosquitto_pub -t command//dummy-namespace:dummy-gateway:dummy-device-id:edge:containers/req/3fdc463c-293c-4f39-ab19-24aef7944550/request -m '{"topic":"dummy-namespace/dummy-gateway:dummy-device-id:edge:containers/things/live/messages/request","headers":{"timeout":"10","response-required":true,"content-type":"application/json","correlation-id":"3fdc463c-293c-4f39-ab19-24aef7944550"},"path":"/features/Metrics/inbox/messages/request","value":{"frequency":"5s"}}'
- Container Metrics answers with an additional message for each container in the topic
e/<tenantId>/<gatewayId>:<deviceId>:edge:containers
{
"topic": "<tenantId>/<gatewayId>:<deviceId>:edge:containers/things/twin/commands/modify",
"headers": {
"response-required": false
},
"path": "/features/Container:<uuid>",
"value": {
"definition": [
"com.bosch.iot.suite.edge.containers:Container:1.5.0"
],
"properties": {
"status": {
"name": "seatservice-example",
"imageRef": "ghcr.io/eclipse/kuksa.val.services/seat_service:v0.1.0",
"config": {
"domainName": "seatservice-example-domain",
"hostName": "seatservice-example-host",
"env": [
"VEHICLEDATABROKER_DAPR_APP_ID=databroker",
"BROKER_ADDR=databroker-host:30555",
"RUST_LOG=info",
"vehicle_data_broker=info"
],
"restartPolicy": {
"type": "UNLESS_STOPPED"
},
"extraHosts": [
"databroker-host:host_ip"
],
"portMappings": [
{
"proto": "tcp",
"hostPort": 30051,
"hostPortEnd": 30051,
"containerPort": 50051,
"hostIP": "localhost"
}
],
"networkMode": "BRIDGE",
"log": {
"type": "JSON_FILE",
"maxFiles": 2,
"maxSize": "1M",
"mode": "BLOCKING"
}
},
"createdAt": "2023-02-02T08:46:33.792687313Z",
"state": {
"status": "RUNNING",
"pid": 13627,
"startedAt": "2023-02-02T09:51:08.049572297Z",
"finishedAt": "2023-02-02T09:50:51.752255799Z"
}
}
}
}
}
-
To disable Container Metrics, send a request with frequency of
0s
:mosquitto_pub -t command//dummy-namespace:dummy-gateway:dummy-device-id:edge:containers/req/3fdc463c-293c-4f39-ab19-24aef7944550/request -m '{"topic":"dummy-namespace/dummy-gateway:dummy-device-id:edge:containers/things/live/messages/request","headers":{"timeout":"10","response-required":true,"content-type":"application/json","correlation-id":"3fdc463c-293c-4f39-ab19-24aef7944550"},"path":"/features/Metrics/inbox/messages/request","value":{"frequency":"0s"}}'
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.