Skip to content

Commit

Permalink
Merge pull request #272 from porters-xyz/prom-query-fix
Browse files Browse the repository at this point in the history
updated query!
  • Loading branch information
wtfsayo authored May 21, 2024
2 parents c0cbbbe + 2d06a17 commit 854be50
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions web-portal/backend/fly.prod.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ primary_region = 'sea'
# ONEINCH_API_KEY = ...
# OX_API_KEY = ...
# RPC_KEY = ...
PROM_URL = 'https://api.fly.io/prometheus/porters/api/v1/'

[[services]]
internal_port = 4000
Expand Down
1 change: 1 addition & 0 deletions web-portal/backend/fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ primary_region = 'sea'
# ONEINCH_API_KEY = ...
# OX_API_KEY = ...
# RPC_KEY = ...
PROM_URL = 'https://api.fly.io/prometheus/porters-staging/api/v1/'

[http_service]
internal_port = 4000
Expand Down
6 changes: 3 additions & 3 deletions web-portal/backend/src/usage/usage.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export class UsageService {
step: number | string,
): Promise<Response> {

const url = `https://api.fly.io/prometheus/porters-staging/api/v1/query_range?query=sum(${query})&start=${start}&end=now&step=${step}`;

const url = process.env.PROM_URL +`query_range?query=sum(increase(${query}))&start=${start}&end=now&step=${step}`;
// do include `/` into url
const result = await fetch(url, {
headers: {
Authorization: String(process.env.PROM_TOKEN),
Expand All @@ -59,7 +59,7 @@ export class UsageService {
case '24h':
return '1h';
case '1h':
return '1m';
return '5m';
case '7d':
return '1d';
case '30d':
Expand Down
5 changes: 1 addition & 4 deletions web-portal/frontend/components/dashboard/insights.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,7 @@ const Insights: React.FC = () => {


const totalRequests =
Math.abs(
_.get(_.first(formattedData), 'requests', 0) -
_.get(_.last(formattedData), 'requests', 0),
)
_.sumBy(formattedData, 'requests')


const successData = totalRequests;
Expand Down

0 comments on commit 854be50

Please sign in to comment.