Skip to content

Conversation

@mosheharary-ts
Copy link

This commit implements a new optional feature for tracking HTTP requests at the path level, grouped by zone, path, and HTTP status code. Key changes:

Core functionality:

  • Add new metric cloudflare_zone_requests_status_path with labels for zone, account, status, and path
  • Implement path normalization to strip query strings and fragments for reduced cardinality
  • Add configurable path limit per zone (1-1000, default 100) to control metric cardinality
  • Add status code filtering with support for individual codes, ranges, or combinations
  • Disable path metrics for free-tier accounts as this requires premium Cloudflare features
  • Fetch path metrics using new GraphQL query with adaptive grouping

Configuration:

  • Add ENABLE_PATH_METRICS flag (default: false) to enable the feature
  • Add PATH_METRICS_LIMIT flag (default: 100) to control max paths per zone
  • Add PATH_METRICS_STATUS_FILTER flag to filter by HTTP status codes

Documentation:

  • Update README.md with usage examples for path metrics and status filtering
  • Add Helm chart configuration for pathMetrics.enabled and pathMetrics.limit
  • Update chart README with usage examples and cardinality warnings

Docker and testing:

  • Add Dockerfile with multi-stage build using Go 1.25 and Alpine
  • Add docker-compose.yml with Prometheus integration for local testing
  • Add prometheus.yml configuration for scraping the exporter
  • Add env.example template for API token configuration
  • Add comprehensive tests for path metrics validation and label structure

This feature addresses PLTOPS-4619 and provides enhanced visibility into request patterns at the path level for detailed traffic analysis.

Pull Request Template

Description

Please provide a brief description of the changes in this PR.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Other (please describe):

Testing

  • I have run make release-tests and all tests pass
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Code Quality

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

Before Submitting

Please ensure you have completed the following before submitting your PR:

# Run comprehensive tests
make release-tests

If the above command fails, please fix the issues before submitting your PR.

Additional Notes

Add any other context about the pull request here.

This commit implements a new optional feature for tracking HTTP requests
at the path level, grouped by zone, path, and HTTP status code. Key changes:

Core functionality:
- Add new metric cloudflare_zone_requests_status_path with labels for zone, account, status, and path
- Implement path normalization to strip query strings and fragments for reduced cardinality
- Add configurable path limit per zone (1-1000, default 100) to control metric cardinality
- Add status code filtering with support for individual codes, ranges, or combinations
- Disable path metrics for free-tier accounts as this requires premium Cloudflare features
- Fetch path metrics using new GraphQL query with adaptive grouping

Configuration:
- Add ENABLE_PATH_METRICS flag (default: false) to enable the feature
- Add PATH_METRICS_LIMIT flag (default: 100) to control max paths per zone
- Add PATH_METRICS_STATUS_FILTER flag to filter by HTTP status codes

Documentation:
- Update README.md with usage examples for path metrics and status filtering
- Add Helm chart configuration for pathMetrics.enabled and pathMetrics.limit
- Update chart README with usage examples and cardinality warnings

Docker and testing:
- Add Dockerfile with multi-stage build using Go 1.25 and Alpine
- Add docker-compose.yml with Prometheus integration for local testing
- Add prometheus.yml configuration for scraping the exporter
- Add env.example template for API token configuration
- Add comprehensive tests for path metrics validation and label structure

This feature addresses PLTOPS-4619 and provides enhanced visibility into
request patterns at the path level for detailed traffic analysis.
@haad
Copy link
Contributor

haad commented Nov 13, 2025

Can anyone test this PR on account with multiple zones ? @aw or @sprsquish ?

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.

2 participants