np_net
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.
- Version
- 1.0.0
- Frameworks
- None needed. Shim es_extended to see ESX callbacks
- Dependencies
- None. Measured resources must be Lua 5.4
- Database
- None
- Monitoring
- Prometheus + Grafana, as a docker compose stack in
monitoring/ - Endpoint
/np_net/metricsbehind a Bearer token, optional IP list- Optional
- np_admin (permissions, staff tools, live settings, audit log)
- Permissions
- np_admin nodes
np_net.viewandnp_net.manage, no ACE. The console command is console only

np_net has no in-game UI. These are renders of its provisioned Grafana dashboard and the npnet console command with mock data, at 1920×1080. Names and numbers are made up.
What's in it
One manifest line per resource. The shim counts in local tables and hands np_net a delta every 5 seconds, so nothing is sent per event.
Per event, per resource
- Sends, normal and latent, with their payload bytes.
- Server egress as bytes × recipients, and broadcasts to
-1.
Handler time
- Net events received, time spent in their handlers and the slowest run.
- Server and client side: clients send one batched report every 30 s.
Why players drop
- Timeout, reliable overflow, exiting, crash, kicked, banned, resource, other.
- Players, average and highest ping every 5 s.
Server tick
- A histogram of the time between two server ticks.
- A hitch counter, 150 ms by default.
State bags and memory
- State bag changes per key and bag type, value bytes if you want them.
- Lua memory of every shimmed resource, server and client.
Prometheus and Grafana
/np_net/metricsbehind a Bearer token, optional IP list.- A docker compose stack with a provisioned dashboard: eight rows, 33 panels.
Console
npnet topby bytes, count, egress or handler time, without Grafana.npnet patch np_*adds the shim line to every manifest.
Measures only
- Same targets, same arguments, same
source, same return values. - Errors in handlers are not caught. Nothing is merged, delayed or dropped.
A closer look
Events
The Overview and Events rows answer the first question: what costs the bandwidth. Filter by server, resource and side.

- Payload bytes once per send, and egress as bytes × recipients. A broadcast to 120 players counts 120 times.
- Broadcast share: how many server sends go to
-1. High often means an event only some players need. - Latent vs normal payload bytes, so you see what already goes through the latent queue.
- Client → server: the events clients flood the server with, from their batched reports.
Handlers and the server tick
When the tick p95 goes up, the handler graphs show what ran at the same time.

| Panel | What it shows |
|---|---|
| Time spent | Seconds per second in the handlers of each net event, server and client side |
| Max single run | The slowest run in the last window. Handler time is wall time, so a handler that calls Wait() includes the wait |
| Handler cost | Time and receives side by side, for the average cost of one arrival |
| Tick | The time between two server ticks as a heatmap and p50 / p95 / p99. Buckets from 10 ms to 1 s |
| Hitches | Ticks slower than np_net_hitch_ms (150), per minute |
Player drops and state bags
Every drop reason is sorted into one of eight categories. State bags are counted by bag type and key, never by bag id, so a thousand entities stay one series per key.

- reliable_overflow usually means a resource sends too much, too fast. Look at the egress graph right before it.
- Categories: banned, reliable_overflow, crash, timeout, kicked, then the drop code of newer artifacts, resource, exiting, other.
- State bags: global, player, entity and other, per key. Value bytes with
np_net_statebag_bytes 1. - Lua memory per shimmed resource. Client side: the average of every connected client's latest report.
Console and np_admin
No Grafana at hand? npnet top prints the most expensive events in the server console.

