Skip to main content
Version: v4

Legacy Prometheus endpoint

Before v4, SuiviBourse stored its data in Prometheus. To keep pre-v4 deployments working, the app still exposes a Prometheus /metrics endpoint in parallel with the InfluxDB writer.

It is enabled by default and reflects only the current snapshot of each share — there is no historical data or backfill on this endpoint (that lives in InfluxDB).

Configuration

VariableDefaultDescription
SB_PROMETHEUS_ENABLEDtrueExpose the /metrics endpoint
SB_METRICS_PORT8081TCP port for the endpoint

To disable it entirely:

SB_PROMETHEUS_ENABLED=false

Exposed gauges

All share gauges are prefixed with sb_ and carry the labels share_name, share_symbol and account.

MetricDescription
sb_share_priceCurrent market price
sb_purchased_quantityQuantity purchased
sb_purchased_priceWeighted average cost price
sb_purchased_feeTotal fees
sb_owned_quantityCurrently owned quantity
sb_received_dividendTotal dividends received
sb_dividend_yieldDividend yield (percentage)
sb_pe_ratioPrice-to-Earnings ratio
sb_market_capMarket capitalization
sb_volumeTrading volume
sb_share_infoAlways 1; carries extra labels share_currency, share_exchange, quote_type
sb_price_staleness1 when the stored price is silently stale — frozen across consecutive open-market cycles while the live quote moves — 0 otherwise. See the price-freshness sonde.
New account label (v4.1) — re-glue existing queries

Since v4.1 the sb_* gauges carry an account label. A query that used to aggregate without it now splits by account; aggregate the label away to restore the old behaviour:

sum without(account) (sb_owned_quantity)

See Upgrading to accounts.

For opt-in accounts, extra per-account and global gauges are exposed:

MetricLabelsDescription
sb_account_cash_balance / sb_account_holdings_value / sb_account_total_value / sb_account_net_contributedaccountPer-account cash & value
sb_account_xirr / sb_account_gain_absolu / sb_account_twr_indexaccountPer-account money-weighted performance
sb_account_infoaccount, account_type, account_currencyAlways 1
sb_portfolio_*(none)The same fields at the global level, without an account label

Scraping with Prometheus

Add a static scrape config pointing at the app:

/etc/prometheus/prometheus.yaml
scrape_configs:
- job_name: 'suivi-bourse'
scrape_interval: '120s'
static_configs:
- targets: ['localhost:8081']

Exporting to other databases

Because the endpoint speaks the Prometheus/OpenMetrics format, you can use Telegraf to forward it to other systems (ElasticSearch, InfluxDB v1/v2, MongoDB, …):

# Read metrics from the SuiviBourse app
[[inputs.prometheus]]
## URLs to scrape metrics from
urls = ["http://localhost:8081/metrics"]

## Metric version 1 or 2
metric_version = 1

## Optional tag added to every scraped metric
url_tag = "suivi-bourse"
tip

For historical data and long-term storage, prefer the native InfluxDB 3 integration — the Prometheus endpoint only carries the latest snapshot.