Monitoring

class uwsgiconf.options.monitoring.Monitoring(*args, **kwargs)

Monitoring facilities.

class metric_types

Various metric types to represent data of various nature.

User metrics must inherit from one of those.

absolute

alias of uwsgiconf.options.monitoring_metric_types.MetricTypeAbsolute

alias

alias of uwsgiconf.options.monitoring_metric_types.MetricTypeAlias

counter

alias of uwsgiconf.options.monitoring_metric_types.MetricTypeCounter

gauge

alias of uwsgiconf.options.monitoring_metric_types.MetricTypeGauge

class collectors

Metric collection and accumulation means.

accumulator

alias of uwsgiconf.options.monitoring_collectors.CollectorAccumulator

adder

alias of uwsgiconf.options.monitoring_collectors.CollectorAdder

avg

alias of uwsgiconf.options.monitoring_collectors.CollectorAvg

file

alias of uwsgiconf.options.monitoring_collectors.CollectorFile

function

alias of uwsgiconf.options.monitoring_collectors.CollectorFunction

multiplier

alias of uwsgiconf.options.monitoring_collectors.CollectorMultiplier

pointer

alias of uwsgiconf.options.monitoring_collectors.CollectorPointer

sum

alias of uwsgiconf.options.monitoring_collectors.CollectorSum

class pushers

Means to deliver metrics to various remotes or locals.

These are available for .register_stats_pusher().

carbon

alias of uwsgiconf.options.monitoring_pushers.PusherCarbon

file

alias of uwsgiconf.options.monitoring_pushers.PusherFile

mongo

alias of uwsgiconf.options.monitoring_pushers.PusherMongo

rrdtool

alias of uwsgiconf.options.monitoring_pushers.PusherRrdtool

socket

alias of uwsgiconf.options.monitoring_pushers.PusherSocket

statsd

alias of uwsgiconf.options.monitoring_pushers.PusherStatsd

zabbix

alias of uwsgiconf.options.monitoring_pushers.PusherZabbix

register_metric(metric)

Officially Registered Metrics:

  • worker 3 - exports information about workers.
    Example: worker.1.requests [or 3.1.1] reports the number of requests served by worker 1.
  • plugin 4 - namespace for metrics automatically added by plugins.
    Example: plugins.foo.bar
  • core 5 - namespace for general instance information.
  • router 6 - namespace for corerouters.
    Example: router.http.active_sessions
  • socket 7 - namespace for sockets.
    Example: socket.0.listen_queue
  • mule 8 - namespace for mules.
    Example: mule.1.signals
  • spooler 9 - namespace for spoolers.
    Example: spooler.1.signals
  • system 10 - namespace for system metrics, like loadavg or free memory.
Parameters:metric (Metric|list[Metric]) – Metric object.
set_metrics_params(enable=None, store_dir=None, restore=None, no_cores=None)

Sets basic Metrics subsystem params.

uWSGI metrics subsystem allows you to manage “numbers” from your apps.

When enabled, the subsystem configures a vast amount of metrics (like requests per-core, memory usage, etc) but, in addition to this, you can configure your own metrics, such as the number of active users or, say, hits of a particular URL, as well as the memory consumption of your app or the whole server.

Parameters:
  • enable (bool) – Enables the subsystem.
  • store_dir (str) –

    Directory to store metrics. The metrics subsystem can expose all of its metrics in the form of text files in a directory. The content of each file is the value of the metric (updated in real time).

    Note

    Placeholders can be used to build paths, e.g.: {project_runtime_dir}/metrics/ See Section.project_name and Section.runtime_dir.

  • restore (bool) – Restore previous metrics from store_dir. When you restart a uWSGI instance, all of its metrics are reset. Use the option to force the metric subsystem to read-back the values from the metric directory before starting to collect values.
  • no_cores (bool) – Disable generation of cores-related metrics.
set_metrics_threshold(name, value, *, check_interval=None, reset_to=None, alarm=None, alarm_message=None)

Sets metric threshold parameters.

Parameters:
  • name (str) – Metric name.
  • value (int) – Threshold value.
  • reset_to (int) – Reset value to when threshold is reached.
  • check_interval (int) – Threshold check interval in seconds.
  • alarm (str|AlarmType) – Alarm to trigger when threshold is reached.
  • alarm_message (str) – Message to pass to alarm. If not set metrics name is passed.
set_stats_params(address=None, enable_http=None, minify=None, no_cores=None, no_metrics=None, push_interval=None)

Enables stats server on the specified address.

Parameters:
  • address (str) –

    Address/socket to make stats available on.

    Examples:
    • 127.0.0.1:1717
    • /tmp/statsock
    • :5050
  • enable_http (bool) – Server stats over HTTP. Prefixes stats server json output with http headers.
  • minify (bool) – Minify statistics json output.
  • no_cores (bool) – Disable generation of cores-related stats.
  • no_metrics (bool) – Do not include metrics in stats output.
  • push_interval (int) – Set the default frequency of stats pushers in seconds/
register_stats_pusher(pusher)

Registers a pusher to be used for pushing statistics to various remotes/locals.

Parameters:pusher (Pusher|list[Pusher]) –
enable_snmp(address, community_string)

Enables SNMP.

uWSGI server embeds a tiny SNMP server that you can use to integrate your web apps with your monitoring infrastructure.

Note

SNMP server is started in the master process after dropping the privileges. If you want it to listen on a privileged port, you can either use Capabilities on Linux, or use the as-root option to run the master process as root.

Parameters:
  • address (str) –

    UDP address to bind to.

    Examples:

    • 192.168.1.1:2222
  • community_string (str) – SNMP instance identifier to address it.