Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions miner-apps/jd-client/src/lib/monitoring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ fn downstream_to_sv2_client_info(client: &Downstream) -> Option<Sv2ClientInfo> {
rollable_extranonce_size: extended_channel.get_rollable_extranonce_size(),
expected_shares_per_minute: extended_channel.get_shares_per_minute(),
shares_accepted: share_accounting.get_shares_accepted(),
shares_rejected: 0,
share_work_sum: share_accounting.get_share_work_sum(),
last_share_sequence_number: share_accounting.get_last_share_sequence_number(),
best_diff: share_accounting.get_best_diff(),
Expand All @@ -113,6 +114,7 @@ fn downstream_to_sv2_client_info(client: &Downstream) -> Option<Sv2ClientInfo> {
extranonce_prefix_hex: hex::encode(standard_channel.get_extranonce_prefix()),
expected_shares_per_minute: standard_channel.get_shares_per_minute(),
shares_accepted: share_accounting.get_shares_accepted(),
shares_rejected: 0,
share_work_sum: share_accounting.get_share_work_sum(),
last_share_sequence_number: share_accounting.get_last_share_sequence_number(),
best_diff: share_accounting.get_best_diff(),
Expand Down
2 changes: 2 additions & 0 deletions pool-apps/pool/src/lib/monitoring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ fn downstream_to_sv2_client_info(client: &Downstream) -> Option<Sv2ClientInfo> {
rollable_extranonce_size: extended_channel.get_rollable_extranonce_size(),
expected_shares_per_minute: extended_channel.get_shares_per_minute(),
shares_accepted: share_accounting.get_shares_accepted(),
shares_rejected: 0,
share_work_sum: share_accounting.get_share_work_sum(),
last_share_sequence_number: share_accounting.get_last_share_sequence_number(),
best_diff: share_accounting.get_best_diff(),
Expand All @@ -62,6 +63,7 @@ fn downstream_to_sv2_client_info(client: &Downstream) -> Option<Sv2ClientInfo> {
extranonce_prefix_hex: hex::encode(standard_channel.get_extranonce_prefix()),
expected_shares_per_minute: standard_channel.get_shares_per_minute(),
shares_accepted: share_accounting.get_shares_accepted(),
shares_rejected: 0,
share_work_sum: share_accounting.get_share_work_sum(),
last_share_sequence_number: share_accounting.get_last_share_sequence_number(),
best_diff: share_accounting.get_best_diff(),
Expand Down
7 changes: 5 additions & 2 deletions stratum-apps/src/monitoring/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,18 @@ tokio::spawn(async move {
- `sv2_server_channels{channel_type}` - Server channels by type (extended/standard)
- `sv2_server_hashrate_total` - Total server hashrate
- `sv2_server_channel_hashrate{channel_id, user_identity}` - Per-channel hashrate
- `sv2_server_shares_accepted_total{channel_id, user_identity}` - Per-channel shares
- `sv2_server_shares_accepted_total{channel_id, user_identity}` - Per-channel accepted shares
- `sv2_server_shares_submitted_total{channel_id, user_identity}` - Per-channel submitted (validated) shares
- `sv2_server_shares_rejected_total{channel_id, user_identity, error_code}` - Per-channel rejected shares by error code
- `sv2_server_blocks_found_total` - Total blocks found across all current server channels

**Clients:**
- `sv2_clients_total` - Connected client count
- `sv2_client_channels{channel_type}` - Client channels by type (extended/standard)
- `sv2_client_hashrate_total` - Total client hashrate
- `sv2_client_channel_hashrate{client_id, channel_id, user_identity}` - Per-channel hashrate
- `sv2_client_shares_accepted_total{client_id, channel_id, user_identity}` - Per-channel shares
- `sv2_client_shares_accepted_total{client_id, channel_id, user_identity}` - Per-channel accepted shares
- `sv2_client_shares_rejected_total{client_id, channel_id, user_identity}` - Per-channel rejected shares
- `sv2_client_blocks_found_total` - Total blocks found across all current client channels

**Sv1 (Translator Proxy only):**
Expand Down
4 changes: 4 additions & 0 deletions stratum-apps/src/monitoring/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub struct ExtendedChannelInfo {
pub rollable_extranonce_size: u16,
pub expected_shares_per_minute: f32,
pub shares_accepted: u32,
pub shares_rejected: u32,
pub share_work_sum: f64,
pub last_share_sequence_number: u32,
pub best_diff: f64,
Expand All @@ -39,6 +40,7 @@ pub struct StandardChannelInfo {
pub extranonce_prefix_hex: String,
pub expected_shares_per_minute: f32,
pub shares_accepted: u32,
pub shares_rejected: u32,
pub share_work_sum: f64,
pub last_share_sequence_number: u32,
pub best_diff: f64,
Expand Down Expand Up @@ -154,6 +156,7 @@ mod tests {
rollable_extranonce_size: 4,
expected_shares_per_minute: 1.0,
shares_accepted: 10,
shares_rejected: 0,
share_work_sum: 100.0,
last_share_sequence_number: 5,
best_diff: 50.0,
Expand All @@ -174,6 +177,7 @@ mod tests {
extranonce_prefix_hex: "bb".into(),
expected_shares_per_minute: 2.0,
shares_accepted: 20,
shares_rejected: 0,
share_work_sum: 200.0,
last_share_sequence_number: 8,
best_diff: 80.0,
Expand Down
6 changes: 4 additions & 2 deletions stratum-apps/src/monitoring/http_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl MonitoringServer {
let has_server = snapshot.server_info.is_some();
let has_sv2_clients = snapshot.sv2_clients_summary.is_some();

// Create metrics with SV1 monitoring enabled
// Re-create metrics with SV1 enabled
let metrics = PrometheusMetrics::new(has_server, has_sv2_clients, true)?;

// Add Sv1 clients source and attach new metrics to the cache
Expand Down Expand Up @@ -806,6 +806,7 @@ mod tests {
rollable_extranonce_size: 4,
expected_shares_per_minute: 1.0,
shares_accepted: 10,
shares_rejected: 0,
share_work_sum: 100.0,
last_share_sequence_number: 5,
best_diff: 50.0,
Expand All @@ -829,6 +830,7 @@ mod tests {
extranonce_prefix_hex: "bb".into(),
expected_shares_per_minute: 2.0,
shares_accepted: 20,
shares_rejected: 0,
share_work_sum: 200.0,
last_share_sequence_number: 8,
best_diff: 80.0,
Expand All @@ -853,10 +855,10 @@ mod tests {
rollable_extranonce_size: 4,
version_rolling: true,
shares_acknowledged: 10,
shares_submitted: 12,
shares_rejected: 0,
shares_rejected_by_reason: HashMap::new(),
share_work_sum: 100.0,
shares_submitted: 12,
best_diff: 50.0,
blocks_found: 0,
}
Expand Down
46 changes: 44 additions & 2 deletions stratum-apps/src/monitoring/prometheus_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ pub struct PrometheusMetrics {
pub sv2_server_hashrate_total: Option<Gauge>,
pub sv2_server_channel_hashrate: Option<GaugeVec>,
pub sv2_server_shares_accepted_total: Option<GaugeVec>,
pub sv2_server_shares_submitted_total: Option<GaugeVec>,
pub sv2_server_shares_rejected_total: Option<GaugeVec>,
pub sv2_server_blocks_found_total: Option<Gauge>,
// Clients metrics (downstream connections)
pub sv2_clients_total: Option<Gauge>,
pub sv2_client_channels: Option<GaugeVec>,
pub sv2_client_hashrate_total: Option<Gauge>,
pub sv2_client_channel_hashrate: Option<GaugeVec>,
pub sv2_client_shares_accepted_total: Option<GaugeVec>,
pub sv2_client_shares_rejected_total: Option<GaugeVec>,
pub sv2_client_blocks_found_total: Option<Gauge>,
// SV1 metrics
pub sv1_clients_total: Option<Gauge>,
Expand All @@ -45,6 +48,8 @@ impl PrometheusMetrics {
sv2_server_hashrate_total,
sv2_server_channel_hashrate,
sv2_server_shares_accepted_total,
sv2_server_shares_submitted_total,
sv2_server_shares_rejected_total,
sv2_server_blocks_found_total,
) = if enable_server_metrics {
let channels = GaugeVec::new(
Expand Down Expand Up @@ -77,6 +82,24 @@ impl PrometheusMetrics {
)?;
registry.register(Box::new(shares_accepted.clone()))?;

let shares_submitted = GaugeVec::new(
Opts::new(
"sv2_server_shares_submitted_total",
"Total shares submitted (validated) per server channel",
),
&["channel_id", "user_identity"],
)?;
registry.register(Box::new(shares_submitted.clone()))?;

let shares_rejected = GaugeVec::new(
Opts::new(
"sv2_server_shares_rejected_total",
"Total shares rejected per server channel by error code",
),
&["channel_id", "user_identity", "error_code"],
)?;
registry.register(Box::new(shares_rejected.clone()))?;

let blocks_found = Gauge::new(
"sv2_server_blocks_found_total",
"Total blocks found across all current server channels",
Expand All @@ -88,10 +111,12 @@ impl PrometheusMetrics {
Some(hashrate),
Some(channel_hashrate),
Some(shares_accepted),
Some(shares_submitted),
Some(shares_rejected),
Some(blocks_found),
)
} else {
(None, None, None, None, None)
(None, None, None, None, None, None, None)
};

// Clients metrics (downstream connections)
Expand All @@ -101,6 +126,7 @@ impl PrometheusMetrics {
sv2_client_hashrate_total,
sv2_client_channel_hashrate,
sv2_client_shares_accepted_total,
sv2_client_shares_rejected_total,
sv2_client_blocks_found_total,
) = if enable_clients_metrics {
let clients_total =
Expand Down Expand Up @@ -137,6 +163,15 @@ impl PrometheusMetrics {
)?;
registry.register(Box::new(shares_accepted.clone()))?;

let shares_rejected = GaugeVec::new(
Opts::new(
"sv2_client_shares_rejected_total",
"Total shares rejected per client channel",
),
&["client_id", "channel_id", "user_identity"],
)?;
registry.register(Box::new(shares_rejected.clone()))?;

let blocks_found = Gauge::new(
"sv2_client_blocks_found_total",
"Total blocks found across all current client channels",
Expand All @@ -149,10 +184,11 @@ impl PrometheusMetrics {
Some(hashrate),
Some(channel_hashrate),
Some(shares_accepted),
Some(shares_rejected),
Some(blocks_found),
)
} else {
(None, None, None, None, None, None)
(None, None, None, None, None, None, None)
};

// SV1 metrics
Expand All @@ -175,12 +211,15 @@ impl PrometheusMetrics {
sv2_server_hashrate_total,
sv2_server_channel_hashrate,
sv2_server_shares_accepted_total,
sv2_server_shares_submitted_total,
sv2_server_shares_rejected_total,
sv2_server_blocks_found_total,
sv2_clients_total,
sv2_client_channels,
sv2_client_hashrate_total,
sv2_client_channel_hashrate,
sv2_client_shares_accepted_total,
sv2_client_shares_rejected_total,
sv2_client_blocks_found_total,
sv1_clients_total,
sv1_hashrate_total,
Expand Down Expand Up @@ -210,6 +249,8 @@ mod tests {
assert!(m.sv2_server_hashrate_total.is_some());
assert!(m.sv2_server_channel_hashrate.is_some());
assert!(m.sv2_server_shares_accepted_total.is_some());
assert!(m.sv2_server_shares_submitted_total.is_some());
assert!(m.sv2_server_shares_rejected_total.is_some());
// clients and sv1 should be None
assert!(m.sv2_clients_total.is_none());
assert!(m.sv1_clients_total.is_none());
Expand All @@ -223,6 +264,7 @@ mod tests {
assert!(m.sv2_client_hashrate_total.is_some());
assert!(m.sv2_client_channel_hashrate.is_some());
assert!(m.sv2_client_shares_accepted_total.is_some());
assert!(m.sv2_client_shares_rejected_total.is_some());
// server and sv1 should be None
assert!(m.sv2_server_channels.is_none());
assert!(m.sv1_clients_total.is_none());
Expand Down
Loading
Loading