Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions apps/price_pusher/grafana-dashboard.sample.json
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Grafana table panel missing excludeByName entries for new chain default label columns

Adding chain as a default Prometheus label in apps/price_pusher/src/metrics.ts:38 means that table-format queries in the "Price Feeds List" panel will now produce chain, chain#B, and chain#C columns (one per query ref). The excludeByName block already excludes the analogous app/app#B/app#C columns from the pre-existing app default label, but does not exclude the new chain columns. As a result, the table will display extra unwanted columns showing the chain value in every row.

(Refers to lines 432-455)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@
"uid": "edryyydtht14wa"
},
"editorMode": "code",
"expr": "pyth_price_feeds_total{namespace=\"$chain\"}",
"expr": "pyth_price_feeds_total{chain=\"$chain\"}",
"instant": true,
"legendFormat": "{{namespace}}",
"legendFormat": "{{chain}}",
"range": false,
"refId": "A"
}
Expand Down Expand Up @@ -169,9 +169,9 @@
"uid": "edryyydtht14wa"
},
"editorMode": "code",
"expr": "count(pyth_price_last_published_time{namespace=\"$chain\"})",
"expr": "count(pyth_price_last_published_time{chain=\"$chain\"})",
"instant": true,
"legendFormat": "{{namespace}}",
"legendFormat": "{{chain}}",
"range": false,
"refId": "A"
}
Expand Down Expand Up @@ -252,7 +252,7 @@
"uid": "edryyydtht14wa"
},
"editorMode": "code",
"expr": "time() - pyth_price_last_published_time{namespace=\"$chain\"}",
"expr": "time() - pyth_price_last_published_time{chain=\"$chain\"}",
"instant": true,
"legendFormat": "{{alias}}",
"range": false,
Expand Down Expand Up @@ -383,7 +383,7 @@
"uid": "edryyydtht14wa"
},
"editorMode": "code",
"expr": "pyth_price_last_published_time{namespace=\"$chain\"}",
"expr": "pyth_price_last_published_time{chain=\"$chain\"}",
"format": "table",
"instant": true,
"legendFormat": "__auto",
Expand All @@ -396,7 +396,7 @@
"uid": "edryyydtht14wa"
},
"editorMode": "code",
"expr": "time() - pyth_price_last_published_time{namespace=\"$chain\"}",
"expr": "time() - pyth_price_last_published_time{chain=\"$chain\"}",
"format": "table",
"instant": true,
"legendFormat": "__auto",
Expand All @@ -409,7 +409,7 @@
"uid": "edryyydtht14wa"
},
"editorMode": "code",
"expr": "pyth_price_update_attempts_total{status=\"success\", namespace=\"$chain\"}",
"expr": "pyth_price_update_attempts_total{status=\"success\", chain=\"$chain\"}",
"format": "table",
"instant": true,
"legendFormat": "__auto",
Expand Down Expand Up @@ -606,7 +606,7 @@
"uid": "edryyydtht14wa"
},
"editorMode": "code",
"expr": "increase(pyth_price_update_attempts_total{status=\"success\", namespace=\"$chain\"}[$__range])",
"expr": "increase(pyth_price_update_attempts_total{status=\"success\", chain=\"$chain\"}[$__range])",
"legendFormat": "{{alias}} - Updates",
"range": true,
"refId": "A"
Expand Down Expand Up @@ -732,7 +732,7 @@
"uid": "edryyydtht14wa"
},
"editorMode": "code",
"expr": "sum by (trigger) (increase(pyth_price_update_attempts_total{namespace=\"$chain\"}[$__range]))",
"expr": "sum by (trigger) (increase(pyth_price_update_attempts_total{chain=\"$chain\"}[$__range]))",
"instant": false,
"legendFormat": "{{trigger}}",
"range": true,
Expand Down Expand Up @@ -819,7 +819,7 @@
"uid": "edryyydtht14wa"
},
"editorMode": "code",
"expr": "pyth_wallet_balance{namespace=\"$chain\"}",
"expr": "pyth_wallet_balance{chain=\"$chain\"}",
"instant": true,
"legendFormat": "{{wallet_address}}",
"range": false,
Expand Down Expand Up @@ -915,7 +915,7 @@
"uid": "edryyydtht14wa"
},
"editorMode": "code",
"expr": "pyth_wallet_balance{namespace=\"$chain\"}",
"expr": "pyth_wallet_balance{chain=\"$chain\"}",
"legendFormat": "{{wallet_address}} ({{network}})",
"range": true,
"refId": "A"
Expand Down Expand Up @@ -1024,7 +1024,7 @@
"uid": "edryyydtht14wa"
},
"editorMode": "code",
"expr": "increase(pyth_price_update_attempts_total{status=\"error\", namespace=\"$chain\"}[$__range])",
"expr": "increase(pyth_price_update_attempts_total{status=\"error\", chain=\"$chain\"}[$__range])",
"legendFormat": "{{alias}} - Errors",
"range": true,
"refId": "A"
Expand Down Expand Up @@ -1077,7 +1077,7 @@
"uid": "ads9ouz3jh4hsa"
},
"editorMode": "code",
"expr": "{namespace=~\"$chain\"} | logfmt | json | msg =~ `.*(Price update successful|Transaction confirmed|Successfully updated price).*` | line_format `Tx Hash: {{.hash}}`",
"expr": "{chain=~\"$chain\"} | logfmt | json | msg =~ `.*(Price update successful|Transaction confirmed|Successfully updated price).*` | line_format `Tx Hash: {{.hash}}`",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 Loki stream selector assumes chain label exists on log streams

