Skip to content

Commit

Permalink
Merge pull request #123 from SimplyVC/feature/v0.3.4
Browse files Browse the repository at this point in the history
0.3.4 Code
  • Loading branch information
Cherrett authored Mar 16, 2022
2 parents 664fe5e + 3b4d575 commit 0df20db
Show file tree
Hide file tree
Showing 38 changed files with 559 additions and 420 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class ChainlinkContractAlertCode(AlertCode):
PriceFeedNotObservedIncreaseAboveThreshold = 'cl_contract_alert_1'
PriceFeedObservedAgain = 'cl_contract_alert_2'
PriceFeedDeviationInreasedAboveThreshold = 'cl_contract_alert_3'
PriceFeedDeviationIncreasedAboveThreshold = 'cl_contract_alert_3'
PriceFeedDeviationDecreasedBelowThreshold = 'cl_contract_alert_4'
ConsensusNotReached = 'cl_contract_alert_5'
ErrorContractsNotRetrieved = 'cl_contract_alert_6'
Expand Down
Empty file.
22 changes: 14 additions & 8 deletions alerter/src/alerter/alerters/contract/chainlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from src.alerter.alerters.alerter import Alerter
from src.alerter.factory.chainlink_contract_alerting_factory import \
ChainlinkContractAlertingFactory
from src.alerter.grouped_alerts_metric_code.contract.chainlink_contract_metric_code \
from src.alerter.grouped_alerts_metric_code.contract.\
chainlink_contract_metric_code \
import GroupedChainlinkContractAlertsMetricCode as MetricCode
from src.configs.alerts.contract.chainlink import ChainlinkContractAlertsConfig
from src.configs.factory.node.chainlink_alerts import \
Expand Down Expand Up @@ -153,7 +154,8 @@ def _process_result(self, transformer_data: Dict,
meta_data['node_parent_id'], "",
meta_data['last_monitored'],
MetricCode.ErrorNoSyncedDataSources.value,
"", "Synced EVM data sources found!", None
"", "{} found synced EVM data sources!".format(
meta_data['monitor_name']), None
)

self.alerting_factory.classify_error_alert(
Expand All @@ -164,7 +166,8 @@ def _process_result(self, transformer_data: Dict,
meta_data['node_parent_id'], "",
meta_data['last_monitored'],
MetricCode.ErrorContractsNotRetrieved.value,
"", "Chainlink contracts are now being retrieved!", None
"", "{} is now retrieving chainlink contracts!".format(
meta_data['monitor_name']), None
)

current_historical_rounds = contract_data['historicalRounds'][
Expand Down Expand Up @@ -225,7 +228,8 @@ def _process_result(self, transformer_data: Dict,
data_for_alerting, meta_data['node_parent_id'],
meta_data['node_id'], proxy_address,
MetricCode.PriceFeedNotObserved.value,
meta_data['node_name'], meta_data['last_monitored']
meta_data['node_name'], meta_data['last_monitored'],
contract_data['description']
)

"""
Expand All @@ -245,15 +249,16 @@ def _process_result(self, transformer_data: Dict,
self.alerting_factory. \
classify_thresholded_alert_contract(
current_deviation, sub_config,
cl_alerts.PriceFeedDeviationInreasedAboveThreshold,
cl_alerts.PriceFeedDeviationIncreasedAboveThreshold,
cl_alerts.PriceFeedDeviationDecreasedBelowThreshold,
data_for_alerting,
meta_data['node_parent_id'],
meta_data['node_id'],
proxy_address,
MetricCode.PriceFeedDeviation.value,
meta_data['node_name'],
meta_data['last_monitored']
meta_data['last_monitored'],
contract_data['description']
)

"""
Expand Down Expand Up @@ -284,7 +289,8 @@ def _process_result(self, transformer_data: Dict,
meta_data['last_monitored'],
meta_data['node_parent_id'],
meta_data['node_id'],
proxy_address
proxy_address,
contract_data['description']
], data_for_alerting,
)

Expand Down Expand Up @@ -379,7 +385,7 @@ def _process_configs(
properties: pika.spec.BasicProperties, body: bytes) -> None:
sent_configs = json.loads(body)

self.logger.info("Received configs %s", sent_configs)
self.logger.debug("Received configs %s", sent_configs)

if 'DEFAULT' in sent_configs:
del sent_configs['DEFAULT']
Expand Down
2 changes: 1 addition & 1 deletion alerter/src/alerter/alerters/node/chainlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def _process_configs(
properties: pika.spec.BasicProperties, body: bytes) -> None:
sent_configs = json.loads(body)

self.logger.info("Received configs %s", sent_configs)
self.logger.debug("Received configs %s", sent_configs)

if 'DEFAULT' in sent_configs:
del sent_configs['DEFAULT']
Expand Down
2 changes: 1 addition & 1 deletion alerter/src/alerter/alerters/node/evm.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def _process_configs(
properties: pika.spec.BasicProperties, body: bytes) -> None:
sent_configs = json.loads(body)

self.logger.info("Received configs %s", sent_configs)
self.logger.debug("Received configs %s", sent_configs)

if 'DEFAULT' in sent_configs:
del sent_configs['DEFAULT']
Expand Down
73 changes: 37 additions & 36 deletions alerter/src/alerter/alerts/contract/chainlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,115 +10,116 @@
class PriceFeedObservationsMissedIncreasedAboveThreshold(Alert):
def __init__(self, origin_name: str, missed_observations: int,
severity: str, timestamp: float, threshold_severity: str,
parent_id: str, origin_id: str, proxy_address: str) -> None:
parent_id: str, origin_id: str, proxy_address: str,
contract_description: str) -> None:
alert_data = ChainlinkContractAlertData()
alert_data.set_alert_data(proxy_address)
super().__init__(
ChainlinkContractAlertCode.PriceFeedNotObservedIncreaseAboveThreshold,
ChainlinkContractAlertCode
.PriceFeedNotObservedIncreaseAboveThreshold,
"The Chainlink {} node's missed observations have increased above "
"{} threshold to {} missed observations for price feed {}.".format(
origin_name, threshold_severity, missed_observations,
proxy_address),
contract_description),
severity, timestamp, parent_id, origin_id,
MetricCode.PriceFeedNotObserved, alert_data)


