empiredan opened a new issue, #1206:
URL: https://github.com/apache/incubator-pegasus/issues/1206

   # 1. Motivation
   
   The new framework should provide a service to collect metrics. Since it's 
hoped that the metrics are collected very conveniently, the service can be 
**RESTful**. With *http* protocol, the metrics can be viewed just by any 
browser or a `curl` command.
   
   # 2. Data types
   
   ## 2.1 Request
   
   Common RESTful semantics will be adopted for the service. For example, 
metrics can queried by `GET` method with parameters passed in [query 
string](https://en.wikipedia.org/wiki/Query_string).
   
   However, there are just field pairs (name and value) in query string. In our 
scenario, complex data structures such as array should be supported. For 
example, multiple metric names may be contained in a query.
   
   To solve this problem, the field value can be designed as such format to 
represent an array: comma("`,`") can be used as the delimiter to separate each 
element of the array, for example "`put_count,put_latency,alive_node_count`"; 
also, comma("`,`") can be used safely in query component in URL according to 
[possible side effect using comma in query 
string](https://stackoverflow.com/questions/45686595/possible-side-effect-using-comma-in-querystring)
 and [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986#section-3.4).
   
   ## 2.2 Response
   
   The collected metrics can just be organized in *json* format. The detailed 
implementations will be described in the following sections.
   
   # 3. API
   
   ## 3.1 Query metrics
   
   ### 3.1.1 Request
   
   #### URI
   
   ```url
   /metrics
   ```
   
   #### Parameters
   
   | Parameters | Data Types |Description|
   |:----------:|:-----------:|:----------|
   | types | array | entity types, such as `server`, `table`, `replica`, etc. |
   | ids | array | entity IDs. |
   | attributes | array | attributes for entity, such as table name and 
partition id for entity `replica`, and 
"`attr_key_1,attr_val_1,attr_key_2,attr_val_2`" means there are 2 pairs of 
attributes: `attr_key_1:attr_val_1` and `attr_key_2:attr_val_2`. |
   | metrics | array | metric names. |
   
   
   #### Headers
   
   ```http
   Accept: application/json
   ```
   
   ### 3.1.2 Response
   
   #### Headers
   
   ```http
   Content-Type: application/json
   ```
   
   #### Content
   
   ```json
   [
       { // entity 1
           "type": "<entity_type>",
           "id": "<entity_id>",
           "attributes": {
               "<attr_key_1>": "<attr_val_1>",
               "<attr_key_2>": "<attr_val_2>",
               "<attr_key_3>": "<attr_val_3>",
               ...
           },
           "metrics": [ // metrics that belong to entity 1
               // gauge
               {
                   "name": "<gauge_name>",
                   "value": 100
               },
               // counter
               {
                   "name": "<counter_name>",
                   "value": 10000
               },
               // percentile
               {
                   "name": "<percentile_name>",
                   "p50": 1,
                   "90": 5,
                   "95": 8,
                   "99": 10,
                   "p999": 15
               }
           ]
       },
       { // entity 2
           ...
       },
       ...
   ]
   ```
   
   ### 3.1.3 Examples
   
   #### Collect all metrics
   
   ```url
   /metrics
   ```
   
   #### Collect all metrics from server entity
   
   ```url
   /metrics?types=server
   ```
   
   #### Collect all metrics from both server and replica entity
   
   ```url
   /metrics?types=server,replica
   ```
   
   #### Collect all metrics of the given replica entities (table_name=my_table, 
partitions_id=1 or 5)
   
   ```url
   
/metrics?types=replica&attributes=table_name,my_table,partition_id,1,partition_id,5
   ```
   
   #### Collect specified metrics of server entity and the given replica 
entities (table_name=my_table, partitions_id=1 or 5)
   
   ```url
   
/metrics?types=server,replica&attributes=table_name,my_table,partition_id,1,partition_id,5,metrics=get_latency,put_count,alive_node_count
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to