Commit 85c0cfb7 authored by Naman Dixit's avatar Naman Dixit

Updated docker instrumentation data format

parent d52d8e53
...@@ -44,21 +44,40 @@ Format: ...@@ -44,21 +44,40 @@ Format:
Once the runtime entity has been launched (or the launch has failed), the Executor sends back a status message on the `LOG_COMMON` topic. Once the runtime entity has been launched (or the launch has failed), the Executor sends back a status message on the `LOG_COMMON` topic.
```javascript ```javascript
{ {
"message_type" : "deployment_launch", "message_type" : "deployment",
"reason": "launch"/"terminate",
"node_id" : "unique-machine-id", "node_id" : "unique-machine-id",
"entity_id" : "handle for the actual container/VM/etc.", "entity_id" : "handle for the actual container/VM/etc.",
"entity_type" : "docker/libvirt/etc.", "entity_type" : "docker/libvirt/etc.",
"resource_id": "logical-entity-id", "resource_id": "logical-entity-id",
"function_id": "unique-function-id", "function_id": "unique-function-id",
"timestamp" : "time(2) compatible timestamp", "timestamp" : "time(2) compatible timestamp",
"reason": "deployment"/"termination"
"status": true/false // Only valid if reason==deployment
} }
``` ```
Instrumentation data is also sent on the `LOG_COMMON` topic. This data is sent from whichever part of the pipeline has access to the relevant information, Instrumentation data is also sent on the `LOG_COMMON` topic. This data is sent from whichever part of the pipeline has access to the relevant information,
and whoever needs the data is allowed to read it. Each message is required to have atleast three fields: `node_id`, `resource_id` and `function_id`. and whoever needs the data is allowed to read it. Each message is required to have atleast three fields: `node_id`, `resource_id` and `function_id`.
```javascript ```javascript
{ // From Docker
"message_type" : "instrumentation",
"node_id" : "unique-machine-id",
"resource_id": "logical-entity-id",
"function_id": "unique-function-id",
"entity_id" : "handle for the actual container/VM/etc.",
"entity_type" : "docker/libvirt/etc.",
"timestamp" : "time(2) compatible timestamp",
"data" : {
"cpu_percentage" : 0.43,
"memory_percentage" : 4.32,
"memory_used" : "42MB",
"memory_usable" : "543MB",
"disk_read" : "4GB",
"disk_written" : "43GB",
"net_upload" : "32MB",
"net_download" : "54MB"
}
}
{ // Example message from Executor { // Example message from Executor
"message_type" : "instrumentation", "message_type" : "instrumentation",
"node_id" : "unique-machine-id", "node_id" : "unique-machine-id",
......
...@@ -30,28 +30,49 @@ void* dockerProcessLoop (void *arg) ...@@ -30,28 +30,49 @@ void* dockerProcessLoop (void *arg)
atof(cJSON_GetObjectItem(data_json, "CPUPerc")->valuestring)); atof(cJSON_GetObjectItem(data_json, "CPUPerc")->valuestring));
sbufPrint(json, ",\n\"memory_percentage\": %f", sbufPrint(json, ",\n\"memory_percentage\": %f",
atof(cJSON_GetObjectItem(data_json, "MemPerc")->valuestring)); atof(cJSON_GetObjectItem(data_json, "MemPerc")->valuestring));
sbufPrint(json, ",\n\"memory_used\": %f",
atof(cJSON_GetObjectItem(data_json, "MemUsage")->valuestring)); { // Memory
sbufPrint(json, ",\n\"memory_limit\": %f", Char *mem_begin = cJSON_GetObjectItem(data_json, "MemUsage")->valuestring;
atof(strchr(cJSON_GetObjectItem(data_json, "MemUsage")->valuestring, '/') + 1)); Char *mem_middle = strchr(mem_begin, '/');
sbufPrint(json, ",\n\"block_input\": %f", mem_middle[0] = '\0';
atof(cJSON_GetObjectItem(data_json, "BlockIO")->valuestring)); mem_middle[-1] = '\0';
sbufPrint(json, ",\n\"block_output\": %f", mem_middle[1] = '\0';
atof(strchr(cJSON_GetObjectItem(data_json, "BlockIO")->valuestring, '/') + 1)); sbufPrint(json, ",\n\"memory_used\": \"%s\"", mem_begin);
sbufPrint(json, ",\n\"net_down\": %f", sbufPrint(json, ",\n\"memory_usable\": \"%s\"", mem_middle + 2);
atof(cJSON_GetObjectItem(data_json, "NetIO")->valuestring)); }
sbufPrint(json, ",\n\"net_up\": %f",
atof(strchr(cJSON_GetObjectItem(data_json, "NetIO")->valuestring, '/') + 1)); { // Disk
Char *block_begin = cJSON_GetObjectItem(data_json, "BlockIO")->valuestring;
Char *block_middle = strchr(block_begin, '/');
block_middle[0] = '\0';
block_middle[-1] = '\0';
block_middle[1] = '\0';
sbufPrint(json, ",\n\"disk_read\": \"%s\"", block_begin);
sbufPrint(json, ",\n\"disk_written\": \"%s\"", block_middle + 2);
}
{ // Network
Char *net_begin = cJSON_GetObjectItem(data_json, "NetIO")->valuestring;
Char *net_middle = strchr(net_begin, '/');
net_middle[0] = '\0';
net_middle[-1] = '\0';
net_middle[1] = '\0';
sbufPrint(json, ",\n\"net_upload\": \"%s\"", net_begin);
sbufPrint(json, ",\n\"net_download\": \"%s\"", net_middle + 2);
}
sbufPrint(json, "\n}\n"); sbufPrint(json, "\n}\n");
cJSON *json_parse = cJSON_Parse(json); cJSON *json_parse = cJSON_Parse(json);
Char *json_pretty = cJSON_Print(json_parse); Char *json_pretty = cJSON_Print(json_parse);
Sint time_now = (Sint)time(0);
Char *output = NULL; Char *output = NULL;
sbufPrint(output, "{\"node_id\": \"%s\"", node_name); sbufPrint(output, "{\n\"message_type\": \"%s\"", "instrumentation");
sbufPrint(output, ",\"node_id\": \"%s\"", node_name);
sbufPrint(output, ",\n\"entity_id\": \"%s\"", (Char*)arg); sbufPrint(output, ",\n\"entity_id\": \"%s\"", (Char*)arg);
sbufPrint(output, ",\n\"type\": \"%s\"", "instrumentation"); sbufPrint(output, ",\n\"entity_type\": \"%s\"", "docker");
sbufPrint(output, ",\n\"backend\": \"%s\"", "docker"); sbufPrint(output, ",\n\"timestamp\": %d", time_now);
sbufPrint(output, ",\n\"data\": %s", json_pretty); sbufPrint(output, ",\n\"data\": %s", json_pretty);
sbufPrint(output, "\n}\n"); sbufPrint(output, "\n}\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment