Add unauthenticated /metrics endpoint on port 15692#1198
Add unauthenticated /metrics endpoint on port 15692#1198carlhoerberg wants to merge 2 commits intomainfrom
Conversation
Run ID: 16532328713
|
Claude finished @carlhoerberg's task —— View job PR Review: Add unauthenticated /metrics endpoint on port 15692I've conducted a comprehensive review of this PR. The implementation looks solid overall with good architectural decisions and security considerations. Review Tasks:
🟢 Overall Assessment: LGTM with Minor SuggestionsThis is a well-implemented feature that addresses issue #1162 effectively. The code follows good practices and maintains security through localhost-only binding. ✅ StrengthsSecurity:
Architecture:
Code Quality:
🟡 Minor Suggestions1. Input Validation Enhancement ( # Current: Only validates bytesize
if prefix.bytesize > 20
# Suggestion: Add character validation for security
if prefix.bytesize > 20 || !prefix.matches?(/^[a-zA-Z_][a-zA-Z0-9_]*$/)
context.response.status_code = 400
context.response.print "Invalid prefix format"
return
end2. Error Handling Consistency ( # Current: Simple text response
context.response.print "Not Found"
# Suggestion: Include valid paths for better UX
context.response.print "Not Found. Available endpoints: /metrics, /metrics/detailed"3. Configuration Validation ( p.on("--metrics-port=PORT", "Metrics port to listen on without auth (default: 15692)") do |v|
port = v.to_i
raise "Metrics port must be between 1 and 65535" unless (1..65535).includes?(port)
@metrics_port = port
end📊 Test Coverage AnalysisExcellent coverage includes:
Potential additional tests:
🚀 Performance Considerations
🔒 Security AssessmentThe security model is appropriate for the use case:
📝 Code Quality ObservationsPrometheus Controller Changes (lines 72-86, 103-124):
Launcher Integration (lines 71, 184-188):
🎯 RecommendationApprove and merge - this is a solid implementation that effectively addresses the requirements. The minor suggestions are optional improvements that don't impact the core functionality or security model. The feature successfully provides:
|
|
@claude modify this pr, when MetricServer is run in a replication follower an amqp_server can't be injected, so make it optional. |
|
Claude finished @carlhoerberg's task —— View job I've successfully modified the PR to make amqp_server optional in MetricsServer for replication follower scenarios. Tasks Completed:
Changes Made:
Summary:The changes ensure that when MetricsServer runs in a replication follower context where amqp_server can't be injected, the metrics server still functions properly. Server-specific metrics return default values (0) while system-level metrics (like file descriptors, GC stats) are still available when applicable. This addresses the original issue where followers couldn't start the metrics server due to the missing amqp_server dependency. Commit: |
- Modified MetricsServer to accept optional amqp_server parameter - Updated PrometheusController to handle nil amqp_server gracefully - All metrics methods now return default values (0) when amqp_server is nil - Added test case for follower scenario without amqp_server - Ensures metrics endpoint works in replication follower contexts 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Carl Hörberg <carlhoerberg@users.noreply.github.com>
This implements the ability to serve Prometheus metrics without authentication on localhost:15692 (configurable), addressing the need for simplified metrics scraping as described in issue #1162.
Key Changes
The metrics server only binds to localhost for security and serves both /metrics and /metrics/detailed endpoints. Followers expose the same metrics they can provide (CPU/RAM/GC metrics and replication-related data).
Fixes #1162
Generated with Claude Code