Skip to content

Expose Prometheus metrics via django-prometheus#743

Merged
matthew-li merged 6 commits intoupgrade/rocky8-python3.13-developfrom
upgrade/rocky8-python3.13-prometheus-metrics
Feb 15, 2026
Merged

Expose Prometheus metrics via django-prometheus#743
matthew-li merged 6 commits intoupgrade/rocky8-python3.13-developfrom
upgrade/rocky8-python3.13-prometheus-metrics

Conversation

@matthew-li
Copy link
Copy Markdown
Collaborator

Description

**** Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. ****

  • Installed and configured django-prometheus to expose Prometheus metrics for Django-related operations at /metrics.
  • Updated the Ansible playbook to restrict access to /metrics by IP and user, requiring basic authentication via .htpasswd.
  • Added web to ALLOWED_HOSTS in the Docker environment, so that a Prometheus instance within the same Docker network may access metrics via web.

Type of change

**** Please delete options that are not relevant. ****

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

**** Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration. ****

  • Ensure that metrics appear at /metrics.
  • Run a local Prometheus instance by extending Docker Compose, and ensure that it scrapes /metrics and is accessible at port 9090:
    • docker-compose.prometheus-extension.yml
      services:
        prometheus:
          image: prom/prometheus:latest
          ports:
            - "9090:9090"
          volumes:
            - ./config/prometheus.yml:/etc/prometheus/prometheus.yml
            - prometheus-data:/prometheus
          command:
            - '--config.file=/etc/prometheus/prometheus.yml'
            - '--storage.tsdb.path=/prometheus'
      
      volumes:
        prometheus-data:
          external: false
      
    • prometheus.yml
      global:
        scrape_interval: 15s
      
      scrape_configs:
        - job_name: 'mybrc'
          static_configs:
            - targets: ['web:80']
      
    • Command: docker compose -p $DOCKER_PROJECT_NAME -f bootstrap/development/docker/docker-compose.yml -f bootstrap/development/docker/docker-compose.prometheus-extension.yml up

PR Self Evaluation

Strikethrough things that don’t make sense for your PR.

  • My code follows the agreed upon best practices
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if needed)
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in the appropriate modules
  • I have performed a self-review of my own code

@matthew-li matthew-li merged commit 1705608 into upgrade/rocky8-python3.13-develop Feb 15, 2026
1 check passed
@matthew-li matthew-li deleted the upgrade/rocky8-python3.13-prometheus-metrics branch March 11, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant