[Release] [V8] Prometheus

FiveM Prometheus

This resource adds a Prometheus endpoint to your FX Server.
There are some default metrics available and you can add yours.

Downloads

Default metrics

Screenshot

Name Type Description
fxs_player_count Gauge Number of connected players
fxs_player_connections Counter Number of player connections
fxs_player_disconnections Counter Number of player disconnections
fxs_average_player_latency Gauge Average player latency
fxs_players_latency Histogram Players latency
fxs_min_player_ping Gauge Minimum player ping
fxs_max_player_ping Gauge Maximum player ping

Configuration

Convars available:

Name Type Default value Description
prometheus_timeout int 5000 Interval in ms to collect data
prometheus_auth_enabled int 0 Protects the endpoint with credentials if true (1)
prometheus_login string “admin” Endpoint login
prometheus_password string “admin” Endpoint password

Prometheus configuration

# A scrape configuration containing exactly one FXS endpoint to scrape.
scrape_configs:
  - job_name: 'fxserver'
    scrape_interval: 60s
    basic_auth:
      username: admin
      password: admin
    metrics_path: /prometheus/metrics
    static_configs:
      - targets: ['127.0.0.1:30120']

Usage

Add a new metric

--[[
 * @event prometheus:addMetric
 *
 * @param {string} type - The metric type, i.e. Gauge.
 * @param {string} name - The metric name.
 * @param {string} description - The metric description.
 * @param {function} cb - A callback function to update the metric with a method name (i.e. set) and a value.
]]
TriggerEvent("prometheus:addMetric", "Gauge", "fxs_gauge_example", "Gauge example.", function(cb)
    math.randomseed(os.clock())
    if math.random(0, 1) == 1 then
      cb("set", 42)
    else
      cb("set", 1664)
    end
end)
23 Likes

That look’s nice, best release I’ve seen in a while. Will try it out! Thanks

thy for sharing, looks interesting, I will try

Wonderful for sure ill be using this for the server.

1 Like

Damn this is hot, Good job bud!

nice release.keep it up

Awesome Release Man!
+1

This shit is Fire!!!

@Hellslicer I am attempting to set this up and I am not sure what Im missing its throwing an error in my server cmd saying its missing prom-client

1 Like

If you don’t use the Yarn resource you should install dependencies manually.
Navigate to the Prometheus resource folder and then run: npm install

Please forgive my continued ignorance, I navigated out to your folder “fivem-prometheus” and ran npm install via powershell and it gave me an error.

@Hellslicer, sorry I am also new to the forms so I apologize if this double tags you

Looks sexy. Will check out in le morning

I have set the prometheus exporter on the FX server. I try to validate it with postman. I am running with defaults.
I am getting Route /prometheus/metrics not found. and I also try Route /metrics not found. too.

I am running this on a windows server too.

I have no errors. Am I missing something?

Thanks in Advance.

Rename the folder to prometheus (instead of fivem-prometheus) if you want to use /prometheus/metrics route.

okay, tried that. Now getting the following error –

This seems to be like an error connecting to http://127.0.0.1/prometheus/metrics. The response status was 0.
Check out the W3C XMLHttpRequest Level 2 spec for more details about when this happens.

You forgot the port of your FX Server. i.e.: http://127.0.0.1:30120/prometheus/metrics

1 Like

Thanks. That was embarrassing. :stuck_out_tongue_winking_eye: Working great now. :slight_smile:

How do I specify the convar values in the server config?

Is it set prometheus_auth_enabled 1 or just prometheus_auth_enabled 1 and also the other two values of prometheus_login and prometheus_password?

Thanks in Advance.

set prometheus_auth_enabled 1
set prometheus_login "some_login"
set prometheus_password "some_password"