Skip to content

Commit

Permalink
subscan format
Browse files Browse the repository at this point in the history
  • Loading branch information
ironoa committed Dec 17, 2024
1 parent 7152dae commit 47db3d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
rules:
- alert: AccountTokenBalanceBelowDesired
annotations:
message: 'Target <a href="https://assethub-{{`{{ $labels.network }}`}}.subscan.io/account/{{`{{ $labels.address }}`}}">{{`{{ $labels.name }}`}}</a> has less tokens than expected...'
message: 'Target <a href="https://{{`{{ $labels.network }}`}}.subscan.io/account/{{`{{ $labels.address }}`}}">{{`{{ $labels.name }}`}}</a> has less tokens than expected...'
expr: max without(instance,pod) (last_over_time(polkadot_account_token_balance_desired[10m]) - last_over_time(polkadot_account_token_balance_current[10m])) > 0
for: 2m
labels:
Expand Down
12 changes: 10 additions & 2 deletions src/prometheus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,19 @@ export class Prometheus implements PromClient {
}

updateCurrentTokenBalance(network: string, name: string, address: string, token: string, balance: number): void {
this.tokenBalanceCurrent.set({network:network, name, address, token, environment: this.environment }, balance);
this.tokenBalanceCurrent.set({network:this._toSubscanAssethubFormat(network), name, address, token, environment: this.environment }, balance);
}

updateDesiredTokenBalance(network: string, name: string, address: string, token: string, balance: number): void {
this.tokenBalanceDesired.set({network:network, name, address, token, environment: this.environment }, balance);
this.tokenBalanceDesired.set({network:this._toSubscanAssethubFormat(network), name, address, token, environment: this.environment }, balance);
}

_toSubscanAssethubFormat(network: string): string{
if(network.includes("kusama"))
return "assethub-kusama"
if(network.includes("polkadot"))
return "assethub-polkadot"
return "unknown"
}

_initMetrics(): void {
Expand Down

0 comments on commit 47db3d0

Please sign in to comment.