metrics can not be read without authentication when using BASE_PATH #4937

Closed
opened 2025-12-29 19:22:26 +01:00 by adam · 1 comment
Owner

Originally created by @sthiriet on GitHub (May 21, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v2.10.4

Python version

3.8

Steps to Reproduce

  1. Set METRICS_ENABLED=True
  2. Set LOGIN_REQUIRED=True (added by @jeremystretch)
  3. Set BASE_PATH='netbox/'
  4. HTTP GET on /netbox/metrics url redirect to login page

Expected Behavior

succesfully get metrics

Observed Behavior

Redirection to login url.

Originally created by @sthiriet on GitHub (May 21, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v2.10.4 ### Python version 3.8 ### Steps to Reproduce 1. Set METRICS_ENABLED=True 2. Set LOGIN_REQUIRED=True (added by @jeremystretch) 3. Set BASE_PATH='netbox/' 4. HTTP GET on /netbox/metrics url redirect to login page ### Expected Behavior succesfully get metrics ### Observed Behavior Redirection to login url.
adam added the type: bugstatus: accepted labels 2025-12-29 19:22:26 +01:00
adam closed this issue 2025-12-29 19:22:27 +01:00
Author
Owner

@sthiriet commented on GitHub (May 21, 2021):

From what i see, it should be resolved by modifying this line :

09b856bf0b/netbox/netbox/middleware.py (L27)

with something like

if not request.path_info.startswith((api_path, '/{}metrics'.format(settings.BASE_PATH))) and request.path_info != settings.LOGIN_URL:
@sthiriet commented on GitHub (May 21, 2021): From what i see, it should be resolved by modifying this line : https://github.com/netbox-community/netbox/blob/09b856bf0b3b7faea483b3e37a2942a84ecfd99b/netbox/netbox/middleware.py#L27 with something like ```python if not request.path_info.startswith((api_path, '/{}metrics'.format(settings.BASE_PATH))) and request.path_info != settings.LOGIN_URL: ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4937