| Command | What |
|---|---|
npnet status | Shimmed resources, last push, Lua memory, series, endpoint state |
npnet top | By bytes, count, egress or handler, any number of rows |
npnet reset | Zero every counter |
npnet patch | Add the shim line to one resource, np_* or all; unpatch removes exactly those lines |
| np_admin | Nodes np_net.view / np_net.manage, staff tools for top events, status and reset (output in F8), live settings and the audit log |
How the shim works
init.lua runs inside each resource's own Lua state, on both sides, and wraps the event functions there.
- A send packs its arguments once and calls the same
*Internalnative the CitizenFX scheduler calls, so the size is known without packing twice. - Handlers get the same arguments (
nilholes included),sourceand return values.RemoveEventHandlerkeeps working. - Counts stay in local tables and go to np_net as one delta every 5 s. Without np_net running, the shim keeps counting and drops the deltas.
- If a native or
msgpack.pack_argsis missing, the original function is called and the send is counted without bytes.
| Side | Wrapped |
|---|---|
| server | TriggerClientEvent, TriggerLatentClientEvent |
| client | TriggerServerEvent, TriggerLatentServerEvent |
| both | RegisterNetEvent, RegisterServerEvent, AddEventHandler |
Security
Port 30120 is public for players, so the endpoint is closed until you set a token.
| Concern | How it's handled |
|---|---|
| Endpoint | Answers 503 until np_net_token is set. Prometheus sends Authorization: Bearer; the compare doesn't stop at the first wrong character |
| IP list | np_net_allow_ips for a fixed scrape address. Firewall /np_net/metrics to the Prometheus host as well |
| Token | A server convar with set, never setr. Never in a file and never sent to clients |
| Client reports | Untrusted. Types, sizes and ranges checked, one report per player per interval, only resources that exist, rejected reports counted by reason |
| Grafana | Bound to 127.0.0.1. Reach it through an SSH tunnel or a VPN |
- Client numbers find problems, they don't prove anything. A modified client can report any number. Server numbers are measured on the server.
- Run the stack on a small separate box. Prometheus and Grafana on the FXServer machine cause exactly the hitches the dashboard is meant to find.
- The scrape is plain HTTP: run it over a private network or WireGuard / Tailscale when the boxes aren't in one data centre.
Set it up
Compatibility
Any Lua 5.4 resource can be shimmed, np_* or not. np_net uses no framework; to see framework traffic, shim the framework itself.
| Setup | What to shim |
|---|---|
| es_extended | ESX callbacks run in es_extended's Lua state. npnet patch es_extended to see esx:triggerServerCallback and friends |
| qbx_core / qb-core | A function you get from the core's export runs in the core's state. Patch the core to see its events |
| ox_lib | Callbacks run in the resource that uses them. Its shim counts them, as long as the shim line comes before @ox_lib/init.lua |
| Standalone | Patch the resources you want to see. Drops, tick, ping and state bags need no shim |
| Not covered | Why |
|---|---|
| JS and C# resources | The shim is Lua |
| Unshimmed resources | Invisible to the event metrics |
| Engine traffic | Entity sync, voice and state bag replication aren't events. The tick and FXServer's own /perf/ show their effect |
| Local events | TriggerEvent never touches the network and isn't counted |
Installation
On start the console shows ready, metrics at /np_net/metrics (open, bearer token set).
- Copy
np_netinto your resources and add it toserver.cfg, early:set np_net_token "a-long-random-string" # set, never setr ensure np_net # before the resources you measure - Add the shim to each resource you want to see, as the first script line of its
fxmanifest.lua, before any file that copies the event functions into locals and before@ox_lib/init.lua:shared_script '@np_net/init.lua' - Or let np_net do it from the server console, then restart each patched resource:
npnet patch np_* # every resource starting with np_ npnet patch es_extended npnet unpatch all # removes exactly the lines np_net added - Point Prometheus at
http://<server>:30120/np_net/metricswithAuthorization: Bearer <token>, or use the stack inmonitoring/(next tab).
Prometheus and Grafana
monitoring/ is a docker compose stack: Prometheus v3 and Grafana with the np_net dashboard as the home dashboard.
cd monitoring
cp .env.example .env
$EDITOR .env # GF_ADMIN_PASSWORD, FIVEM_TARGET=host:30120
# same value as np_net_token in server.cfg
printf '%s' 'paste-the-token-here' > secrets/np_net_token
docker compose up -d
# from your PC: both only listen on 127.0.0.1
ssh -L 3000:127.0.0.1:3000 -L 9090:127.0.0.1:9090 you@monitoring-box| Dashboard row | Panels |
|---|---|
| Overview | Players, ping, hitches, tick p95, net egress, event traffic |
| Events | Top events by egress, sends/s, client → server bytes, broadcast share, latent vs normal |
| Handlers | Time spent, max single run, handler cost |
| Player drops | Drops by category, drops in range |
| Server tick | Heatmap, quantiles, hitches per minute |
| State bags | Changes per bag type, top keys |
| Resources & exporter | Lua memory, shimmed resources, series, version |
| Client reports | Reports per second, rejected by reason |
Several servers: one target file with a server label each, picked in the dashboard's Server variable. FXServer's own /perf/ endpoint can be added as an optional job; its path and auth differ between artifacts, so check it with curl -i first.
Configuration
Everything is a convar in server.cfg. With np_admin, most of them can be changed live, and an np_admin value beats the convar.
| Convar | Default | What |
|---|---|---|
np_net_token | empty | Bearer token; empty = 503 |
np_net_allow_ips | empty | Comma list of IPs allowed to scrape |
np_net_flush_ms | 5000 | How often each shim hands over its delta (setr) |
np_net_client_report_ms | 30000 | Client report interval, 0 = off (setr) |
| Convar | Default | What |
|---|---|---|
np_net_max_series | 2000 | Label series kept; beyond it __other__ |
np_net_tick | 1 | Measure the server tick |
np_net_hitch_ms | 150 | A slower tick is a hitch |
np_net_statebags | 1 | Count state bag changes |
np_net_statebag_bytes | 0 | Also count value bytes (costs CPU) |
The token, the IP list and the flush interval stay convars. Everything else is in np_admin's Resource settings → np_net.
Questions
Does it change how my events behave?
No. Every event goes to the same targets through the same natives, handlers get the same arguments, source and return values, and errors are not caught. np_net never merges, delays or drops anything.
Does it cost performance?
Very little. A send is packed once, as it would be anyway. Counts stay in local tables and go to np_net as one delta every 5 seconds; clients send one latent report every 30 seconds. The scrape renders numbers np_net has already aggregated.
Do I need Grafana?
No. npnet top prints the most expensive events in the console, and any Prometheus-compatible tool can scrape the endpoint. The docker compose stack in monitoring/ is the quickest way to the dashboard.
Why don't I see ESX callbacks?
They run in es_extended's Lua state, not in the resource that asked. Patch es_extended too and they appear under resource="es_extended".
Can I trust the client numbers?
Use them to find problems, not as proof against a player. A modified client can report any number. np_net checks every report, rate-limits each player and counts rejected reports, but only server-side numbers are measured by the server itself.
Does it use ACE permissions?
No. The console command is console only. With np_admin, staff get the nodes np_net.view and np_net.manage for the staff tools.
Works well with

See what your events cost.
Every metric, the dashboard and the monitoring stack are in the docs.