class PriceFeedObservedAgain(Alert):
def __init__(self, origin_name: str, severity: str, timestamp: float,
parent_id: str, origin_id: str, proxy_address: str) -> None:
parent_id: str, origin_id: str, proxy_address: str,
contract_description: str) -> None:
alert_data = ChainlinkContractAlertData()
alert_data.set_alert_data(proxy_address)
super().__init__(
ChainlinkContractAlertCode.PriceFeedObservedAgain,
"The Chainlink {} node is no longer missing observations for "
"price feed {}.".format(
origin_name, proxy_address),
"price feed {}.".format(origin_name, contract_description),
severity, timestamp, parent_id, origin_id,
MetricCode.PriceFeedNotObserved, alert_data)


class PriceFeedDeviationInreasedAboveThreshold(Alert):
class PriceFeedDeviationIncreasedAboveThreshold(Alert):
def __init__(self, origin_name: str, deviation: float, severity: str,
timestamp: float, threshold_severity: str,
parent_id: str, origin_id: str, proxy_address: str) -> None:
timestamp: float, threshold_severity: str, parent_id: str,
origin_id: str, proxy_address: str,
contract_description: str) -> None:
alert_data = ChainlinkContractAlertData()
alert_data.set_alert_data(proxy_address)
super().__init__(
ChainlinkContractAlertCode.PriceFeedDeviationInreasedAboveThreshold,
ChainlinkContractAlertCode
.PriceFeedDeviationIncreasedAboveThreshold,
"The Chainlink {} node's submission has increased above {} "
"threshold to {}% deviation for the price feed {}.".format(
origin_name, threshold_severity, deviation,
proxy_address),
origin_name, threshold_severity, deviation, contract_description),
severity, timestamp, parent_id, origin_id,
MetricCode.PriceFeedDeviation, alert_data)


class PriceFeedDeviationDecreasedBelowThreshold(Alert):
def __init__(self, origin_name: str, deviation: float, severity: str,
timestamp: float, threshold_severity: str, parent_id: str,
origin_id: str, proxy_address: str) -> None:
origin_id: str, proxy_address: str,
contract_description: str) -> None:
alert_data = ChainlinkContractAlertData()
alert_data.set_alert_data(proxy_address)
super().__init__(
ChainlinkContractAlertCode.PriceFeedDeviationDecreasedBelowThreshold,
ChainlinkContractAlertCode
.PriceFeedDeviationDecreasedBelowThreshold,
"The Chainlink {} node's submission has decreased below {} "
"threshold to {}% deviation for the price feed {}.".format(
origin_name, threshold_severity, deviation,
proxy_address),
contract_description),
severity, timestamp, parent_id, origin_id,
MetricCode.PriceFeedDeviation, alert_data)


