From 0b7d2bac020413609b00df6ce270ed470158a5b2 Mon Sep 17 00:00:00 2001
From: Nikolay Stanchev <ns17@it-innovation.soton.ac.uk>
Date: Tue, 17 Jul 2018 18:32:28 +0100
Subject: [PATCH] Updates documentation for the graph API

---
 docs/clmc-service.md | 67 +++++++++++++++++++++++++++++++++++---------
 1 file changed, 54 insertions(+), 13 deletions(-)

diff --git a/docs/clmc-service.md b/docs/clmc-service.md
index 53de429..896867f 100644
--- a/docs/clmc-service.md
+++ b/docs/clmc-service.md
@@ -38,15 +38,15 @@ All source code, tests and configuration files of the service can be found in th
 
 #### Graph API Endpoints
 
-* **POST** ***/graph/build?from={timestamp-seconds}&to={timestamp-seconds}***
+* **POST** ***/graph/temporal?from={timestamp-seconds}&to={timestamp-seconds}***
 
     This API method sends a request to the CLMC service to build a graph related to the time range declared with the *from* and *to* URL parameters.
 
    * Request:
         
         Expects a JSON-formatted request body which declares the database, retention policy and service function chain instance for which the graph is built.
-        The request should also include the service functions that must be included in the graph along with the measurement name and response time field for each
-        service function. The response time field could be an influx function across multiple fields.
+        The request should also include the service functions that must be included in the graph along with the measurement name, response time field, request size field and
+        response size field for each service function. The declared fields could be influx functions across multiple fields.
         
    * Request Body Example: 
     
@@ -58,11 +58,15 @@ All source code, tests and configuration files of the service can be found in th
           "service_functions": {
             "nginx": {
               "response_time_field": "mean(response_time)",
+              "request_size_field": "mean(request_size)",
+              "response_size_field": "mean(response_size)",
               "measurement_name": "nginx"
             },
             "minio": {
               "response_time_field": "mean(sum)/mean(count)",
-              "measurement_name":"minio_http_requests_duration_seconds"
+              "request_size_field": "mean(request_size)/mean(count)",
+              "response_size_field": "mean(response_size)/mean(count)",
+              "measurement_name": "minio_http_requests_duration_seconds"
             }
           }
         }
@@ -71,13 +75,13 @@ All source code, tests and configuration files of the service can be found in th
         These parameters are then filled in the following influx query template:
         
         ```
-        SELECT {0} AS mean_response_time FROM "{1}"."{2}".{3} WHERE sfc_i='{4}' and time>={5} and time<{6} GROUP BY ipendpoint, location, sf_i
+        SELECT {0}, {1}, {2} AS mean_response_time FROM "{3}"."{4}".{5} WHERE sfc_i='{6}' and time>={7} and time<{8} GROUP BY ipendpoint, location, sf_i
         ```
         
         E.g. for the minio service function, the following query will be used to retrieve the data from influx (request url is /graph/build?from=1528385420&to=1528385860):
         
         ```
-        SELECT mean(sum)/mean(count) AS mean_response_time FROM "MSDemo"."autogen".minio_http_requests_duration_seconds WHERE sfc_i='MSDemo_1' and time>=1528385420000000000 and time<1528385860000000000 GROUP BY ipendpoint, location, sf_i
+        SELECT mean(sum)/mean(count), mean(request_size)/mean(count), mean(response_size)/mean(count) AS mean_response_time FROM "MSDemo"."autogen".minio_http_requests_duration_seconds WHERE sfc_i='MSDemo_1' and time>=1528385420000000000 and time<1528385860000000000 GROUP BY ipendpoint, location, sf_i
         ```
             
         N.B. timestamps are converted to nano seconds.
@@ -103,11 +107,15 @@ All source code, tests and configuration files of the service can be found in th
           "service_functions": {
             "nginx": {
               "response_time_field": "mean(response_time)",
+              "request_size_field": "mean(request_size)",
+              "response_size_field": "mean(response_size)",
               "measurement_name": "nginx"
             },
             "minio": {
               "response_time_field": "mean(sum)/mean(count)",
-              "measurement_name":"minio_http_requests_duration_seconds"
+              "request_size_field": "mean(request_size)/mean(count)",
+              "response_size_field": "mean(response_size)/mean(count)",
+              "measurement_name": "minio_http_requests_duration_seconds"
             }
           },
           "graph": {
@@ -136,7 +144,7 @@ All source code, tests and configuration files of the service can be found in th
         ```json
         {
            "uuid": "75df6f8d-3829-4fd8-a3e6-b3e917010141",
-           "deleted": 4
+           "deleted": 5
         }
         ``` 
 
@@ -147,7 +155,8 @@ All source code, tests and configuration files of the service can be found in th
 
     * Response:
 
-        The response of this request is a JSON content, which contains the result from the Cypher query including forward latencies, reverse latencies and service function response time.
+        The response of this request is a JSON content, which contains the result from the Cypher query including forward latencies, reverse latencies and service function response time along with the
+        calculated round trip time and global tag values for the given service function endpoint.
         
         Returns a 400 Bad Request error if the URL parameters are invalid
             
@@ -159,13 +168,29 @@ All source code, tests and configuration files of the service can be found in th
     
         ```json
         {
+            "request_size": 2048,
+            "response_size": 104857,
+            "bandwidth": 104857600,
             "forward_latencies": [
-                22, 11
+               22, 11
             ],
+            "total_forward_latency": 0,
             "reverse_latencies": [
-                15, 18
+               15, 18
             ],
-            "response_time": 15.75
+            "total_reverse_latency": 0,
+            "response_time": 15.75,
+            "round_trip_time": 81.75,
+            "global_tags": {
+                "sr": "SR1",
+                "ipendpoint": "minio_1_ep1",
+                "sfc": "MSDemo",
+                "sf_i": "minio_1",
+                "location": "DC1",
+                "sf": "minio",
+                "sfc_i": "MSDemo_1",
+                "host": "host2"
+            }
         }
         ``` 
         
@@ -176,9 +201,25 @@ All source code, tests and configuration files of the service can be found in th
         
         ```json
         {
+            "request_size": 2048,
+            "response_size": 104857,
+            "bandwidth": 104857600,
             "forward_latencies": [],
+            "total_forward_latency": 0,
             "reverse_latencies": [],
-            "response_time": 15.75
+            "total_reverse_latency": 0,
+            "response_time": 3,
+            "round_trip_time": 3,
+            "global_tags": {
+                "sr": "SR1",
+                "ipendpoint": "minio_1_ep1",
+                "sfc": "MSDemo",
+                "sf_i": "minio_1",
+                "location": "DC1",
+                "sf": "minio",
+                "sfc_i": "MSDemo_1",
+                "host": "host2"
+            }
         }
         ``` 
 
-- 
GitLab