The Grafana dashboard Loki queries (e.g., {chain=~"$chain"} at lines 1080, 1130, 1167) and the template variable definition at line 1205 now query for a chain label on Loki log streams. This label is not set by the application code itself — it depends on how logs are shipped to Loki (e.g., via Promtail/Grafana Agent label configuration in Kubernetes). Previously the dashboard used namespace which is automatically applied by Kubernetes service discovery. The new chain label will need to be explicitly configured in the log pipeline (e.g., as a Promtail relabeling rule or a pod label). This is a deployment concern rather than a code bug, but operators upgrading should be aware they need to update their log shipping configuration to add a chain label.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

"queryType": "range",
"refId": "A"
}
Expand Down Expand Up @@ -1127,7 +1127,7 @@
"uid": "ads9ouz3jh4hsa"
},
"editorMode": "code",
"expr": "{namespace=~\"$chain\"} | logfmt",
"expr": "{chain=~\"$chain\"} | logfmt",
"queryType": "range",
"refId": "A"
}
Expand Down Expand Up @@ -1164,7 +1164,7 @@
"uid": "ads9ouz3jh4hsa"
},
"editorMode": "builder",
"expr": "{namespace=~\"$chain\"} | logfmt | detected_level = `error`",
"expr": "{chain=~\"$chain\"} | logfmt | detected_level = `error`",
"queryType": "range",
"refId": "A"
}
Expand Down Expand Up @@ -1202,7 +1202,7 @@
"name": "chain",
"options": [],
"query": {
"label": "namespace",
"label": "chain",
"refId": "LokiVariableQueryEditor-VariableQuery",
"stream": "",
"type": 1
Expand Down
2 changes: 1 addition & 1 deletion apps/price_pusher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,5 @@
},
"type": "module",
"types": "./dist/index.d.ts",
"version": "10.4.0"
"version": "10.5.0"
}
7 changes: 6 additions & 1 deletion apps/price_pusher/src/aptos/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default {
...options.controllerLogLevel,
...options.enableMetrics,
...options.metricsPort,
...options.metricsChain,
},
command: "aptos",
describe: "run price pusher for aptos",
Expand All @@ -70,6 +71,7 @@ export default {
controllerLogLevel,
enableMetrics,
metricsPort,
metricsChain,
} = argv;