class ConsensusFailure(Alert):
def __init__(self, origin_name: str, severity: str,
timestamp: float, parent_id: str, origin_id: str,
proxy_address: str) -> None:
def __init__(self, origin_name: str, severity: str, timestamp: float,
parent_id: str, origin_id: str, proxy_address: str,
contract_description: str) -> None:
alert_data = ChainlinkContractAlertData()
alert_data.set_alert_data(proxy_address)
super().__init__(
ChainlinkContractAlertCode.ConsensusNotReached,
"The Price Feed {} has a Consensus failure."
"The Chainlink Node observing the price feed is {}."
.format(proxy_address, origin_name),
"The Chainlink Node observing the price feed is {}.".format(
contract_description, origin_name),
severity, timestamp, parent_id, origin_id,
MetricCode.ConsensusFailure, alert_data)


class ErrorContractsNotRetrieved(Alert):
def __init__(self, origin_name: str, message: str, severity: str,
timestamp: float, parent_id: str, origin_id: str) -> None:
def __init__(self, _: str, message: str, severity: str, timestamp: float,
parent_id: str, origin_id: str) -> None:
super().__init__(
ChainlinkContractAlertCode.ErrorContractsNotRetrieved,
"{}: {}".format(parent_id, message), severity, timestamp,
parent_id, origin_id,
message, severity, timestamp, parent_id, origin_id,
MetricCode.ErrorContractsNotRetrieved)


class ContractsNowRetrieved(Alert):
def __init__(self, origin_name: str, message: str, severity: str,
timestamp: float, parent_id: str, origin_id: str) -> None:
def __init__(self, _: str, message: str, severity: str, timestamp: float,
parent_id: str, origin_id: str) -> None:
super().__init__(
ChainlinkContractAlertCode.ContractsNowRetrieved,
"{}: {}".format(parent_id, message), severity, timestamp,
parent_id, origin_id,
message, severity, timestamp, parent_id, origin_id,
MetricCode.ErrorContractsNotRetrieved)


class ErrorNoSyncedDataSources(Alert):
def __init__(self, origin_name: str, message: str, severity: str,
timestamp: float, parent_id: str, origin_id: str) -> None:
def __init__(self, _: str, message: str, severity: str, timestamp: float,
parent_id: str, origin_id: str) -> None:
super().__init__(
ChainlinkContractAlertCode.ErrorNoSyncedDataSources,
"{}: {}".format(parent_id, message), severity, timestamp,
parent_id, origin_id,
message, severity, timestamp, parent_id, origin_id,
MetricCode.ErrorNoSyncedDataSources)


class SyncedDataSourcesFound(Alert):
def __init__(self, origin_name: str, message: str, severity: str,
timestamp: float, parent_id: str, origin_id: str) -> None:
def __init__(self, _: str, message: str, severity: str, timestamp: float,
parent_id: str, origin_id: str) -> None:
super().__init__(
ChainlinkContractAlertCode.SyncedDataSourcesFound,
"{}: {}".format(parent_id, message), severity, timestamp,
parent_id, origin_id,
message, severity, timestamp, parent_id, origin_id,
MetricCode.ErrorNoSyncedDataSources)
12 changes: 6 additions & 6 deletions alerter/src/alerter/alerts/github_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def __init__(self, origin_name: str, release_name: str, tag_name: str,
super().__init__(
GithubAlertCode.NewGitHubReleaseAlert,
"Repo: {} has a new release {} tagged {}.".format(
origin_name, release_name, tag_name), severity,
timestamp, parent_id, origin_id,
origin_name, release_name, tag_name),
severity, timestamp, parent_id, origin_id,
GroupedGithubAlertsMetricCode.GithubRelease)


