Skip to main content

python.d zscores

Plugin: python.d.plugin Module: zscores

Overview

By using smoothed, rolling Z-Scores for selected metrics or charts you can narrow down your focus and shorten root cause analysis.

This collector uses the Netdata rest api to get the mean and stddev for each dimension on specified charts over a time range (defined by train_secs and offset_secs).

For each dimension it will calculate a Z-Score as z = (x - mean) / stddev (clipped at z_clip). Scores are then smoothed over time (z_smooth_n) and, if mode: 'per_chart', aggregated across dimensions to a smoothed, rolling chart level Z-Score at each time step.

This collector is supported on all platforms.

This collector supports collecting metrics from multiple instances of this integration, including remote instances.

Default Behavior

Auto-Detection

This integration doesn't support auto-detection.

Limits

The default configuration for this integration does not impose any limits on data collection.

Performance Impact

The default configuration for this integration is not expected to impose a significant performance impact on the system.

Metrics

Metrics grouped by scope.

The scope defines the instance that the metric belongs to. An instance is uniquely identified by a set of labels.

Per python.d zscores instance

These metrics refer to the entire monitored application.

This scope has no labels.

Metrics:

MetricDimensionsUnit
zscores.za dimension per chart or dimensionz
zscores.3stddeva dimension per chart or dimensioncount

Alerts

There are no alerts configured by default for this integration.

Setup

Prerequisites

Python Requirements

This collector will only work with Python 3 and requires the below packages be installed.

# become netdata user
sudo su -s /bin/bash netdata
# install required packages
pip3 install numpy pandas requests netdata-pandas==0.0.38

Configuration

File

The configuration file name for this integration is python.d/zscores.conf.

You can edit the configuration file using the edit-config script from the Netdata config directory.

cd /etc/netdata 2>/dev/null || cd /opt/netdata/etc/netdata
sudo ./edit-config python.d/zscores.conf

Options

There are 2 sections:

  • Global variables
  • One or more JOBS that can define multiple different instances to monitor.

The following options can be defined globally: priority, penalty, autodetection_retry, update_every, but can also be defined per JOB to override the global values.

Additionally, the following collapsed table contains all the options that can be configured inside a JOB definition.

Every configuration JOB starts with a job_name value which will appear in the dashboard, unless a name parameter is specified.

Config options
NameDescriptionDefaultRequired
charts_regexwhat charts to pull data for - A regex like system\..*/ or system\..*/apps.cpu/apps.mem etc.system..*yes
train_secslength of time (in seconds) to base calculations off for mean and stddev.14400yes
offset_secsoffset (in seconds) preceding latest data to ignore when calculating mean and stddev.300yes
train_every_nrecalculate the mean and stddev every n steps of the collector.900yes
z_smooth_nsmooth the z score (to reduce sensitivity to spikes) by averaging it over last n values.15yes
z_clipcap absolute value of zscore (before smoothing) for better stability.10yes
z_absset z_abs: 'true' to make all zscores be absolute values only.trueyes
burn_inburn in period in which to initially calculate mean and stddev on every step.2yes
modemode can be to get a zscore 'per_dim' or 'per_chart'.per_chartyes
per_chart_aggper_chart_agg is how you aggregate from dimension to chart when mode='per_chart'.meanyes
update_everySets the default data collection frequency.5no
priorityControls the order of charts at the netdata dashboard.60000no
autodetection_retrySets the job re-check interval in seconds.0no
penaltyIndicates whether to apply penalty to update_every in case of failures.yesno

Examples

Default

Default configuration.

local:
name: 'local'
host: '127.0.0.1:19999'
charts_regex: 'system\..*'
charts_to_exclude: 'system.uptime'
train_secs: 14400
offset_secs: 300
train_every_n: 900
z_smooth_n: 15
z_clip: 10
z_abs: 'true'
burn_in: 2
mode: 'per_chart'
per_chart_agg: 'mean'

Troubleshooting

Debug Mode

To troubleshoot issues with the zscores collector, run the python.d.plugin with the debug option enabled. The output should give you clues as to why the collector isn't working.

  • Navigate to the plugins.d directory, usually at /usr/libexec/netdata/plugins.d/. If that's not the case on your system, open netdata.conf and look for the plugins setting under [directories].

    cd /usr/libexec/netdata/plugins.d/
  • Switch to the netdata user.

    sudo -u netdata -s
  • Run the python.d.plugin to debug the collector:

    ./python.d.plugin zscores debug trace

Getting Logs

If you're encountering problems with the zscores collector, follow these steps to retrieve logs and identify potential issues:

  • Run the command specific to your system (systemd, non-systemd, or Docker container).
  • Examine the output for any warnings or error messages that might indicate issues. These messages should provide clues about the root cause of the problem.

System with systemd

Use the following command to view logs generated since the last Netdata service restart:

journalctl _SYSTEMD_INVOCATION_ID="$(systemctl show --value --property=InvocationID netdata)" --namespace=netdata --grep zscores

System without systemd

Locate the collector log file, typically at /var/log/netdata/collector.log, and use grep to filter for collector's name:

grep zscores /var/log/netdata/collector.log

Note: This method shows logs from all restarts. Focus on the latest entries for troubleshooting current issues.

Docker Container

If your Netdata runs in a Docker container named "netdata" (replace if different), use this command:

docker logs netdata 2>&1 | grep zscores

Do you have any feedback for this page? If so, you can open a new issue on our netdata/learn repository.