API to get LLB values for listing page

Review Request #633 — Created Jan. 28, 2025 and submitted

apoorva.sn
AMP
amp_3_7
AA-2572
pmurugaiyan, prajesh, shuinvy

Problem

API to get LLB values for listing page:
Link Name, Gateway IP, Status, Bandwidth Threshold, Bandwidth Usage, Bandwidth In, Bandwidth Out, Connections, Hits

API to get LLB values for Dashboard page:
hits, connections

Solution

Have introduced a new logic to get the LLB Stats and the monitoring data values from Influx DB

Tested with the Postman using following URL:
1. Listing Page
https://192.168.85.47:8888/llb/stats

{"action":"get_llb_stats"}

{
"results": [
{
"statement_id": 0,
"series": [
{
"name": "llbStats",
"tags": {
"agent_host": "192.168.85.101"
},
"columns": [
"time",
"linkName",
"linkGateway",
"linkStatus",
"linkThresh",
"linkUsage",
"linkBandwidIn",
"linkBandwidOut",
"linkConn",
"linkHits"
],
"values": [
[
1738049430000,
"VLAN-162",
"192.168.162.1",
"Up",
"10485760kbps",
0,
"0bps",
"0bps",
0,
1482
],
[
1738049430000,
"VLAN-85",
"192.168.85.1",
"Up",
"10485760kbps",
0,
"0bps",
"0bps",
1,
1483
]
]
}
]
}
]
}

  1. Monitoring Page
    https://192.168.85.47:8888/llb/monitoring_data

{
"results": [
{
"statement_id": 0,
"series": [
{
"name": "llbStats",
"columns": [
"time",
"top",
"linkName",
"agent_host"
],
"values": [
[
1738147200812,
0,
"VLAN-162",
"192.168.85.101"
],
[
1738147200812,
0,
"VLAN-85",
"192.168.85.101"
]
]
}
]
},
{
"statement_id": 1,
"series": [
{
"name": "llbStats",
"columns": [
"time",
"top",
"linkName",
"agent_host"
],
"values": [
[
1738147210000,
4,
"VLAN-85",
"192.168.85.101"
],
[
1738147210000,
1,
"VLAN-162",
"192.168.85.101"
]
]
}
]
}
]
}

Description From Last Updated

can we introduce a repo layer to interact with db. Extending current design makes the code a lot harder to …

prajeshprajesh

can be llb/stats

prajeshprajesh

300 seconds sounds too much. 15 seconds should be ideal keeping user experience in mind. You dont want to frustrate …

prajeshprajesh

what is the idea here? We pass the SQL query in the POST method and then we get the DB …

prajeshprajesh

Should we combine these two into one API call. Any reason to keep them separate?

prajeshprajesh

do we need POST here? Is there away to change it to GET.

prajeshprajesh

Same here.. as per handler it is doing a GET action.

prajeshprajesh
apoorva.sn
apoorva.sn
prajesh
  1. 
      
  2. can we introduce a repo layer to interact with db. Extending current design makes the code a lot harder to refactor at a later point in time.

    1. Introduced DB layer to handle DB requests for LLB Stats

  3. 
      
apoorva.sn
apoorva.sn
prajesh
  1. 
      
  2. 300 seconds sounds too much. 15 seconds should be ideal keeping user experience in mind. You dont want to frustrate the use working on the UI :)

  3. what is the idea here? We pass the SQL query in the POST method and then we get the DB response in the POST call?

    1. here we are constructing a query whether agent_host info is provided. If it is there in the POST request then we use the 2nd query

  4. Should we combine these two into one API call. Any reason to keep them separate?

    1. Better to keep them seperate as get_llb_stats_query_str get the query string and execute_db_query executes the query. We might have different query string for every method but execute_db_query can be same.

    2. execute_db_query is something db layer logic. Upper level layers shoudl not care about how how db gets it. This breaks the encapsulation principle.

    3. llb_stats.py is it part of the repo layer or not? if this is the part of repo layer, then current code is okay.

  5. 
      
apoorva.sn
apoorva.sn
shuinvy
  1. Ship It!
  2. 
      
pmurugaiyan
  1. Ship It!
  2. 
      
prajesh
  1. 
      
  2. do we need POST here? Is there away to change it to GET.

    1. As of now we dont have the functionality to get the username from the session and to get the hosts which are accessible to the user.
      so using POST only as of now to get the hosts information

  3. Same here.. as per handler it is doing a GET action.

    1. As of now we dont have the functionality to get the username from the session and to get the hosts which are accessible to the user.
      so using POST only as of now to get the hosts information

  4. 
      
prajesh
  1. Ship It!
  2. 
      
shuinvy
  1. Ship It!
  2. 
      
apoorva.sn
Review request changed

Status: Closed (submitted)

Loading...