Swagger OpenAPI json endpoint caching for Ansible dynamic Inventory? (api/docs/?format=openapi) #5903
-
Hi All, I'm seeing some super slow returns on the https://netbox.example.com/api/docs/?format=openapi endpoint. For me, it's taking almost 15 seconds. I've got Netbox running behind an NGINX reverse proxy and uWSGI (though I see the same with gunicorn). Postgres is running on the same server. I've tried regular proxy_pass with uWSGI doing an HTTP bind and also the native NGINX uwsgi_pass style, with no noticeable difference. I was able to halve the response time (about 6.5s after first GET) by tweaking urls.py, replacing (just testing things out) Since the Swagger schema is really only updated between versions of Netbox, is there a way for me to ease the load on the uWSGI process with the endpoint I mentioned? I don't see much reason to generate it every single time it's GET-requested... The reason I'm asking is because I'm trying to plug Netbox into Ansible as a dynamic inventory. This is the location of the Ansible code (which actually forces this specific endpoint's use): Can anyone shed some light on how I might get this to perform a little better? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Asible netbox inventory queries a bunch of api endpoints by default. To speed that up, you can try to trim that out. For example: if you only want to query physical devices, don't use You could also set I suggest you read the various arguments on https://docs.ansible.com/ansible/latest/collections/netbox/netbox/nb_inventory_inventory.html#ansible-collections-netbox-netbox-nb-inventory-inventory. |
Beta Was this translation helpful? Give feedback.
-
Isn't that for filtering the results though? As I understand it, the dynamic inventory first flat-out queries this endpoint: |
Beta Was this translation helpful? Give feedback.
Asible netbox inventory queries a bunch of api endpoints by default. To speed that up, you can try to trim that out.
For example: if you only want to query physical devices, don't use
query_filters
(since it also queries virtual devices) but usedevice_query_filters
You could also set
fetch_all
to false and do the same forservices
.I suggest you read the various arguments on https://docs.ansible.com/ansible/latest/collections/netbox/netbox/nb_inventory_inventory.html#ansible-collections-netbox-netbox-nb-inventory-inventory.