const logger = pino({ level: logLevel });
Expand All @@ -82,7 +84,10 @@ export default {
// Initialize metrics if enabled
let metrics: PricePusherMetrics | undefined;
if (enableMetrics) {
metrics = new PricePusherMetrics(logger.child({ module: "Metrics" }));
metrics = new PricePusherMetrics(
logger.child({ module: "Metrics" }),
metricsChain ?? "aptos",
);
metrics.start(metricsPort);
logger.info(`Metrics server started on port ${metricsPort}`);
}
Expand Down
7 changes: 6 additions & 1 deletion apps/price_pusher/src/evm/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export default {
...options.controllerLogLevel,
...options.enableMetrics,
...options.metricsPort,
...options.metricsChain,
},
command: "evm",
describe: "run price pusher for evm",
Expand All @@ -118,6 +119,7 @@ export default {
controllerLogLevel,
enableMetrics,
metricsPort,
metricsChain,
} = argv;

const logger = pino({
Expand Down Expand Up @@ -150,7 +152,10 @@ export default {
// Initialize metrics if enabled
let metrics: PricePusherMetrics | undefined;
if (enableMetrics) {
metrics = new PricePusherMetrics(logger.child({ module: "Metrics" }));
metrics = new PricePusherMetrics(
logger.child({ module: "Metrics" }),
metricsChain ?? "evm",
);
metrics.start(metricsPort);
logger.info(`Metrics server started on port ${metricsPort}`);
}
Expand Down
12 changes: 9 additions & 3 deletions apps/price_pusher/src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,19 @@ export class PricePusherMetrics {
// Wallet metrics
public walletBalance: Gauge;

constructor(logger: Logger) {
constructor(logger: Logger, chain: string) {
this.logger = logger;
this.registry = new Registry();
this.server = express();

// Register the default metrics (memory, CPU, etc.)
this.registry.setDefaultLabels({ app: "price_pusher" });
// Register the default metrics (memory, CPU, etc.). `chain` is set as a
// default label so the sample Grafana dashboard's `chain=$chain` filter
// actually matches emitted series. Deliberately not named `namespace` —
// Kubernetes Prometheus service discovery auto-applies a `namespace`
// label representing the pod's k8s namespace, and with the default
// `honor_labels: false` our label would be renamed to
// `exported_namespace` and the dashboard filter would silently break.
this.registry.setDefaultLabels({ app: "price_pusher", chain });

// Create metrics
this.lastPublishedTime = new Gauge({
Expand Down
14 changes: 14 additions & 0 deletions apps/price_pusher/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,17 @@ export const metricsPort = {
type: "number",
} as Options,
};

export const metricsChain = {
"metrics-chain": {
description:
"Value emitted as the `chain` label on every Prometheus metric. " +
"The sample Grafana dashboard filters by `chain=$chain`, so set this " +
"to your deployment's chain/network name (e.g. `bsc-mainnet`, `sui-testnet`). " +
"Defaults to the chain command name (e.g. `evm`, `sui`, `aptos`, `solana`). " +
"Named `chain` rather than `namespace` to avoid colliding with the " +
"Kubernetes Prometheus service-discovery `namespace` label.",
type: "string",
required: false,
} as Options,
};
7 changes: 6 additions & 1 deletion apps/price_pusher/src/solana/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export default {
...options.controllerLogLevel,
...options.enableMetrics,
...options.metricsPort,
...options.metricsChain,
},
command: "solana",
describe: "run price pusher for solana",
Expand Down Expand Up @@ -153,6 +154,7 @@ export default {
metricsPort,
pythReceiverProgramId,
wormholeProgramId,
metricsChain,
} = argv;

const logger = pino({ level: logLevel });
Expand All @@ -166,7 +168,10 @@ export default {
// Initialize metrics if enabled
let metrics: PricePusherMetrics | undefined;
if (enableMetrics) {
metrics = new PricePusherMetrics(logger.child({ module: "Metrics" }));
metrics = new PricePusherMetrics(
logger.child({ module: "Metrics" }),
metricsChain ?? "solana",
);
metrics.start(metricsPort);
logger.info(`Metrics server started on port ${metricsPort}`);
}
Expand Down
7 changes: 6 additions & 1 deletion apps/price_pusher/src/sui/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export default {
...options.controllerLogLevel,
...options.enableMetrics,
...options.metricsPort,
...options.metricsChain,
},
command: "sui",
describe:
Expand All @@ -105,6 +106,7 @@ export default {
controllerLogLevel,
enableMetrics,
metricsPort,
metricsChain,
} = argv;

const logger = pino({ level: logLevel });
Expand Down Expand Up @@ -141,7 +143,10 @@ export default {
// Initialize metrics if enabled
let metrics: PricePusherMetrics | undefined;
if (enableMetrics) {
metrics = new PricePusherMetrics(logger.child({ module: "Metrics" }));
metrics = new PricePusherMetrics(
logger.child({ module: "Metrics" }),
metricsChain ?? "sui",
);
metrics.start(metricsPort);
logger.info(`Metrics server started on port ${metricsPort}`);
}
Expand Down