Skip to content

Commit

Permalink
Merge pull request #34 from mixbytes/feat_add_oracle_movr_balance_metric
Browse files Browse the repository at this point in the history
Added the oracle balance prometheus metric
  • Loading branch information
Oladiy authored Apr 18, 2022
2 parents 82da851 + 73e599f commit 1cad4cf
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ oracleservice/__pycache__

*.swp

.idea
prompt.py
*.cmd
*.json
39 changes: 20 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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** <br> *Gauge* | Virtual memory size in bytes | Every call |
| **process_resident_memory_bytes** <br> *Gauge* | Resident memory size in bytes | Every call |
| **process_start_time_seconds** <br> *Gauge* | Start time of the process since unix epoch in seconds | Every call |
| **process_cpu_seconds_total** <br> *Counter* | Total user and system CPU time spent in seconds | Every call |
| **process_open_fds** <br> *Gauge* | Number of open file descriptors | Every call |
| **process_max_fds** <br> *Gauge* | Maximum number of open file descriptors | Every call |
| **agent** <br> *Info* | The address of the connected relay chain node | Each reconnection |
| **is_recovery_mode_active** <br> *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** <br> *Gauge* | Active era index | Every change of era |
| **last_era_reported** <br> *Gauge* | The last era that the Oracle has reported | After completing the sending of reports for the era |
| **previous_era_change_block_number** <br> *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** <br> *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** <br> *Gauge* | Total free balance of all stash accounts for the era | Every time a new report is generated |
| **tx_revert** <br> *Histogram* | Number of failed transactions | Every unsuccessful sending of a report |
| **tx_success** <br> *Histogram* | Number of successful transactions | Every successful sending of a report |
| **para_exceptions_count** <br> *Counter* | Parachain exceptions count | |
| **relay_exceptions_count** <br> *Counter* | Relay chain exceptions count | |
| name | description | frequency |
|----------------------------------------------------------------|--------------------------------------------------------------------------------------------------|--------------------------------------------------------------|
| **process_virtual_memory_bytes** <br> *Gauge* | Virtual memory size in bytes | Every call |
| **process_resident_memory_bytes** <br> *Gauge* | Resident memory size in bytes | Every call |
| **process_start_time_seconds** <br> *Gauge* | Start time of the process since unix epoch in seconds | Every call |
| **process_cpu_seconds_total** <br> *Counter* | Total user and system CPU time spent in seconds | Every call |
| **process_open_fds** <br> *Gauge* | Number of open file descriptors | Every call |
| **process_max_fds** <br> *Gauge* | Maximum number of open file descriptors | Every call |
| **agent** <br> *Info* | The address of the connected relay chain node | Each reconnection |
| **is_recovery_mode_active** <br> *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** <br> *Gauge* | Active era index | Every change of era |
| **last_era_reported** <br> *Gauge* | The last era that the Oracle has reported | After completing the sending of reports for the era |
| **previous_era_change_block_number** <br> *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** <br> *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** <br> *Gauge* | Total free balance of all stash accounts for the era | Every time a new report is generated |
| **oracle_movr_balance** <br> *Gauge* | Oracle MOVR balance | Every change of era |
| **tx_revert** <br> *Histogram* | Number of failed transactions | Every unsuccessful sending of a report |
| **tx_success** <br> *Histogram* | Number of successful transactions | Every successful sending of a report |
| **para_exceptions_count** <br> *Counter* | Parachain exceptions count | |
| **relay_exceptions_count** <br> *Counter* | Relay chain exceptions count | |
2 changes: 2 additions & 0 deletions oracleservice/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions oracleservice/prometheus_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1cad4cf

Please sign in to comment.