Skip to content

Commit

Permalink
remove api key from metric (#1431)
Browse files Browse the repository at this point in the history
  • Loading branch information
franzns authored Jan 8, 2025
1 parent e73df95 commit 8be56ff
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
11 changes: 9 additions & 2 deletions apps/scheduler/create-alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ export async function createAlerts(chainId: string): Promise<void> {
const subgraphsToAlert: { subgraphName: string; subgraphUrl: string }[] = [];

for (const [subgraphName, subgraphUrl] of subgraphs) {
subgraphsToAlert.push({ subgraphName, subgraphUrl });
let subgraphUrlClean = subgraphUrl;
if (subgraphUrl.includes('gateway')) {
const parts = subgraphUrl.split('/');
parts.splice(4, 1);
subgraphUrlClean = parts.join('/');
}

subgraphsToAlert.push({ subgraphName, subgraphUrl: subgraphUrlClean });
}

await createSubgraphLagAlertsIfNotExist(chainId, config.data.chain.slug, subgraphsToAlert);
Expand Down Expand Up @@ -159,7 +166,7 @@ async function createSubgraphLagAlertsIfNotExist(
// upsert all other alarms
for (const subgraph of subgraphs) {
const alarmName = `${ALARM_PREFIX}:${subgraph.subgraphName}`;
const metricName = `${chainSlug}-${subgraph.subgraphName}-${subgraph.subgraphUrl}-lag`;
const metricName = `${chainSlug}-${subgraph.subgraphName}-lag-${subgraph.subgraphUrl}`;

//make sure metric is available for alarm
await subgraphMetricPublisher.publish(metricName, 0);
Expand Down
13 changes: 8 additions & 5 deletions modules/controllers/subgraph-monitor-controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import { Chain } from '@prisma/client';
import { syncMerklRewards } from '../actions/aprs/merkl';
import { SwapFeeFromSnapshotsAprService } from '../pool/lib/apr-data-sources/swap-fee-apr-from-snapshots.service';
import { prisma } from '../../prisma/prisma-client';
import { subgraphMetricPublisher } from '../metrics/metrics.client';
import { AllNetworkConfigs } from '../network/network-config';
import { GaugeSubgraphService } from '../subgraphs/gauge-subgraph/gauge-subgraph.service';
Expand All @@ -28,8 +24,15 @@ export function SubgraphMonitorController(tracer?: any) {
const meta = await subgraph.getMetadata();
lag = Math.max(Number(latestBlock) - meta.block.number, 0);

let subgraphUrlClean = subgraphUrl;
if (subgraphUrl.includes('gateway')) {
const parts = subgraphUrl.split('/');
parts.splice(4, 1);
subgraphUrlClean = parts.join('/');
}

subgraphMetricPublisher.publish(
`${config.data.chain.slug}-${subgraphName}-${subgraphUrl}-lag`,
`${config.data.chain.slug}-${subgraphName}-lag-${subgraphUrl}`,
lag,
);
}
Expand Down

0 comments on commit 8be56ff

Please sign in to comment.