0.4.0 • Published 5 years ago

nodebb-plugin-prometheus v0.4.0

Weekly downloads
3
License
MIT
Repository
gitlab
Last release
5 years ago

nodebb-plugin-prometheus

nodebb compatibility

Discuss it or give feedback in the NodeBB community or create an issue in the repository.

Provides a Prometheus exporter endpoint to your NodeBB and exposes metrics. You can secure the endpoint either via your reverse proxy or an access token validated by the plugin. By default the endpoint will be provided at /metrics. Find all the settings in the plugin's ACP page.

The following metrics are provided for NodeBB:

KeyTypeHelp
nodebb_users_totalgaugeTotal registered users
nodebb_posts_totalgaugeTotal posts
nodebb_topics_totalgaugeTotal topics
nodebb_unique_users_5mgaugeUnique users over the last five minutes
nodebb_unique_users_60mgaugeUnique users over the last 60 minutes
nodebb_unique_users_24hgaugeUnique users over the last 24 hours
nodebb_unique_users_30dgaugeUnique users over the 30 days
nodebb_page_view_totalcounterTotal page views since the last restart. There is a label viewer that can have the value user, guest, or bot
nodebb_online_users_5mgaugeUsers online over the last five minutes
nodebb_online_users_60mgaugeUsers online over the last 60 minutes
nodebb_online_users_24hgaugeUsers online over the last 24 hours
nodebb_online_users_30dgaugeUsers online over the last 30 days
nodebb_not_validated_users_totalgaugeTotal users with the e-mail address not validated
nodebb_banned_users_totalgaugeTotal banned users
nodebb_registration_queue_totalgaugeTotal users waiting in the registration queue
nodebb_flags_totalcounterTotal issued flags since last restart
nodebb_error_404_totalcounterTotal HTTP 404 errors since last restart
nodebb_error_503_totalcounterTotal HTTP 503 errors since last restart
nodebb_blacklisted_totalcounterTotal request blocked via the blacklist since last restart
nodebb_maintenance_activegaugeIf maintenance mode is on 1; otherwise 0
nodebb_online_guestsgaugeGuests that are currently online/connected
nodebb_eventloop_lag_secondsGaugeLag of event loop in seconds measured by NodeBB
nodebb_eventloop_maxlag_secondsGaugeMaximum lag of event loop in seconds allowed by NodeBB before it will start to issue 503 errors
nodebb_plugins_activegaugeIf the plugin is active 1; otherwise 0. Has a label id with the name of the plugin

The counters nodebb_flags_total, nodebb_error_404_total, nodebb_error_503_total, nodebb_blacklisted_total currently reset to the value measured in the current hour. This is important to keep in mind if you want to compute the total over one or more restarts, since the counters didn't restart from 0. This will hopefully be fixed in a later version. It might need a patch for NodeBB to make it possible.

In addition default metrics about NodeJS and the process are provided by the prometheus client library.

KeyTypeHelp
process_cpu_user_seconds_totalcounterTotal user CPU time spent in seconds.
process_cpu_system_seconds_totalcounterTotal system CPU time spent in seconds.
process_cpu_seconds_totalcounterTotal user and system CPU time spent in seconds.
process_start_time_secondsgaugeStart time of the process since unix epoch in seconds.
process_resident_memory_bytesgaugeResident memory size in bytes.
process_virtual_memory_bytesgaugeVirtual memory size in bytes.
process_heap_bytesgaugeProcess heap size in bytes.
process_open_fdsgaugeNumber of open file descriptors.
process_max_fdsgaugeMaximum number of open file descriptors.
nodejs_eventloop_lag_secondsgaugeLag of event loop in seconds.
nodejs_active_handles_totalgaugeNumber of active handles.
nodejs_active_requests_totalgaugeNumber of active requests.
nodejs_heap_size_total_bytesgaugeProcess heap size from node.js in bytes.
nodejs_heap_size_used_bytesgaugeProcess heap size used from node.js in bytes.
nodejs_external_memory_bytesgaugeNodejs external memory size in bytes.
nodejs_heap_space_size_total_bytesgaugeProcess heap space size total from node.js in bytes.
nodejs_heap_space_size_used_bytesgaugeProcess heap space size used from node.js in bytes.
nodejs_heap_space_size_available_bytesgaugeProcess heap space size available from node.js in bytes.
nodejs_version_infogaugeNode.js version info.

If you're developing a plugin and want to add other metrics you can listen for the hook action:nodebb-plugin-prometheus.init. It will pass in the Prometheus client in the first parameter: params.prometheus. Make sure to prefix your metrics with the name of your plugin replacing dashes with underscores. Listen to the hook static:nodebb-plugin-prometheus.metrics to update your metrics. It will be fired when a scrape request is made. Further documentation on how to use the Prometheus client can be found at it's repository.

plugin.initPrometheus = function(params) {
  let gauge = new params.prometheus.Gauge({
    name: 'nodebb_plugin_foo_bar_value_total',
    help: 'The total value of my foobar plugin'
  });
  
  // ...
}