Skip to content

feat(egress): add Prometheus metrics, METRICS.md, and metrics fetch in smoke tests#247

Draft
Pangjiping wants to merge 1 commit intoalibaba:mainfrom
Pangjiping:feat/egress/metric
Draft

feat(egress): add Prometheus metrics, METRICS.md, and metrics fetch in smoke tests#247
Pangjiping wants to merge 1 commit intoalibaba:mainfrom
Pangjiping:feat/egress/metric

Conversation

@Pangjiping
Copy link
Collaborator

Summary

  • Add pkg/metrics with metric definitions (DNS, policy, nftables, violations, info, uptime)
  • Expose GET /metrics on policy server; instance_id from OPENSANDBOX_EGRESS_INSTANCE_ID
  • Instrument dnsproxy, policy server, and nft setup; add prometheus/client_golang dependency
  • Add METRICS.md (English) documenting metrics and instance identification
  • Smoke tests: fetch metrics once after all tests pass (smoke-dns, smoke-nft, smoke-dynamic-ip)

Testing

  • Not run (explain why)
  • Unit tests
  • Integration tests
  • e2e / manual verification

Breaking Changes

  • None
  • Yes (describe impact and migration path)

Checklist

@Pangjiping Pangjiping added feature New feature or request component/egress labels Feb 26, 2026
@jwx0925
Copy link
Collaborator

jwx0925 commented Feb 27, 2026

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 93ee89a8f4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +147 to +151
NftDohDotPacketsDroppedTotal = promauto.NewCounterVec(
prometheus.CounterOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "nft_doh_dot_packets_dropped_total",

Choose a reason for hiding this comment

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

P2 Badge Wire DoH/DoT drop counter to real drop events

This metric is declared but never incremented in the new instrumentation paths (there is no NftDohDotPacketsDroppedTotal.WithLabelValues(...).Inc() call in nft.go, policy_server.go, or other egress code), so in dns+nft mode /metrics will never surface actual DoH/DoT drops. Any dashboard or alert relying on opensandbox_egress_nft_doh_dot_packets_dropped_total will silently under-report enforcement behavior.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/egress feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FEATURE: egress stage-4 for audit logs and metrics

2 participants