[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/prismarine](https://jsprismarine.dev/api/@jsprismarine/prismarine/index.md) / stats/serverMetrics

# stats/serverMetrics

## Interfaces

### ServerMetricSources

Defined in: [packages/prismarine/src/stats/serverMetrics.ts:74](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/stats/serverMetrics.ts#L74)

What the server metrics read: the settings, the started transports, the sessions and the
values the build stamped in.

#### Properties

##### build?

> `readonly` `optional` **build?**: () => [`BuildDefines`](https://jsprismarine.dev/api/@jsprismarine/prismarine/version/index.md#builddefines)

Defined in: [packages/prismarine/src/stats/serverMetrics.ts:79](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/stats/serverMetrics.ts#L79)

The values the build stamped in, read on each reading. This build's by default.

###### Returns

[`BuildDefines`](https://jsprismarine.dev/api/@jsprismarine/prismarine/version/index.md#builddefines)

##### config

> `readonly` **config**: `Pick`\<[`Config`](https://jsprismarine.dev/api/@jsprismarine/prismarine/config/Config/classes/Config.md), `"getOnlineMode"`\>

Defined in: [packages/prismarine/src/stats/serverMetrics.ts:75](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/stats/serverMetrics.ts#L75)

##### networking

> `readonly` **networking**: `Pick`\<[`ServerNetworking`](https://jsprismarine.dev/api/@jsprismarine/prismarine/modules/network/classes/ServerNetworking.md), `"getStartedTransports"`\>

Defined in: [packages/prismarine/src/stats/serverMetrics.ts:76](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/stats/serverMetrics.ts#L76)

##### sessions

> `readonly` **sessions**: `Pick`\<[`SessionManager`](https://jsprismarine.dev/api/@jsprismarine/prismarine/SessionManager/classes/SessionManager.md), `"getSessions"`\>

Defined in: [packages/prismarine/src/stats/serverMetrics.ts:77](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/stats/serverMetrics.ts#L77)

## Type Aliases

### ServerMetricName

> **ServerMetricName** = *typeof* [`ServerMetric`](#servermetric)\[keyof *typeof* [`ServerMetric`](#servermetric)\]

Defined in: [packages/prismarine/src/stats/serverMetrics.ts:34](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/stats/serverMetrics.ts#L34)

One of the server's metric names, such as `jsprismarine:players`.

## Variables

### DEVICE\_OS\_NAMES

> `const` **DEVICE\_OS\_NAMES**: `object`

Defined in: [packages/prismarine/src/stats/serverMetrics.ts:40](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/stats/serverMetrics.ts#L40)

The name each device OS a client reports goes by, for every `BuildPlatform` member. `DEDICATED`
is Bedrock Dedicated Server's own value, which no player client sends.

#### Type Declaration

##### -1

> `readonly` **-1**: `"Unknown"` = `'Unknown'`

##### 1

> `readonly` **1**: `"Android"` = `'Android'`

##### 11

> `readonly` **11**: `"PlayStation"` = `'PlayStation'`

##### 12

> `readonly` **12**: `"Nintendo Switch"` = `'Nintendo Switch'`

##### 13

> `readonly` **13**: `"Xbox"` = `'Xbox'`

##### 15

> `readonly` **15**: `"Linux"` = `'Linux'`

##### 2

> `readonly` **2**: `"iOS"` = `'iOS'`

##### 3

> `readonly` **3**: `"macOS"` = `'macOS'`

##### 4

> `readonly` **4**: `"Fire OS"` = `'Fire OS'`

##### 8

> `readonly` **8**: `"Windows"` = `'Windows'`

##### 9

> `readonly` **9**: `"Dedicated Server"` = `'Dedicated Server'`

***

### ServerMetric

> `const` **ServerMetric**: `object`

Defined in: [packages/prismarine/src/stats/serverMetrics.ts:14](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/stats/serverMetrics.ts#L14)

The names of the metrics the server registers about itself, keyed by the part after the
`jsprismarine:` namespace. A provider that reads one of them by name reads it from here.

#### Type Declaration

##### build\_type

> `readonly` **build\_type**: `"jsprismarine:build_type"` = `'jsprismarine:build_type'`

`dev`, `nightly` or `release`, a `label`.

##### online\_mode

> `readonly` **online\_mode**: `"jsprismarine:online_mode"` = `'jsprismarine:online_mode'`

`online` or `offline`, a `label`.

##### player\_platform

> `readonly` **player\_platform**: `"jsprismarine:player_platform"` = `'jsprismarine:player_platform'`

Online players per device platform, such as `Android`, a `distribution`.

##### player\_protocol

> `readonly` **player\_protocol**: `"jsprismarine:player_protocol"` = `'jsprismarine:player_protocol'`

Online players per Minecraft release, then protocol number, a `breakdown`.

##### player\_transport

> `readonly` **player\_transport**: `"jsprismarine:player_transport"` = `'jsprismarine:player_transport'`

Online players per transport they joined over, a `distribution`.

##### players

> `readonly` **players**: `"jsprismarine:players"` = `'jsprismarine:players'`

Players online, a `gauge`.

##### transports

> `readonly` **transports**: `"jsprismarine:transports"` = `'jsprismarine:transports'`

The transports the server started, a `set`.

##### version

> `readonly` **version**: `"jsprismarine:version"` = `'jsprismarine:version'`

The server version, such as `0.20.0`, a `label`.

## Functions

### deviceOsName()

> **deviceOsName**(`os`): `string`

Defined in: [packages/prismarine/src/stats/serverMetrics.ts:67](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/stats/serverMetrics.ts#L67)

The name of a device OS a client reported. The value comes from the client's login, so only a
number that is a `BuildPlatform` member counts, and anything else is `Unknown`.

#### Parameters

##### os

`unknown`

The `DeviceOS` value from the client's login, or undefined for a player with no device.

#### Returns

`string`

A name from [DEVICE\_OS\_NAMES](#device-os-names).

***

### serverMetrics()

> **serverMetrics**(`sources`): [`StatsMetric`](https://jsprismarine.dev/api/@jsprismarine/prismarine/stats/StatsMetric/index.md#statsmetric)[]

Defined in: [packages/prismarine/src/stats/serverMetrics.ts:97](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/stats/serverMetrics.ts#L97)

The metrics the server registers about itself, one per [ServerMetric](#servermetric) name. Each reads
its source when a provider asks, so a config reload or a player joining shows up in the next
reading.

A protocol is reported under the first Minecraft release that speaks it, such as `1.26.60` for
the protocol 1.26.60 to 1.26.62 share, since a client names only its protocol.

#### Parameters

##### sources

[`ServerMetricSources`](#servermetricsources)

The config, the networking, the session manager and the build values to read.

#### Returns

[`StatsMetric`](https://jsprismarine.dev/api/@jsprismarine/prismarine/stats/StatsMetric/index.md#statsmetric)[]

The metrics, in [ServerMetric](#servermetric) order.
