Skip to content

feat: whitelist Cloudflare metric hosts - #1

Open
ElioTohm wants to merge 1 commit into
masterfrom
feature/host-whitelist-configmap
Open

feat: whitelist Cloudflare metric hosts#1
ElioTohm wants to merge 1 commit into
masterfrom
feature/host-whitelist-configmap

Conversation

@ElioTohm

Copy link
Copy Markdown

Description

Adds optional host filtering for all Cloudflare exporter metrics that expose a host label. The whitelist is loaded from an externally managed ConfigMap mounted as hosts.yaml and reloaded before each scrape.

Type of Change

  • New feature (non-breaking when disabled)
  • Documentation update

Testing

  • Added focused whitelist parsing, filtering, reload, synchronization, and stale-series tests
  • go test ./... -count=1
  • go test ./... -race -count=1
  • helm lint
  • Helm render assertions
  • git diff --check

Configuration

Set hostWhitelist.configMapName in Helm values. The external ConfigMap must contain:

hosts:
  - api.example.com
  - www.example.com

The ConfigMap is mounted without subPath so Kubernetes updates are observed automatically.

Additional Notes

The fork retains the design and implementation plan commits alongside the feature commits.

@ElioTohm
ElioTohm force-pushed the feature/host-whitelist-configmap branch from 523c188 to acad5da Compare August 18, 2026 07:24
@ElioTohm
ElioTohm force-pushed the feature/host-whitelist-configmap branch from acad5da to a60a7d5 Compare August 18, 2026 07:39

@chaosbox chaosbox left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we simplify host_whitelist.go by decoding the file into a typed struct instead of manually walking yaml.Node?

If the accepted format is just:

type HostWhitelist struct {
Hosts []string yaml:"hosts" json:"hosts"
}

then yaml.Unmarshal can handle the parsing/validation, and this file can focus on reload behavior and exact host matching. The current manual schema checks make the implementation harder to follow and more brittle than it needs to be.

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