Skip to content

Commit

Permalink
feat: add tracking of missed attestations and consecutive missed atte…
Browse files Browse the repository at this point in the history
…stations
  • Loading branch information
aimxhaisse committed Apr 5, 2024
1 parent da466bb commit d76b3d9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions eth_validator_watcher/entrypoint_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ def _update_metrics(self, watched_validators: WatchedValidators, epoch: int, slo

ideal_consensus_reward: dict[str, int] = defaultdict(int)
actual_consensus_reward: dict[str, int] = defaultdict(int)
missed_attestations: dict[str, int] = defaultdict(int)
missed_consecutive_attestations: dict[str, int] = defaultdict(int)

labels = set()

Expand All @@ -194,6 +196,9 @@ def _update_metrics(self, watched_validators: WatchedValidators, epoch: int, slo
ideal_consensus_reward[label] += validator.ideal_consensus_reward or 0
actual_consensus_reward[label] += validator.actual_consensus_reward or 0

missed_attestations[label] += int(validator.missed_attestation == True)
missed_consecutive_attestations[label] += int(validator.previous_missed_attestation == True and validator.missed_attestation == True)

labels.add(label)

for label, status_count in validator_status_count.items():
Expand All @@ -209,6 +214,9 @@ def _update_metrics(self, watched_validators: WatchedValidators, epoch: int, slo
self._metrics.eth_actual_consensus_rewards.labels(label).set(actual_consensus_reward[label])
self._metrics.eth_consensus_rewards_rate.labels(label).set(pct(actual_consensus_reward[label], ideal_consensus_reward[label], True))

self._metrics.eth_missed_attestations.labels(label).set(missed_attestations[label])
self._metrics.eth_missed_consecutive_attestations.labels(label).set(missed_consecutive_attestations[label])

if not self._metrics_started:
start_http_server(self._cfg.metrics_port)
self._metrics_started = True
Expand Down
4 changes: 4 additions & 0 deletions eth_validator_watcher/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class PrometheusMetrics:
eth_ideal_consensus_rewards: Gauge
eth_actual_consensus_rewards: Gauge
eth_consensus_rewards_rate: Gauge
eth_missed_attestations: Gauge
eth_missed_consecutive_attestations: Gauge


def get_prometheus_metrics() -> PrometheusMetrics:
Expand All @@ -44,6 +46,8 @@ def get_prometheus_metrics() -> PrometheusMetrics:
eth_ideal_consensus_rewards=Gauge("eth_ideal_consensus_rewards", "Ideal consensus rewards", ['scope']),
eth_actual_consensus_rewards=Gauge("eth_actual_consensus_rewards", "Actual consensus rewards", ['scope']),
eth_consensus_rewards_rate=Gauge("eth_consensus_rewards_rate", "Consensus rewards rate", ['scope']),
eth_missed_attestations=Gauge("eth_missed_attestations", "Missed attestations in the last epoch", ['scope']),
eth_missed_consecutive_attestations=Gauge("eth_missed_consecutive_attestations", "Missed consecutive attestations", ['scope']),
)

return _metrics

0 comments on commit d76b3d9

Please sign in to comment.