feat(price-pusher): emit namespace label on all Prometheus metrics#3720
feat(price-pusher): emit namespace label on all Prometheus metrics#37200xghost42 wants to merge 1 commit into
namespace label on all Prometheus metrics#3720Conversation
The sample Grafana dashboard (`grafana-dashboard.sample.json`) filters
every Prometheus query by `namespace=$chain`:
pyth_price_feeds_total{namespace="$chain"}
pyth_price_last_published_time{namespace="$chain"}
pyth_price_update_attempts_total{namespace="$chain", ...}
...
But `src/metrics.ts` only set `app="price_pusher"` as the default label
and never emitted a `namespace` label on any counter/gauge, and
`prometheus.sample.yml` did not add one via relabeling. With the
dashboard out of the box that filter matched zero series, so every
panel for a fresh deployment came up empty — flagged by Devin during
review of pyth-network#3692 and acknowledged there as pre-existing dashboard
behavior worth fixing in a separate PR. This is that PR.
Wiring:
- new CLI option `--metrics-namespace <name>` in `src/options.ts`,
defaulted per chain command (`evm`, `sui`, `aptos`, `solana`) so
that single-chain deployments work without configuration
- `PricePusherMetrics` constructor now takes a `namespace: string`
parameter and sets it via `registry.setDefaultLabels`, so every
existing metric series gains a `namespace` label without per-metric
`labelNames` plumbing
- each chain command (`evm/sui/aptos/solana/command.ts`) reads the
new arg and passes through to the constructor
Operators running multiple deployments of the same chain (e.g. several
EVM networks against one Grafana instance) can now set
`--metrics-namespace bsc-mainnet` / `--metrics-namespace polygon-mainnet`
to disambiguate. Single-deployment setups keep working unchanged.
Bumps `@pythnetwork/price-pusher` to `10.5.0` (additive, no breaking
changes — old CLIs still work). Note: pyth-network#3689 and pyth-network#3703 also bump to
`10.5.0`, so whichever of the three lands second/third will need a
trivial rebase to `10.6.0` / `10.7.0`.
Refs pyth-network#3692.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 7 Skipped Deployments
|
| // Register the default metrics (memory, CPU, etc.). `namespace` is set as | ||
| // a default label so the sample Grafana dashboard's `namespace=$chain` | ||
| // filter actually matches emitted series. | ||
| this.registry.setDefaultLabels({ app: "price_pusher", namespace }); |
There was a problem hiding this comment.
🚩 Prometheus namespace label may collide with Kubernetes service-discovery labels
The new default label namespace set at apps/price_pusher/src/metrics.ts:34 is a very common label auto-applied by Kubernetes Prometheus service discovery (typically representing the k8s namespace of the pod). If the price pusher runs inside Kubernetes and Prometheus is configured with honor_labels: false (the default), the infrastructure's namespace label will be renamed to exported_namespace, which would break the Grafana dashboard filter namespace=$chain. Conversely, with honor_labels: true, the app's label would win but the k8s namespace context would be lost. Consider using a more specific label name (e.g., chain or deployment_chain) to avoid ambiguity.
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
Make the sample Grafana dashboard's
namespace=\$chainfilters actually match emitted series, which they don't today.Background
apps/price_pusher/grafana-dashboard.sample.jsonqueries every panel withnamespace="\$chain", e.g.But
apps/price_pusher/src/metrics.tsonly setapp="price_pusher"as the default registry label, andprometheus.sample.ymldoesn't addnamespacevia relabeling either. The result: every panel in the sample dashboard came up empty on a fresh deployment.Devin flagged this during the #3692 review and I acknowledged it there as pre-existing dashboard behavior worth fixing in a separate PR. This is that PR.
Wiring
--metrics-namespace <name>insrc/options.ts, defaulted per chain command (evm,sui,aptos,solana) so single-chain deployments work without any configurationPricePusherMetricsconstructor now takes anamespace: stringparameter and sets it viaregistry.setDefaultLabels, so every existing metric series gains anamespacelabel without per-metriclabelNamesplumbingevm/sui/aptos/solana/command.ts) reads the new arg and passes through to the constructorOperators running multiple deployments of the same chain (e.g. several EVM networks against one Grafana instance) can now set
--metrics-namespace bsc-mainnet/--metrics-namespace polygon-mainnetto disambiguate. Single-deployment setups keep working unchanged — the dashboard's\$chaintemplate var will just match the chain command name out of the box.Bumps
@pythnetwork/price-pusherto10.5.0.Coordination heads-up
#3689 and #3703 (both open) also bump to
10.5.0. Whichever of the three lands second/third will need a trivial rebase to10.6.0/10.7.0.Test plan
--helpexposes new--metrics-namespaceoption on each chain--metrics-namespace):curl :9090/metricsshowspyth_*{...namespace="evm",...}(orsui/aptos/solana)--metrics-namespace bsc-mainnetyieldsnamespace="bsc-mainnet"on every emitted series\$chain=\$namespacepanels populate end-to-end against a real pusherevm/sui/aptos/solana)Refs #3692.