Expand All @@ -20,8 +20,8 @@ def __init__(self, origin_name: str, severity: str, timestamp: float,
parent_id: str, origin_id: str) -> None:
super().__init__(
GithubAlertCode.CannotAccessGitHubPageAlert,
"Github page inaccessible {}.".format(origin_name), severity,
timestamp, parent_id, origin_id,
"Github page inaccessible {}.".format(origin_name),
severity, timestamp, parent_id, origin_id,
GroupedGithubAlertsMetricCode.CannotAccessGithub)


Expand All @@ -30,6 +30,6 @@ def __init__(self, origin_name: str, severity: str, timestamp: float,
parent_id: str, origin_id: str) -> None:
super().__init__(
GithubAlertCode.GitHubPageNowAccessibleAlert,
"Github page accessible {}.".format(origin_name), severity,
timestamp, parent_id, origin_id,
"Github page accessible {}.".format(origin_name),
severity, timestamp, parent_id, origin_id,
GroupedGithubAlertsMetricCode.CannotAccessGithub)
24 changes: 12 additions & 12 deletions alerter/src/alerter/alerts/node/chainlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def __init__(self, origin_name: str, duration: float, severity: str,
"headers received in total.".format(
origin_name, strfdelta(timedelta(seconds=duration),
"{hours}h, {minutes}m, {seconds}s"),
current_headers_received), severity, timestamp, parent_id,
origin_id,
current_headers_received),
severity, timestamp, parent_id, origin_id,
GroupedChainlinkNodeAlertsMetricCode.NoChangeInTotalHeadersReceived)


Expand All @@ -56,8 +56,8 @@ def __init__(self, origin_name: str, severity: str, timestamp: float,
super().__init__(
ChainlinkNodeAlertCode.ReceivedANewHeaderAlert,
"{} received a new block header. {} headers received in "
"total.".format(origin_name, current_headers_received), severity,
timestamp, parent_id, origin_id,
"total.".format(origin_name, current_headers_received),
severity, timestamp, parent_id, origin_id,
GroupedChainlinkNodeAlertsMetricCode.NoChangeInTotalHeadersReceived)


Expand Down Expand Up @@ -138,8 +138,8 @@ def __init__(self, origin_name: str, current_value: int, severity: str,
.NoOfUnconfirmedTxsDecreasedBelowThresholdAlert,
"{} number of unconfirmed transactions have DECREASED below {} "
"threshold. Current value: {}.".format(
origin_name, threshold_severity, current_value), severity,
timestamp, parent_id, origin_id,
origin_name, threshold_severity, current_value),
severity, timestamp, parent_id, origin_id,
GroupedChainlinkNodeAlertsMetricCode.NoOfUnconfirmedTxsThreshold)


Expand Down Expand Up @@ -248,8 +248,8 @@ def __init__(self, origin_name: str, severity: str, timestamp: float,
ChainlinkNodeAlertCode.PrometheusSourceBackUpAgainAlert,
"The prometheus source of node {} is accessible again, last "
"successful monitor at: {}.".format(
origin_name, datetime.fromtimestamp(timestamp)), severity,
timestamp, parent_id, origin_id,
origin_name, datetime.fromtimestamp(timestamp)),
severity, timestamp, parent_id, origin_id,
GroupedChainlinkNodeAlertsMetricCode.PrometheusSourceIsDown)


Expand Down Expand Up @@ -292,8 +292,8 @@ def __init__(self, origin_name: str, message: str, severity: str,
timestamp: float, parent_id: str, origin_id: str) -> None:
super().__init__(
ChainlinkNodeAlertCode.MetricNotFoundErrorAlert,
"{}: {}".format(origin_name, message), severity, timestamp,
parent_id, origin_id,
"{}: {}".format(origin_name, message),
severity, timestamp, parent_id, origin_id,
GroupedChainlinkNodeAlertsMetricCode.MetricNotFound)


Expand All @@ -302,6 +302,6 @@ def __init__(self, origin_name: str, message: str, severity: str,
timestamp: float, parent_id: str, origin_id: str) -> None:
super().__init__(
ChainlinkNodeAlertCode.MetricFoundAlert,
"{}: {}".format(origin_name, message), severity, timestamp,
parent_id, origin_id,
"{}: {}".format(origin_name, message),
severity, timestamp, parent_id, origin_id,
GroupedChainlinkNodeAlertsMetricCode.MetricNotFound)
Loading

0 comments on commit 0df20db

Please sign in to comment.