diff --git a/.gitignore b/.gitignore index 82aa1e9..ab4f62a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ oracleservice/__pycache__ *.swp +.idea prompt.py *.cmd *.json diff --git a/README.md b/README.md index b19eee7..79c937b 100644 --- a/README.md +++ b/README.md @@ -88,22 +88,23 @@ sudo docker run -e ORACLE_PRIVATE_KEY=${ORACLE_PRIVATE_KEY} --name oracle_${ORAC Prometheus exporter is running on port 8000 by default and provides the following metrics. -| name | description | frequency | -| ---------------------------------------- | -----------------------------------------------------------------|-------------------------------------------| -| **process_virtual_memory_bytes**
*Gauge* | Virtual memory size in bytes | Every call | -| **process_resident_memory_bytes**
*Gauge* | Resident memory size in bytes | Every call | -| **process_start_time_seconds**
*Gauge* | Start time of the process since unix epoch in seconds | Every call | -| **process_cpu_seconds_total**
*Counter* | Total user and system CPU time spent in seconds | Every call | -| **process_open_fds**
*Gauge* | Number of open file descriptors | Every call | -| **process_max_fds**
*Gauge* | Maximum number of open file descriptors | Every call | -| **agent**
*Info* | The address of the connected relay chain node | Each reconnection | -| **is_recovery_mode_active**
*Gauge* | Is oracle-service in recovery mode or not: 1, if the recovery mode, otherwise - the default mode | Starting and ending recovery mode | -| **active_era_id**
*Gauge* | Active era index | Every change of era | -| **last_era_reported**
*Gauge* | The last era that the Oracle has reported | After completing the sending of reports for the era | -| **previous_era_change_block_number**
*Gauge* | Block number of the previous era change | Every change of era, if at least one stash account was found | -| **time_elapsed_until_last_era_report**
*Gauge* | The time elapsed until the last report from the UNIX epoch in seconds | After each successful sending of a report | -| **total_stashes_free_balance**
*Gauge* | Total free balance of all stash accounts for the era | Every time a new report is generated | -| **tx_revert**
*Histogram* | Number of failed transactions | Every unsuccessful sending of a report | -| **tx_success**
*Histogram* | Number of successful transactions | Every successful sending of a report | -| **para_exceptions_count**
*Counter* | Parachain exceptions count | | -| **relay_exceptions_count**
*Counter* | Relay chain exceptions count | | +| name | description | frequency | +|----------------------------------------------------------------|--------------------------------------------------------------------------------------------------|--------------------------------------------------------------| +| **process_virtual_memory_bytes**
*Gauge* | Virtual memory size in bytes | Every call | +| **process_resident_memory_bytes**
*Gauge* | Resident memory size in bytes | Every call | +| **process_start_time_seconds**
*Gauge* | Start time of the process since unix epoch in seconds | Every call | +| **process_cpu_seconds_total**
*Counter* | Total user and system CPU time spent in seconds | Every call | +| **process_open_fds**
*Gauge* | Number of open file descriptors | Every call | +| **process_max_fds**
*Gauge* | Maximum number of open file descriptors | Every call | +| **agent**
*Info* | The address of the connected relay chain node | Each reconnection | +| **is_recovery_mode_active**
*Gauge* | Is oracle-service in recovery mode or not: 1, if the recovery mode, otherwise - the default mode | Starting and ending recovery mode | +| **active_era_id**
*Gauge* | Active era index | Every change of era | +| **last_era_reported**
*Gauge* | The last era that the Oracle has reported | After completing the sending of reports for the era | +| **previous_era_change_block_number**
*Gauge* | Block number of the previous era change | Every change of era, if at least one stash account was found | +| **time_elapsed_until_last_era_report**
*Gauge* | The time elapsed until the last report from the UNIX epoch in seconds | After each successful sending of a report | +| **total_stashes_free_balance**
*Gauge* | Total free balance of all stash accounts for the era | Every time a new report is generated | +| **oracle_movr_balance**
*Gauge* | Oracle MOVR balance | Every change of era | +| **tx_revert**
*Histogram* | Number of failed transactions | Every unsuccessful sending of a report | +| **tx_success**
*Histogram* | Number of successful transactions | Every successful sending of a report | +| **para_exceptions_count**
*Counter* | Parachain exceptions count | | +| **relay_exceptions_count**
*Counter* | Relay chain exceptions count | | diff --git a/oracleservice/oracle.py b/oracleservice/oracle.py index 3ef64dd..116a3af 100644 --- a/oracleservice/oracle.py +++ b/oracleservice/oracle.py @@ -274,6 +274,8 @@ def _handle_era_change(self, active_era_id: int, era_start_timestamp: int): self._sign_and_send_to_para(tx, stash, active_era_id - 1) else: logger.info(f"Skipping sending the transaction for stash {stash.ss58_address}: oracle is running in debug mode") + balance = self.service_params.w3.eth.get_balance(self.account.address) + metrics_exporter.oracle_balance.labels(self.account.address).set(balance) self.last_era_reported[stash.public_key] = active_era_id - 1 logger.info("Waiting for the next era") diff --git a/oracleservice/prometheus_metrics.py b/oracleservice/prometheus_metrics.py index 7669ade..e8f1966 100644 --- a/oracleservice/prometheus_metrics.py +++ b/oracleservice/prometheus_metrics.py @@ -24,6 +24,7 @@ def __post_init__(self, _prefix: str): self.time_elapsed_until_last_report = Gauge('time_elapsed_until_last_report', "the time elapsed until the last report from the unix epoch in seconds", namespace=_prefix) # noqa: E501 self.total_stashes_free_balance = Gauge('total_stashes_free_balance', "total free balance of all stash accounts", namespace=_prefix) # noqa: E501 + self.oracle_balance = Gauge('oracle_balance', "oracle balance [wei]", ['address'], namespace=_prefix) self.tx_revert = Histogram('tx_revert', "reverted transactions", namespace=_prefix) self.tx_success = Histogram('tx_success', "successful transactions", namespace=_prefix)