Skip to content

Installation ​

Requirements ​

  • A FiveM server artifact. The resources you measure must be Lua 5.4 (lua54 'yes').
  • To look at the numbers: Prometheus and Grafana. monitoring/ in the resource has a ready docker compose stack, see Grafana & Prometheus.

No framework, no database, no NUI build. Optional:

Resource Used for
np_admin Permissions, staff tools, live settings and the audit log (see Commands & np_admin)

1. Copy and configure ​

Copy the folder into your resources as np_net. The shim path @np_net/init.lua and exports.np_net depend on that name.

cfg
set np_net_token "a-long-random-string"   # `set`, never `setr`: setr would send it to every client
ensure np_net                             # before the resources you measure

Generate the token with openssl rand -hex 32. Without a token the endpoint answers 503 and the console logs a hint once. All convars are on Configuration.

2. Add the shim ​

Add one line to each resource you want to see, as the first script line of its fxmanifest.lua, right after fx_version / game / lua54:

lua
fx_version 'cerulean'
game 'gta5'
lua54 'yes'

shared_script '@np_net/init.lua'   -- np_net

shared_scripts { '@ox_lib/init.lua', 'shared/config.lua' }
client_scripts { 'client/*.lua' }
server_scripts { 'server/*.lua' }

FiveM loads shared scripts before client and server scripts, in manifest order. The shim must run:

  • before any file that copies the event functions into locals (local TriggerClientEvent = TriggerClientEvent), otherwise those locals keep the unwrapped originals;
  • before @ox_lib/init.lua.

A resource without the line is invisible to the event metrics. Drops, tick, ping and state bags are measured by np_net itself and need no shim.

Or let np_net patch the manifests ​

From the server console:

npnet patch np_*        # every resource whose name starts with np_
npnet patch es_extended
npnet unpatch all       # removes exactly the lines np_net added

patch adds shared_script '@np_net/init.lua' -- np_net after the header lines. It skips resources without Lua scripts, never touches np_net itself, and reports already patched when the line is there. unpatch only removes lines that carry the -- np_net marker; a line you added by hand is reported and left alone.

Restart each patched resource (ensure <name>). The shim is loaded when the resource starts.

Updates overwrite the manifest

Updating a resource from its repo replaces its fxmanifest.lua. Run npnet patch again after an update.

3. Check it works ​

On start the console shows:

[np_net] ready, metrics at /np_net/metrics (open, bearer token set)

Then, once the shimmed resources have started and flushed (5 s):

npnet status

lists every shimmed server resource with its last push and Lua memory, the client shims, the series count and the endpoint state. Test the endpoint from the Prometheus host:

sh
curl -s -H "Authorization: Bearer a-long-random-string" http://<server>:30120/np_net/metrics | head
Answer Meaning
200 + text Working
503 np_net_token is not set Set the convar with set, then restart np_net
401 unauthorized Wrong token, or the header is missing
403 forbidden The scraping IP isn't in np_net_allow_ips
404 np_net isn't started, or the path or port is wrong

4. Point Prometheus at it ​

See Grafana & Prometheus for the docker compose stack, targets and the firewall.