Skip to content

Monitoring

Classes

Monitoring

Monitoring(*args, **kwargs)

OptionsGroup

Monitoring facilities.


name

.name: str = ''

Name to represent the group.


plugin

.plugin: bool | str = False

Indication this option group belongs to a plugin.


enable_snmp

.enable_snmp(address: str, community_string: str)

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.


register_metric

.register_metric(metric)

Officially Registered Metrics:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
* ``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.

register_stats_pusher

.register_stats_pusher(pusher)

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


set_metrics_params

1
2
3
4
5
6
.set_metrics_params(
    enable: bool | None = None,  # (1)!
    store_dir: str | None = None,  # (2)!
    restore: bool | None = None,  # (3)!
    no_cores: bool | None = None,  # (4)!
)
  1. Enables the subsystem.

  2. 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.

  3. 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.

  4. Disable generation of cores-related metrics.

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.


set_metrics_threshold

1
2
3
4
5
6
7
8
.set_metrics_threshold(
    name: str,  # (1)!
    value: str,  # (2)!
    check_interval: int | None = None,  # (3)!
    reset_to: int | None = None,  # (4)!
    alarm=None, 
    alarm_message: str | None = None,  # (5)!
)
  1. Metric name.

  2. Threshold value.

  3. Threshold check interval in seconds.

  4. Reset value to when threshold is reached.

  5. Message to pass to alarm. If not set metrics name is passed.

Sets metric threshold parameters.


set_stats_params

1
2
3
4
5
6
7
8
.set_stats_params(
    address: str | None = None,  # (1)!
    enable_http: bool | None = None,  # (2)!
    minify: bool | None = None,  # (3)!
    no_cores: bool | None = None,  # (4)!
    no_metrics: bool | None = None,  # (5)!
    push_interval: int | None = None,  # (6)!
)
  1. Address/socket to make stats available on.

    1
    2
    3
    4
    Examples:
        * 127.0.0.1:1717
        * /tmp/statsock
        * :5050
    
  2. Server stats over HTTP. Prefixes stats server json output with http headers.

  3. Minify statistics json output.

  4. Disable generation of cores-related stats.

  5. Do not include metrics in stats output.

  6. Set the default frequency of stats pushers in seconds/

Enables stats server on the specified address.


collectors

.collectors()

Metric collection and accumulation means.


metric_types

.metric_types()

Various metric types to represent data of various nature.

User metrics must inherit from one of those.


pushers

.pushers()

Means to deliver metrics to various remotes or locals.

These are available for .register_stats_pusher().