Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken REST API #8999

Open
DGabri opened this issue Feb 26, 2025 · 1 comment
Open

Broken REST API #8999

DGabri opened this issue Feb 26, 2025 · 1 comment
Assignees
Labels
Bug Ready to Test a feedback is needed on a proposal or implementation

Comments

@DGabri
Copy link
Contributor

DGabri commented Feb 26, 2025

lua/rest/v2/get/alert/top.lua

Fails when invoked, instead of returning an error code, it returns rubbish

curl -u admin:admin -H "Content-Type: application/json" -d '{"ifid": "0"}' http://localhost:3000/lua/rest/v2/get/alert/top.lua

/ntopng/scripts/lua/modules/alert_store/alert_store.lua:1814: bad argument #1 to 'for iterator' (table expected, got string)

@MatteoBiscosi
Copy link
Member

MatteoBiscosi commented Feb 28, 2025

The issue should now be fixed, however consider the following, if you want ALL the alerts, you need to add the status filter to the query, otherwise only the "important" alerts are displayed.
I'd suggest specifing in the Documented rest api that by default only the important one are displayed ("historical"); if all the alerts needs to be displayed, the filter is "all" otherwise only the engaged one is "engaged":

biscosi@devele:~/ntopng$ curl -u admin:admin1 -H "Content-Type: application/json" -d '{"ifid": "11", "status": "any"}' http://localhost:3000/lua/rest/v2/get/alert/top.lua

{"rc":0,"rsp":[{"value":[{"title":"ACL Violation (ICMP/TCP/UDP)","count":95,"key":"alert_id","label":"ACL Violation (ICMP/TCP/…","value":102},{"title":"Probing Attempt","count":0,"key":"alert_id","label":"Probing Attempt","value":101},{"title":"Periodic Flow","count":0,"key":"alert_id","label":"Periodic Flow","value":88},{"title":"Error Code","count":0,"key":"alert_id","label":"Error Code","value":71},{"title":"Slow Periodic Activity","count":0,"key":"alert_id","label":"Slow Periodic Activity","value":4128},{"title":"Packet Drops","count":0,"key":"alert_id","label":"Packet Drops","value":4137},{"title":"Minor Issues","count":0,"key":"alert_id","label":"Minor Issues","value":89}],"label":"Top Alerts By Count","name":"top_alerts_by_count","tooltip":"Most seen alerts"},{"value":[{"title":"ACL Violation (ICMP/TCP/UDP)","severity_label":"Error","severity":"5","key":"alert_id","label":"ACL Violation (ICMP/TCP/…","value":102},{"title":"Slow Periodic Activity","severity_label":"Error","severity":"5","key":"alert_id","label":"Slow Periodic Activity","value":4128},{"title":"Packet Drops","severity_label":"Error","severity":"5","key":"alert_id","label":"Packet Drops","value":4137},{"title":"Probing Attempt","severity_label":"Warning","severity":"4","key":"alert_id","label":"Probing Attempt","value":101},{"title":"Periodic Flow","severity_label":"Notice","severity":"3","key":"alert_id","label":"Periodic Flow","value":88},{"title":"Error Code","severity_label":"Notice","severity":"3","key":"alert_id","label":"Error Code","value":71},{"title":"Minor Issues","severity_label":"Notice","severity":"3","key":"alert_id","label":"Minor Issues","value":89}],"label":"Top Alerts By Severity","name":"top_alerts_by_severity","tooltip":"Alerts with higher severity"}],"rc_str_hr":"Success","rc_str":"OK"}

@MatteoBiscosi MatteoBiscosi added the Ready to Test a feedback is needed on a proposal or implementation label Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Ready to Test a feedback is needed on a proposal or implementation
Projects
None yet
Development

No branches or pull requests

2 participants