Skip to content

Commit

Permalink
fix: average chain rewards metric (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
vgorkavenko committed Jan 30, 2023
1 parent 7aa3102 commit c8035ae
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 39 deletions.
66 changes: 35 additions & 31 deletions docker/grafana/provisioning/dashboards/rewards.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 19,
"iteration": 1673429825910,
"iteration": 1675056856592,
"links": [
{
"asDropdown": false,
Expand Down Expand Up @@ -320,7 +320,8 @@
"value": null
}
]
}
},
"unit": "GWei"
},
"overrides": []
},
Expand Down Expand Up @@ -355,7 +356,7 @@
},
"editorMode": "code",
"exemplar": true,
"expr": "ethereum_validators_monitoring_avg_chain_reward{duty=\"attestation\"} / 10^9 and on() changes(ethereum_validators_monitoring_epoch_number[25s]) > 0",
"expr": "ethereum_validators_monitoring_avg_chain_reward{duty=\"attestation\"} and on() changes(ethereum_validators_monitoring_epoch_number[25s]) > 0",
"interval": "",
"legendFormat": "avg",
"range": true,
Expand Down Expand Up @@ -413,7 +414,8 @@
"value": null
}
]
}
},
"unit": "ETH"
},
"overrides": []
},
Expand Down Expand Up @@ -506,7 +508,8 @@
"value": null
}
]
}
},
"unit": "GWei"
},
"overrides": []
},
Expand Down Expand Up @@ -541,7 +544,7 @@
},
"editorMode": "code",
"exemplar": true,
"expr": "ethereum_validators_monitoring_avg_chain_reward{duty=\"sync\"} / 10^9 and on() changes(ethereum_validators_monitoring_epoch_number[25s]) > 0",
"expr": "ethereum_validators_monitoring_avg_chain_reward{duty=\"sync\"} and on() changes(ethereum_validators_monitoring_epoch_number[25s]) > 0",
"interval": "",
"legendFormat": "avg",
"range": true,
Expand Down Expand Up @@ -600,7 +603,8 @@
"value": null
}
]
}
},
"unit": "GWei"
},
"overrides": []
},
Expand Down Expand Up @@ -635,7 +639,7 @@
},
"editorMode": "code",
"exemplar": true,
"expr": "ethereum_validators_monitoring_avg_chain_penalty{duty=\"attestation\"} / 10^9 and on() changes(ethereum_validators_monitoring_epoch_number[25s]) > 0",
"expr": "ethereum_validators_monitoring_avg_chain_penalty{duty=\"attestation\"} and on() changes(ethereum_validators_monitoring_epoch_number[25s]) > 0",
"interval": "",
"legendFormat": "avg",
"range": true,
Expand Down Expand Up @@ -694,7 +698,8 @@
"value": null
}
]
}
},
"unit": "GWei"
},
"overrides": []
},
Expand Down Expand Up @@ -729,7 +734,7 @@
},
"editorMode": "code",
"exemplar": true,
"expr": "ethereum_validators_monitoring_avg_chain_penalty{duty=\"sync\"} / 10^9 and on() changes(ethereum_validators_monitoring_epoch_number[25s]) > 0",
"expr": "ethereum_validators_monitoring_avg_chain_penalty{duty=\"sync\"} and on() changes(ethereum_validators_monitoring_epoch_number[25s]) > 0",
"interval": "",
"legendFormat": "avg",
"range": true,
Expand Down Expand Up @@ -788,7 +793,8 @@
"value": null
}
]
}
},
"unit": "GWei"
},
"overrides": []
},
Expand Down Expand Up @@ -823,7 +829,7 @@
},
"editorMode": "code",
"exemplar": true,
"expr": "ethereum_validators_monitoring_avg_chain_missed_reward{duty=\"attestation\"} / 10^9 and on() changes(ethereum_validators_monitoring_epoch_number[25s]) > 0",
"expr": "ethereum_validators_monitoring_avg_chain_missed_reward{duty=\"attestation\"} and on() changes(ethereum_validators_monitoring_epoch_number[25s]) > 0",
"interval": "",
"legendFormat": "avg",
"range": true,
Expand Down Expand Up @@ -882,7 +888,8 @@
"value": null
}
]
}
},
"unit": "ETH"
},
"overrides": []
},
Expand Down Expand Up @@ -976,7 +983,8 @@
"value": null
}
]
}
},
"unit": "GWei"
},
"overrides": []
},
Expand Down Expand Up @@ -1011,7 +1019,7 @@
},
"editorMode": "code",
"exemplar": true,
"expr": "ethereum_validators_monitoring_avg_chain_missed_reward{duty=\"sync\"} / 10^9 and on() changes(ethereum_validators_monitoring_epoch_number[25s]) > 0",
"expr": "ethereum_validators_monitoring_avg_chain_missed_reward{duty=\"sync\"} and on() changes(ethereum_validators_monitoring_epoch_number[25s]) > 0",
"interval": "",
"legendFormat": "avg",
"range": true,
Expand Down Expand Up @@ -2378,8 +2386,7 @@
"mode": "absolute",
"steps": [
{
"color": "light-red",
"value": null
"color": "light-red"
}
]
}
Expand Down Expand Up @@ -2649,8 +2656,7 @@
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
"color": "green"
}
]
}
Expand Down Expand Up @@ -2732,8 +2738,7 @@
"mode": "absolute",
"steps": [
{
"color": "light-purple",
"value": null
"color": "light-purple"
}
]
}
Expand Down Expand Up @@ -3036,8 +3041,7 @@
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
"color": "green"
}
]
}
Expand Down Expand Up @@ -3097,8 +3101,8 @@
{
"current": {
"selected": false,
"text": "173498",
"value": "173498"
"text": "177689",
"value": "177689"
},
"datasource": {
"type": "prometheus",
Expand Down Expand Up @@ -3205,8 +3209,8 @@
{
"current": {
"selected": false,
"text": "98.333740234375",
"value": "98.333740234375"
"text": "95.404052734375",
"value": "95.404052734375"
},
"datasource": {
"type": "prometheus",
Expand All @@ -3233,8 +3237,8 @@
{
"current": {
"selected": false,
"text": "9",
"value": "9"
"text": "10",
"value": "10"
},
"datasource": {
"type": "prometheus",
Expand All @@ -3260,7 +3264,7 @@
},
{
"current": {
"selected": true,
"selected": false,
"text": [
"All"
],
Expand Down Expand Up @@ -3334,6 +3338,6 @@
"timezone": "",
"title": "Rewards & Penalties",
"uid": "poBeaLaRD",
"version": 4,
"version": 5,
"weekStart": ""
}
16 changes: 8 additions & 8 deletions src/storage/clickhouse/clickhouse.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,9 @@ export const avgChainRewardsAndPenaltiesStats = (epoch: Epoch): string => `
FROM
(
SELECT
avg(att_earned_reward) as attestation_reward,
avg(att_missed_reward) as attestation_missed,
avg(att_penalty) as attestation_penalty
avgIf(att_earned_reward, att_earned_reward > 0) as attestation_reward,
avgIf(att_missed_reward, att_missed_reward > 0) as attestation_missed,
avgIf(att_penalty, att_penalty > 0) as attestation_penalty
FROM (
SELECT att_earned_reward, att_missed_reward, att_penalty
FROM validators_summary
Expand All @@ -525,8 +525,8 @@ export const avgChainRewardsAndPenaltiesStats = (epoch: Epoch): string => `
) as att,
(
SELECT
avg(propose_earned_reward) as prop_reward,
avg(propose_missed_reward) as prop_missed,
avgIf(propose_earned_reward, propose_earned_reward > 0) as prop_reward,
avgIf(propose_missed_reward, propose_missed_reward > 0) as prop_missed,
avg(propose_penalty) as prop_penalty
FROM (
SELECT propose_earned_reward, propose_missed_reward, propose_penalty
Expand All @@ -537,9 +537,9 @@ export const avgChainRewardsAndPenaltiesStats = (epoch: Epoch): string => `
) as prop,
(
SELECT
avg(sync_earned_reward) as sync_reward,
avg(sync_missed_reward) as sync_missed,
avg(sync_penalty) as sync_penalty
avgIf(sync_earned_reward, sync_earned_reward > 0) as sync_reward,
avgIf(sync_missed_reward, sync_missed_reward > 0) as sync_missed,
avgIf(sync_penalty, sync_penalty > 0) as sync_penalty
FROM (
SELECT sync_earned_reward, sync_missed_reward, sync_penalty
FROM validators_summary
Expand Down

0 comments on commit c8035ae

Please sign in to comment.