np_net v1.0.0 ​
Network metrics for FiveM servers. np_net counts which events cost bytes, broadcasts and handler time, and why players drop. Prometheus scrapes the numbers and Grafana shows them.
It only measures. No event is changed, delayed, merged or dropped. np_net is standalone: no framework, no database, no in-game UI. np_admin is optional.
ensure np_net # early, before the resources you want to measure
set np_net_token "a-long-random-string"
-- fxmanifest.lua of every resource you want to see, as the FIRST script line
shared_script '@np_net/init.lua'
Then scrape http://<server>:30120/np_net/metrics with Authorization: Bearer a-long-random-string.
What you get ​
- Per event, per resource: sends (normal / latent), payload bytes, server egress (bytes × recipients),
broadcasts to
-1, net events received, handler time (total and the slowest run). - Both sides: server resources report directly. Clients send one batched report every 30 s, so you also see what clients send to the server and how long client handlers take.
- Player drops by reason: timeout, reliable_overflow, exiting, crash, kicked, banned, resource, other.
- Players and ping: count, average and highest ping, every 5 s.
- Server tick: a histogram of the time between two server ticks, plus a hitch counter.
- State bags: changes per key and bag type (global / player / entity / other), optionally with value bytes.
- Lua memory of every shimmed resource, server and client.
- Console:
npnet topprints the most expensive events without Grafana. - Heatmaps: player time, time in vehicles, deaths, low FPS and every drop category per map cell and day, in a viewer np_net serves itself. See Heatmaps.
- Monitoring stack: a docker compose Prometheus + Grafana setup with a provisioned dashboard. See Grafana & Prometheus.
Every metric with its labels is on Metrics.
How it works ​
init.lua is a shim. With shared_script '@np_net/init.lua' it runs inside the resource's own Lua state, on
both sides, and wraps the event globals there:
| Side | Wrapped |
|---|---|
| server | TriggerClientEvent, TriggerLatentClientEvent |
| client | TriggerServerEvent, TriggerLatentServerEvent |
| both | RegisterNetEvent, RegisterServerEvent, AddEventHandler |
resource state (shim) np_net Prometheus → Grafana
counts in local tables ──every 5 s──▶ server: exports.np_net:push
client: local event → one report / 30 s → server
aggregates, renders /np_net/metrics ◀── scrape every 15 s
- A send packs its arguments once and calls the same
*Internalnative the CitizenFX scheduler calls, so the shim knows the payload size without packing twice. - Only handlers of net events are wrapped. They get the same arguments, the same
sourceand the same return values. Errors are not caught. Other handlers aren't touched. - Counts stay in local tables. Every
np_net_flush_ms(5 s) the shim hands a delta to np_net. Nothing is sent per event. - When np_net isn't running, the shim keeps counting and drops the deltas.
Details on Development.
Handler time is wall time
A handler that calls Wait() includes the wait in np_net_event_handler_seconds_total. A slow handler that waits on
a database callback looks as slow as one that blocks the thread.
Quick look without Grafana ​
npnet top bytes 5
top 5 by bytes
side resource event sent bytes egress recv handler
server np_hud np_hud:sync 18240 4.1 MB 96.3 MB 0 0.0ms
server np_inventory np_inventory:update 3112 2.7 MB 2.7 MB 0 0.0ms
client np_phone np_phone:server:sync 1450 812.4 kB 0 B 0 0.0ms
server es_extended esx:setPlayerData 2210 604.0 kB 604.0 kB 0 0.0ms
server np_payments np_payments:server:charge 0 0 B 0 B 388 912.4ms
See Commands & np_admin.