From 07550bcf99a4e9438b153dde1fef2400cd1170b4 Mon Sep 17 00:00:00 2001 From: akhercha Date: Thu, 25 Jul 2024 09:45:36 +0200 Subject: [PATCH] fix(long_tail_assets): Readable config --- .github/workflows/docker-build.yml | 2 +- prometheus/alerts.rules.yml | 21 +++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index db6618d..5423278 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -60,7 +60,7 @@ jobs: with: context: . file: Dockerfile - platforms: ${{ format('linux/{0}', matrix.platform) }} + platforms: ${{ format('linux/{0}', matrix.platform) }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:cache-${{ matrix.platform }},mode=max cache-to: type=registry,ref=${{ env.REGISTRY_IMAGE }}:cache-${{ matrix.platform }},mode=max diff --git a/prometheus/alerts.rules.yml b/prometheus/alerts.rules.yml index 913f13c..a94d023 100644 --- a/prometheus/alerts.rules.yml +++ b/prometheus/alerts.rules.yml @@ -64,7 +64,7 @@ groups: summary: "Price deviation is too high" description: "The median on-chain price of {{ $labels.pair }} has deviated for more than 2.5% with the reference price from DefiLlama." - - alert: LongTailAssetCriticalDeviation + - alert: LongTailAssetSourcesDeviation expr: | ( long_tail_asset_deviating_sources >= 2 @@ -81,18 +81,15 @@ groups: labels: severity: critical annotations: - summary: "Long tail asset critical deviation detected" + summary: "Long tail asset sources deviation is too high" description: | - {{ $deviating := printf "%.0f" $value }} - {{ $total := printf "%.0f" (long_tail_asset_total_sources) }} - {{ $threshold := printf "%.2f" ( - (long_tail_asset_total_sources <= 6) - * 100 * last_over_time(long_tail_asset_threshold{type="low"}[1h]) - or - (long_tail_asset_total_sources > 6) - * 100 * last_over_time(long_tail_asset_threshold{type="high"}[1h]) - ) }} - {{ $deviating }} out of {{ $total }} sources for {{ $labels.pair }} have deviated from the onchain price beyond {{ $threshold }}%. + {{ $deviating := long_tail_asset_deviating_sources }} + {{ $total := long_tail_asset_total_sources }} + {{ $threshold := long_tail_asset_threshold{type="low"} }} + {{ if gt $total 6.0 }} + {{ $threshold = long_tail_asset_threshold{type="high"} }} + {{ end }} + {{ printf "%.0f" $deviating }} out of {{ printf "%.0f" $total }} sources for {{ $labels.pair }} have deviated from the onchain price beyond {{ printf "%.2f" (100 * $threshold) }}%. - name: API rules: