Skip to content

Metrics ​

np_net serves Prometheus text format (version=0.0.4) at /np_net/metrics. All names start with np_net_, counters end in _total. Counters only go up until np_net restarts or someone runs npnet reset; use rate() and increase() on them.

Labels ​

Label Values
side Where it happened: server or client. side="client" series come from client reports
resource The shimmed resource
event The event name, or __other__ (see Series cap)
kind normal or latent
category Drop category (see Player drops)
bag, key State bag type (global, player, entity, other) and key
reason Why a client report was rejected
le Histogram bucket

Prometheus adds job, instance and the server label from the target file.

Events ​

Metric Type Labels Meaning
np_net_event_sent_total counter side, resource, event, kind Sends. Server: TriggerClientEvent / TriggerLatentClientEvent. Client: TriggerServerEvent / TriggerLatentServerEvent
np_net_event_sent_bytes_total counter side, resource, event, kind Packed payload bytes, once per send
np_net_event_egress_bytes_total counter resource, event, kind Server only: payload bytes × recipients. A broadcast to 120 players counts 120 times
np_net_event_broadcast_total counter resource, event Server sends to -1
np_net_event_received_total counter side, resource, event Net events that arrived over the network, on the side that received them. Counted once per arrival, however many handlers the resource registered, as long as it has at least one Lua function handler for the name
np_net_event_handler_seconds_total counter side, resource, event Time spent in handlers of net events that arrived over the network. Wall time
np_net_event_handler_max_seconds gauge side, resource, event Slowest single run in the last window. Goes back to 0 after two quiet windows

Notes:

  • Bytes are payload bytes: the msgpack'd arguments. FiveM's own framing (event name, packet headers) isn't included. Compare events with each other, not with your NIC graph.
  • Egress is computed: -1 uses the current player count, a table of targets its length, a single id 1.
  • Sends to a table of targets go through the original function, so they are counted without bytes.
  • If msgpack.pack_args or the *Internal native is missing on an artifact, the original function is called and the send is counted without bytes.
  • Only handlers of net events are wrapped (names passed to RegisterNetEvent). Other handlers go to the scheduler untouched. A local TriggerEvent of a net event name runs straight through and is neither counted nor timed.
  • Handler time is wall time. A handler that calls Wait() includes the wait.

Useful queries:

txt
# what costs the most upstream bandwidth
topk(10, sum by (resource, event) (rate(np_net_event_egress_bytes_total[5m])))

# which client events flood the server
topk(10, sum by (resource, event) (rate(np_net_event_sent_total{side="client"}[5m])))

# average handler time per arrival
sum by (resource, event) (rate(np_net_event_handler_seconds_total[5m]))
  / sum by (resource, event) (rate(np_net_event_received_total[5m]))

Player drops ​

Metric Type Labels
np_net_player_drops_total counter category

Categories are checked in this order, on the lowercased drop reason:

Category Matches
banned The text says "banned" or "ban"
reliable_overflow "…overflow" (reliable buffer overflow: usually a resource sending too much, too fast)
crash "crash"
timeout "timed out" or "timeout", including "Server->client connection timed out. Pending commands …"
kicked "kick"
then the clientDropReason code of newer artifacts: resource, client exit, timed out
resource A resource dropped them (resourceName is set)
exiting "Exiting", "Disconnected.", "Quit"
other Anything else

All eight categories are always exported, also at 0.

Label values that aren't valid UTF-8 (server event names, state bag keys) are written with U+FFFD, so one odd name can't make Prometheus reject the whole scrape.

Players and ping ​

Sampled every 5 s.

Metric Type
np_net_players gauge
np_net_player_ping_avg_ms gauge
np_net_player_ping_max_ms gauge

Server tick ​

np_net runs a Wait(0) loop and measures the time between two resumes. On a healthy server that is one server frame; when the main thread stalls, it grows.

Metric Type Labels
np_net_tick_ms histogram le = 10, 25, 50, 75, 100, 150, 250, 500, 1000, +Inf
np_net_hitches_total counter Ticks slower than np_net_hitch_ms (150)
txt
histogram_quantile(0.95, sum by (le) (rate(np_net_tick_ms_bucket[5m])))

Off with np_net_tick 0.

State bags ​

Every change the server sees, through one AddStateBagChangeHandler.

Metric Type Labels
np_net_statebag_changes_total counter bag, key
np_net_statebag_bytes_total counter bag, key. Only with np_net_statebag_bytes 1

bag is global, player (player:<id>), entity (entity: and localEntity:) or other. Bag ids are never a label, so a thousand entities stay one series per key.

Resources and the exporter ​

Metric Type Labels Meaning
np_net_info gauge (1) version np_net version
np_net_resource_lua_memory_bytes gauge side, resource Lua memory (collectgarbage('count')) of each shimmed resource. Client side: the average of the latest report of each connected client
np_net_resources_shimmed gauge side Resources whose shim reported
np_net_series gauge Label series np_net currently keeps, all three budgets together
np_net_series_dropped_total counter Deltas folded into __other__ by the series cap

Series cap ​

Every side × resource × event and every bag × key is one series. np_net keeps at most np_net_max_series (2000) in each of three budgets: server events, client-reported events and state bag keys. Clients (which can report any event name, and set their own state bag keys) can't push server events into __other__. Beyond the cap, new names are counted as event="__other__" (or key="__other__") and np_net_series_dropped_total goes up. Each shim also keeps at most 128 event names per resource.

If __other__ grows, a resource is probably building event or key names from data ('job:' .. playerId). Fix the name, or raise the cap.

Client reports ​

np_net's client collects the deltas of every shimmed resource on that client and sends one latent report per np_net_client_report_ms (30 s). The first report of each client is spread over half an interval, so clients don't all report in the same second.

Metric Type Labels
np_net_client_reports_total counter Every report that arrived
np_net_client_reports_rejected_total counter reason
Reason
disabled Reports are off (np_net_client_report_ms 0)
rate Sooner than max(5 s, interval / 2) after the player's last report. Rejected reports start the gap too
shape Not the expected table layout
too_many_resources More than 64 resources
too_many_events More than 150 events for one resource
bad_name Empty, too long, control characters or not valid UTF-8
bad_value Not a finite number, negative, out of range, or a fractional count
unknown_resource A resource that doesn't exist on the server

A malformed report is rejected as a whole. Client numbers are untrusted: see Compatibility → Client numbers.

Heatmaps ​

The maps themselves are in the heatmap viewer. Prometheus only gets two counters:

Metric Type Labels Meaning
np_net_heatmap_points_total counter layer Points recorded on the heatmaps since start
np_net_heatmap_ignored_total counter reason invalid: off the map, a bad value or more than 48 layers a day. cell_cap: a new cell beyond np_net_heatmap_max_cells

Snapshot export ​

The same numbers as a Lua table, for your own tooling:

lua
local snap = exports.np_net:GetSnapshot()
-- { version, events = { { side, resource, event, sent, sentLatent, bytes, egress, broadcasts, received,
--   handlerSeconds, handlerMaxSeconds }, ... }, statebags, drops, players, tick, series, seriesDropped, shimmed, reports }

exports.np_net:AddHeat(layer, where, weight) adds a heatmap point: see Heatmaps → Your own layers.

exports.np_net:push is what the shim calls. Don't call it yourself.