Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion watchtower/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use {
struct Config {
address_labels: HashMap<String, String>,
ignore_http_bad_gateway: bool,
ignore_rpc_timeout: bool,
interval: Duration,
json_rpc_urls: Vec<String>,
rpc_timeout: Duration,
Expand Down Expand Up @@ -170,6 +171,12 @@ fn get_config() -> Config {
no alerting should a Bad Gateway error be a side effect of \
the real problem")
)
.arg(
Arg::with_name("ignore_rpc_timeout")
.long("ignore-rpc-timeout")
.takes_value(false)
.help("Ignore RPC timeout errors as some RPC endpoints often timeout and thus generate many false positives.")
)
.arg(
Arg::with_name("name_suffix")
.long("name-suffix")
Expand Down Expand Up @@ -216,6 +223,7 @@ fn get_config() -> Config {
let active_stake_alert_threshold =
value_t_or_exit!(matches, "active_stake_alert_threshold", u8);
let ignore_http_bad_gateway = matches.is_present("ignore_http_bad_gateway");
let ignore_rpc_timeout = matches.is_present("ignore_rpc_timeout");

let name_suffix = value_t_or_exit!(matches, "name_suffix", String);

Expand All @@ -224,6 +232,7 @@ fn get_config() -> Config {
let config = Config {
address_labels: config.address_labels,
ignore_http_bad_gateway,
ignore_rpc_timeout,
interval,
json_rpc_urls,
rpc_timeout,
Expand Down Expand Up @@ -383,7 +392,12 @@ fn query_endpoint(
}
Err(err) => {
if let client_error::ErrorKind::Reqwest(reqwest_err) = err.kind() {
if let Some(client_error::reqwest::StatusCode::BAD_GATEWAY) = reqwest_err.status() {
if reqwest_err.is_timeout() && config.ignore_rpc_timeout {
warn!("Error suppressed: {}", err);
return Ok(None);
} else if let Some(client_error::reqwest::StatusCode::BAD_GATEWAY) =
reqwest_err.status()
{
if config.ignore_http_bad_gateway {
warn!("Error suppressed: {}", err);
return Ok(None);
Expand Down