Skip to content

πŸ’š Implement Protocol Health MonitoringΒ #152

Description

@mijinummi

πŸ’š Implement Protocol Health Monitoring

Issue: #152
Type: Feature
Priority: High
Estimated Effort: 2–4 days


🧠 Concept

Implement a Protocol Health Monitoring service that continuously evaluates the operational health of monitored blockchain protocols and smart contract systems. The service should collect key health metrics, detect abnormal behavior, evaluate configurable health thresholds, and generate alerts when protocol conditions indicate potential security, operational, or availability risks.

The monitoring system should provide an early warning mechanism for protocol degradation before it escalates into outages, exploits, or user-facing incidents.


⚠️ Problem

Security incidents are often preceded by changes in protocol behavior, such as declining transaction throughput, spikes in failed transactions, unexpected contract activity, or network instability.

Currently, there is no centralized mechanism to continuously assess protocol health or identify operational anomalies.

Without protocol health monitoring:

  • Performance degradation may go unnoticed until users are affected.
  • Security teams lose valuable early indicators of attacks or exploits.
  • Protocol outages are detected too late.
  • Operational metrics cannot be correlated with security incidents.
  • Long-term health trends are unavailable for analysis.

πŸ“ Implementation Scope

src/modules/protocols/health/

Suggested structure:

health/
β”œβ”€β”€ protocol-health.service.ts
β”œβ”€β”€ health-monitor.service.ts
β”œβ”€β”€ metrics-collector.service.ts
β”œβ”€β”€ health-evaluator.service.ts
β”œβ”€β”€ threshold-engine.service.ts
β”œβ”€β”€ protocol-health.repository.ts
β”œβ”€β”€ dto/
β”œβ”€β”€ entities/
β”œβ”€β”€ interfaces/
β”œβ”€β”€ enums/
β”œβ”€β”€ alerts/
└── utils/

βœ… Requirements

Protocol Registration

Support monitoring one or more configured protocols.

Each monitored protocol should include configurable metadata such as:

  • Protocol name
  • Network
  • Version (optional)
  • Monitored contracts
  • Monitoring interval
  • Enabled/disabled status

The design should support onboarding additional protocols with minimal configuration changes.


Health Metrics Collection

Continuously collect operational metrics for monitored protocols.

Example metrics include:

  • Transaction throughput (TPS)
  • Transaction success rate
  • Failed transaction rate
  • Contract invocation frequency
  • Event emission rate
  • Block processing rate
  • Active user/account count
  • Gas or fee consumption (where applicable)
  • Average transaction confirmation time
  • RPC/API availability
  • Contract execution failures

Metrics should be timestamped and persisted for historical analysis.


Activity Monitoring

Monitor protocol activity for abnormal behavior, including:

  • Sudden spikes in transaction volume
  • Sharp declines in protocol activity
  • Large increases in failed transactions
  • Unexpected contract interaction patterns
  • Significant reductions in active users
  • Prolonged inactivity
  • Repeated execution failures
  • Unusual event generation rates

The monitoring engine should support configurable observation windows for short-term and long-term analysis.


Health Evaluation Engine

Implement a health evaluation engine that derives an overall protocol health status from collected metrics.

Example health states:

  • Healthy
  • Degraded
  • Warning
  • Critical
  • Offline

Health evaluations should consider multiple metrics together rather than relying on a single threshold.


Threshold Monitoring

Support configurable thresholds for individual health metrics.

Example thresholds:

  • Failed transaction rate exceeds 15%
  • TPS falls below configured baseline
  • API availability below 99%
  • Contract execution failures exceed threshold
  • Confirmation time exceeds acceptable limits
  • Activity drops by more than a configured percentage

Thresholds should be configurable per protocol rather than globally hardcoded.


Historical Health Tracking

Persist protocol health snapshots including:

  • Timestamp
  • Health status
  • Individual metric values
  • Threshold evaluation results
  • Overall health score (if applicable)

Historical records should support dashboards, reporting, audits, and incident investigations.


Alert Generation

Generate alerts when:

  • Health thresholds are exceeded
  • Protocol health status changes
  • Metrics deteriorate rapidly
  • A protocol becomes unavailable
  • Activity deviates significantly from historical baselines

Alerts should include:

  • Protocol name
  • Network
  • Triggering metric(s)
  • Observed value
  • Configured threshold
  • Health status
  • Severity
  • Timestamp

Alerts should integrate with the platform's existing notification and incident management pipeline.


Trend Analysis

Support trend calculations for:

  • Health score over time
  • Metric history
  • Performance degradation
  • Recovery trends
  • Threshold breach frequency
  • Protocol availability

These trends should be optimized for frontend dashboards and reporting.


Error Handling

The monitoring service should:

  • Retry transient failures
  • Continue monitoring remaining protocols if one collector fails
  • Log collection and evaluation errors with sufficient context
  • Gracefully handle temporary RPC or API outages

πŸ”’ Non-Functional Requirements

  • Configurable monitoring intervals
  • Modular metrics collection architecture
  • Extensible health evaluation engine
  • Idempotent metric processing
  • Efficient storage for historical metrics
  • Structured logging
  • Type-safe DTOs and entities
  • Unit-testable monitoring logic
  • Scalable architecture supporting multiple protocols concurrently

🎯 Acceptance Criteria

  • Monitored protocols are registered and evaluated automatically
  • Operational health metrics are collected at configurable intervals
  • Protocol activity is monitored for abnormal behavior
  • Configurable health thresholds are evaluated correctly
  • Overall protocol health status is calculated from collected metrics
  • Health snapshots and metric history are persisted for trend analysis
  • Alerts are generated when thresholds are exceeded or health degrades
  • Historical health trends are available for reporting and dashboards
  • Monitoring recovers gracefully from transient failures
  • Code passes linting, type checking, and existing test suites

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaign

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions