Skip to content

API reference / @jsprismarine/prismarine / stats/serverMetrics

stats/serverMetrics ​

Interfaces ​

ServerMetricSources ​

Defined in: packages/prismarine/src/stats/serverMetrics.ts:74

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

Defined in: packages/prismarine/src/stats/serverMetrics.ts:79

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

Returns ​

BuildDefines

config ​

readonly config: Pick<Config, "getOnlineMode">

Defined in: packages/prismarine/src/stats/serverMetrics.ts:75

networking ​

readonly networking: Pick<ServerNetworking, "getStartedTransports">

Defined in: packages/prismarine/src/stats/serverMetrics.ts:76

sessions ​

readonly sessions: Pick<SessionManager, "getSessions">

Defined in: packages/prismarine/src/stats/serverMetrics.ts:77

Type Aliases ​

ServerMetricName ​

ServerMetricName = typeof ServerMetric[keyof typeof ServerMetric]

Defined in: packages/prismarine/src/stats/serverMetrics.ts:34

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

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

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

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.


serverMetrics() ​

serverMetrics(sources): StatsMetric[]

Defined in: packages/prismarine/src/stats/serverMetrics.ts:97

The metrics the server registers about itself, one per 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

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

Returns ​

StatsMetric[]

The metrics, in ServerMetric order.