Skip to content

Commit

Permalink
🐛 fix error message & scrape interval
Browse files Browse the repository at this point in the history
- better error message
- scrape interval = 30s
  • Loading branch information
EvolveArt committed Jan 8, 2024
1 parent 1c5e5b7 commit f55afbf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions prometheus/alerts.rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ groups:
- name: Oracle
rules:
- alert: TimeSinceLastUpdateTooHigh
expr: time_since_last_update_seconds > 1200
expr: time_since_last_update_seconds > 1800
for: 5m
labels:
severity: critical
annotations:
summary: "Time since the last update is too high"
description: "The time since the last update from {{ $labels.publisher }} has exceeded 1200 seconds."
description: "The time since the last update from {{ $labels.publisher }} has exceeded 1800 seconds."
- alert: WrongPrice
expr: price_deviation > 0.02
for: 5m
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub(crate) async fn monitor(
) {
let monitoring_config = get_config(None).await;

let mut interval = interval(Duration::from_secs(5));
let mut interval = interval(Duration::from_secs(30));

loop {
interval.tick().await; // Wait for the next tick
Expand Down Expand Up @@ -148,7 +148,7 @@ pub(crate) async fn monitor(
match result {
Ok(data) => match data {
Ok(_) => log::info!("[{data_type}] Task finished successfully",),
Err(e) => log::error!("[{data_type}] Task failed with error: {:?}", e),
Err(e) => log::error!("[{data_type}] Task failed with error: {e}"),
},
Err(e) => log::error!("[{data_type}] Task failed with error: {:?}", e),
}
Expand Down
10 changes: 6 additions & 4 deletions src/monitoring/price_deviation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ pub async fn price_deviation<T: Entry>(
.await
.map_err(|e| MonitoringError::Api(e.to_string()))?;

let coins_prices: CoinPricesDTO = response
.json()
.await
.map_err(|e| MonitoringError::Api(e.to_string()))?;
let coins_prices: CoinPricesDTO = response.json().await.map_err(|e| {
MonitoringError::Api(format!(
"Failed to convert to DTO object, got error {:?}",
e.to_string()
))
})?;

let api_id = format!("coingecko:{}", coingecko_id);

Expand Down

0 comments on commit f55afbf

Please sign in to comment.