# serve-prometheus (/docs/tx/serve-prometheus)

Advertises where this neuron's prometheus metrics can be scraped, separate
from the axon endpoint used for inter-neuron traffic. Signed by the hotkey,
which must be registered on the subnet, and subject to the same serving
rate limit as `serve_axon`. Like the axon calls, this only writes chain
data — running the metrics server is up to the caller.

| Signer   | Origin                                 | Pallet          | Wraps                                                                                            |
| -------- | -------------------------------------- | --------------- | ------------------------------------------------------------------------------------------------ |
| `hotkey` | signed account (pallet role may apply) | SubtensorModule | [`SubtensorModule.serve_prometheus`](/code/pallets/subtensor/src/macros/dispatches.rs#L748-L759) |

## Parameters [#parameters]

| Parameter | Type    | Required | Description                                                                        |
| --------- | ------- | -------- | ---------------------------------------------------------------------------------- |
| `netuid`  | integer | yes      | Subnet on which to publish the endpoint.                                           |
| `ip`      | string  | yes      | Public IPv4 or IPv6 address of the endpoint, in standard dotted or colon notation. |
| `port`    | integer | yes      | TCP port the endpoint listens on.                                                  |
| `version` | integer | no       | Version number of the serving neuron's software, stored with the endpoint.         |

Address parameters (`--hotkey`, `--coldkey`, `--dest`, ...) accept a raw ss58
address, an address-book or proxy-book name, or a local wallet/hotkey name.

## CLI [#cli]

Preview with `--dry-run` (shows fee, effects, and policy result without
submitting), then submit:

```bash
btcli tx serve-prometheus \
  --netuid <int> \
  --ip <value> \
  --port <int> --dry-run
btcli tx serve-prometheus \
  --netuid <int> \
  --ip <value> \
  --port <int> -w my_coldkey
```

## Python [#python]

```python
import bittensor as bt
from bittensor.wallet import Wallet

wallet = Wallet(name="my_coldkey", hotkey="my_hotkey")
intent = bt.ServePrometheus(netuid=1, ip="...", port=0)

sub = bt.Subtensor()
plan = sub.plan(intent, wallet)   # fee, effects, policy — no submission
result = sub.execute(intent, wallet)
if not result.success:
    print(result.error.code, result.error.remediation)
```

(`bt.Subtensor` is also the async client — `async with bt.Subtensor() as client:`
— see [The client](/docs/concepts/client).) Or build the intent by op name, as
an agent would:

```python
result = sub.execute_tool("serve_prometheus", {...}, wallet)
```

## On-chain implementation [#on-chain-implementation]

`SubtensorModule.serve_prometheus` — [`pallets/subtensor/src/macros/dispatches.rs#L750`](/code/pallets/subtensor/src/macros/dispatches.rs#L748-L759):

```rust
#[pallet::call_index(5)]
#[pallet::weight((<T as crate::pallet::Config>::WeightInfo::serve_prometheus(), DispatchClass::Normal, Pays::No))]
pub fn serve_prometheus(
    origin: OriginFor<T>,
    netuid: NetUid,
    version: u32,
    ip: u128,
    port: u16,
    ip_type: u8,
) -> DispatchResult {
    Self::do_serve_prometheus(origin, netuid, version, ip, port, ip_type)
}
```

Delegates to [`do_serve_prometheus`](/code/pallets/subtensor/src/subnets/serving.rs#L135).

Every file is browsable under [/code](/code) exactly as built into the runtime, or as plain text under `/code/raw/<path>` (index: [`/code/index.json`](/code/index.json)).
