AE-2137: Monitoring- LLB API

Review Request #1075 — Created Sept. 26, 2025 and updated

apoorva.sn
AMP
amp_4_0
AE-2137
mmiriam, ngurunathan, pmurugaiyan, pradeep, shuinvy

Problem

Create new API for Monitoring-SSLVPN Service for getting data from Timescale DB.

Solution

Have introduced new API's with endpoint /llb_stats for the llb stats API's
Also have done lot of refactoring to get the data in interger, float format for all the fields

LLB Stats

stats:

[root@AN admin]# curl 'http://127.0.0.1:8000/llb_stats' \
-X POST \
-H 'Accept: application/json, text/plain, /' \
-H 'Content-Type: application/json' \
-H 'X-CSRFToken: q6NMpRWOV2cVRIXKr2gWdWSfJ01Gumbv' \
-b 'csrftoken=q6NMpRWOV2cVRIXKr2gWdWSfJ01Gumbv; hive_key=1; django_language=en; csrf_token=q6NMpRWOV2cVRIXKr2gWdWSfJ01Gumbv; current_user=array; hive_sess=920330e0-2958-49b3-81bd-9ef833dfe047' \
--data-raw '{
"stat_name": "llb_stats",
"agent_host": "192.168.162.166",
"from": "now-15h",
"to": "now"
}'
{"status": 200, "message": "success", "data": [{"agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "link_gateway": "192.168.162.1", "link_thresh": 0, "link_usage": 0, "received": 0.0, "sent": 0.0, "link_conn": 0, "link_hits": 0}, {"agent_host": "192.168.162.166", "link_name": "VLAN-163", "link_status": "Up", "link_gateway": "192.168.163.1", "link_thresh": 0, "link_usage": 0, "received": 0.0, "sent": 0.0, "link_conn": 0, "link_hits": 0}]}[root@AN admin]

Monitoring Data:

[root@AN admin]# curl 'http://127.0.0.1:8000/llb_stats' \
-X POST \
-H 'Accept: application/json, text/plain, /' \
-H 'Content-Type: application/json' \
-H 'X-CSRFToken: OFCuCSH9Kbwz1ISN12asaCy81o9wR7bR' \
-b 'csrftoken=OFCuCSH9Kbwz1ISN12asaCy81o9wR7bR; hive_key=1; django_language=en; csrf_token=OFCuCSH9Kbwz1ISN12asaCy81o9wR7bR; current_user=array; hive_sess=175a239d-3805-4a79-8212-c2bdceeda730' \
--data-raw '{
"stat_name": "monitoring_data",
"agent_host": "192.168.162.166",
"from": "now-1h",
"to": "now"
}'
{"top_hits": {"status": 200, "message": "success", "data": [{"hits": 0, "link_name": "VLAN-163", "agent_host": "192.168.162.166"}, {"hits": 0, "link_name": "VLAN-162", "agent_host": "192.168.162.166"}]}, "top_conn": {"status": 200, "message": "success", "data": [{"conn": 0, "link_name": "VLAN-162", "agent_host": "192.168.162.166"}, {"conn": 0, "link_name": "VLAN-163", "agent_host": "192.168.162.166"}]}, "top_throughput": {"status": 200, "message": "success", "data": [{"total_throughput": 0.0, "received": 0.0, "sent": 0.0, "link_name": "VLAN-162", "agent_host": "192.168.162.166"}, {"total_throughput": 0.0, "received": 0.0, "sent": 0.0, "link_name": "VLAN-163", "agent_host": "192.168.162.166"}]}}

Historical Data:

[root@AN admin]# curl 'http://127.0.0.1:8000/llb_stats' \
-X POST \
-H 'Accept: application/json, text/plain, /' \
-H 'Content-Type: application/json' \
-H 'X-CSRFToken: OFCuCSH9Kbwz1ISN12asaCy81o9wR7bR' \
-b 'csrftoken=OFCuCSH9Kbwz1ISN12asaCy81o9wR7bR; hive_key=1; django_language=en; csrf_token= OFCuCSH9Kbwz1ISN12asaCy81o9wR7bR; current_user=array; hive_sess=175a239d-3805-4a79-8212-c2bdceeda730' \
--data-raw '{
"stat_name": "historical_data",
"from": "now-15m",
"to": "now",
"interval": "20s",
"link_name": "VLAN-162"
}'
{"status": 200, "message": "success", "data": [{"ts": "2025-09-26T17:10:40+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:11:00+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:11:20+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:11:40+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:12:00+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:12:20+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:12:40+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:13:00+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:13:20+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:13:40+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:14:00+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:14:20+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:14:40+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:15:00+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:15:20+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:15:40+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:16:00+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:16:20+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:16:40+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:17:00+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:17:20+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:17:40+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:18:00+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:18:20+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:18:40+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:19:00+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:19:20+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:19:40+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:20:00+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:20:20+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:20:40+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:21:00+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:21:20+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:21:40+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:22:00+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:22:20+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:22:40+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:23:00+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:23:20+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:23:40+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:24:00+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:24:20+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:24:40+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:25:00+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}, {"ts": "2025-09-26T17:25:20+05:30", "agent_host": "192.168.162.166", "link_name": "VLAN-162", "link_status": "Up", "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0, "avg_link_conn": 0.0, "avg_link_hits": 0.0}]}

Summary Data:

[root@AN admin]# curl 'http://127.0.0.1:8000/llb_stats' \
-X POST \
-H 'Accept: application/json, text/plain, /' \
-H 'Content-Type: application/json' \
-H 'X-CSRFToken: o8jSefyqDRCdExwOO4GmhfkalRh6NBon' \
-b 'csrftoken=o8jSefyqDRCdExwOO4GmhfkalRh6NBon; hive_key=1; django_language=en; csrf_token=o8jSefyqDRCdExwOO4GmhfkalRh6NBon; current_user=array; hive_sess=d1e04c12-c7c8-4fbd-910d-54176d395491' \
--data-raw '{
"stat_name": "summary_data",
"from": "2025-09-22T00:00:00Z",
"to": "2025-09-24T00:00:00Z"
}'
{"status": 200, "message": "success", "data": [{"link_name": "VLAN-162", "avg_link_hits": 0.0, "avg_link_conn": 0.0, "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0}, {"link_name": "VLAN-163", "avg_link_hits": 0.0, "avg_link_conn": 0.0, "avg_bandwid_in": 0.0, "avg_bandwid_out": 0.0, "avg_link_usage": 0.0}]}

Description From Last Updated

why agent_host is mandatory! can we keep it optional to get the metrics for all the agent_hosts!

pmurugaiyanpmurugaiyan

Is agent_host_filter used before initialization!

pmurugaiyanpmurugaiyan

same.. sent & received

pmurugaiyanpmurugaiyan

can we keep it as sent & received. We dont need the units in labels. This will be help when …

pmurugaiyanpmurugaiyan

sent & received.

pmurugaiyanpmurugaiyan

can we rename to send & received, it makes parsing easier. In UI, we can use the common service to …

pmurugaiyanpmurugaiyan

remove the debug statements

pmurugaiyanpmurugaiyan

Can we send the http status code 405, instead of 200

pmurugaiyanpmurugaiyan

same.. can we make the agent host optional.

pmurugaiyanpmurugaiyan

can we make from & to optional make it to default - now & now - 15m

pmurugaiyanpmurugaiyan

Please remove the unused code.

pmurugaiyanpmurugaiyan
pmurugaiyan
  1. 
      
  2. why agent_host is mandatory! can we keep it optional to get the metrics for all the agent_hosts!

    1. Have removed in most places, we need to identify where it is mandatory and add it there during validation phase.
      only in llb_stats have kept where it used as mandatory param

  3. Is agent_host_filter used before initialization!

    1. yes it is placeholder which will be replaced later while formatting

  4. can we keep it as sent & received. We dont need the units in labels. This will be help when unparsing / converting the values for the charts & tables.

  5. remove the debug statements

  6. Can we send the http status code 405, instead of 200

  7. same.. can we make the agent host optional.

  8. can we make from & to optional make it to default - now & now - 15m

    1. This is pdf generation code which was using LLB Stats. Have commented it for now, will have to take it up when we work on the report generation.

  9. 
      
apoorva.sn
pmurugaiyan
  1. 
      
  2. can we rename to send & received, it makes parsing easier. In UI, we can use the common service to parse these values to do transformation accordingly.

    1. Using generic field names like sent and received can be ambiguous from an API perspective, especially when the context (client/server, throughput type) isn’t clear.
      It’s better to use descriptive names like server_sent, client_received, etc., so the API response is self-explanatory and easier for consumers to parse.

    2. We have to have separate parsers for unique names. AMP3 we haven't released the API alone. For, AMP4 its not planned yet. Having sent & received will make our data processing easier at the GUI/API parsers.

      Client / Server can be derived from endpoint itself, no need to flag for every field.

    3. from API standpoint it is better if we have different names, as the response will be much cleaner and also future proof in case we expose API to customers

  3. nitpick - content_type not required for JsonResponse.

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