python.d zscores icon

python.d zscores

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.

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.

Name Description Default Required
charts_regex what charts to pull data for - A regex like system\..*/ or system\..*/apps.cpu/apps.mem etc. system..* yes
train_secs length of time (in seconds) to base calculations off for mean and stddev. 14400 yes
offset_secs offset (in seconds) preceding latest data to ignore when calculating mean and stddev. 300 yes
train_every_n recalculate the mean and stddev every n steps of the collector. 900 yes
z_smooth_n smooth the z score (to reduce sensitivity to spikes) by averaging it over last n values. 15 yes
z_clip cap absolute value of zscore (before smoothing) for better stability. 10 yes
z_abs set z_abs: ‘true’ to make all zscores be absolute values only. true yes
burn_in burn in period in which to initially calculate mean and stddev on every step. 2 yes
mode mode can be to get a zscore ‘per_dim’ or ‘per_chart’. per_chart yes
per_chart_agg per_chart_agg is how you aggregate from dimension to chart when mode=‘per_chart’. mean yes
update_every Sets the default data collection frequency. 5 no
priority Controls the order of charts at the netdata dashboard. 60000 no
autodetection_retry Sets the job re-check interval in seconds. 0 no
penalty Indicates whether to apply penalty to update_every in case of failures. yes no

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'

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:

Metric Dimensions Unit
zscores.z a dimension per chart or dimension z
zscores.3stddev a dimension per chart or dimension count

Alerts

There are no alerts configured by default for this integration.

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

The observability platform companies need to succeed

Sign up for free

Want a personalised demo of Netdata for your use case?

Book a Demo