| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
As of v1.32.0, Netdata comes with some ML powered anomaly detection capabilities built into it and available to use out of the box, with zero configuration required (ML was enabled by default in v1.35.0-29-nightly in this PR, previously it required a one line config change).
🚧 Note: If you would like to get involved and help us with some feedback, email us at analytics-ml-team@netdata.cloud, comment on the beta launch post in the Netdata community, or come join us in the 🤖-ml-powered-monitoring channel of the Netdata discord.
Once ML is enabled, Netdata will begin training a model for each dimension. By default this model is a k-means clustering model trained on the most recent 4 hours of data. Rather than just using the most recent value of each raw metric, the model works on a preprocessed "feature vector" of recent smoothed and differenced values. This should enable the model to detect a wider range of potentially anomalous patterns in recent observations as opposed to just point anomalies like big spikes or drops. (This infographic shows some different types of anomalies.)
The sections below will introduce some of the main concepts:
Additional explanations and details can be found in the Glossary and Notes at the bottom of the page.
Once each model is trained, Netdata will begin producing an "anomaly score" at each time step for each dimension. This "anomaly score" is essentially a distance measure to the trained cluster centers of the model (by default each model has k=2, so two cluster centers are learned). More anomalous looking data should be more distant to those cluster centers. If this "anomaly score" is sufficiently large, this is a sign that the recent raw values of the dimension could potentially be anomalous. By default, "sufficiently large" means that the distance is in the 99th percentile or above of all distances observed during training or, put another way, it has to be further away than the furthest 1% of the data used during training. Once this threshold is passed, the "anomaly bit" corresponding to that dimension is set to 100 to flag it as anomalous, otherwise it would be left at 0 to signal normal data.
What this means is that in addition to the raw value of each metric, Netdata now also stores an "anomaly bit" that is either 100 (anomalous) or 0 (normal). Importantly, this is achieved without additional storage overhead due to how the anomaly bit has been implemented within the existing internal Netdata storage representation.
This "anomaly bit" is exposed via the anomaly-bit key that can be passed to the options param of the /api/v1/data REST API.
For example, here are some recent raw dimension values for system.ip on our london demo server:
https://london.my-netdata.io/api/v1/data?chart=system.ip
{
"labels": ["time", "received", "sent"],
"data":
[
[ 1638365672, 54.84098, -76.70201],
[ 1638365671, 124.4328, -309.7543],
[ 1638365670, 123.73152, -167.9056],
...
]
}
And if we add the &options=anomaly-bit params, we can see the "anomaly bit" value corresponding to each raw dimension value:
https://london.my-netdata.io/api/v1/data?chart=system.ip&options=anomaly-bit
{
"labels": ["time", "received", "sent"],
"data":
[
[ 1638365672, 0, 0],
[ 1638365671, 0, 0],
[ 1638365670, 0, 0],
...
]
}
In this example, the dimensions "received" and "sent" didn't show any abnormal behavior, so the anomaly bit is zero. Under normal circumstances, the anomaly bit will mostly be 0. However, there can be random fluctuations setting the anomaly to 100, although this very much depends on the nature of the dimension in question.
Once all models have been trained, we can think of the Netdata dashboard as essentially a big matrix or table of 0's and 100's. If we consider this "anomaly bit"-based representation of the state of the node, we can now think about how we might detect overall node level anomalies. The figure below illustrates the main ideas.
dimensions time d1 d2 d3 d4 d5 NAR 1 0 0 0 0 0 0% 2 0 0 0 0 100 20% 3 0 0 0 0 0 0% 4 0 100 0 0 0 20% 5 100 0 0 0 0 20% 6 0 100 100 0 100 60% 7 0 100 0 100 0 40% 8 0 0 0 0 100 20% 9 0 0 100 100 0 40% 10 0 0 0 0 0 0% DAR 10% 30% 20% 20% 30% 22% NAR_t1-t10 DAR = Dimension Anomaly Rate NAR = Node Anomaly Rate NAR_t1-t10 = Node Anomaly Rate over t1 to t10
To work out an "anomaly rate", we can just average a row or a column in any direction. For example, if we were to just average along a row then this would be the "node anomaly rate" (all dimensions) at time t. Likewise if we averaged a column then we would have the "dimension anomaly rate" for each dimension over the time window t=1-10. Extending this idea, we can work out an overall "anomaly rate" for the whole matrix or any subset of it we might be interested in.
An "anomaly detector" looks at all anomaly bits of a node. Netdata's anomaly detector produces an "anomaly event" when a the percentage of anomaly bits is high enough for a persistent amount of time. This anomaly event signals that there was sufficient evidence among all the anomaly bits that some strange behavior might have been detected in a more global sense across the node.
Essentially if the "Node Anomaly Rate" (NAR) passes a defined threshold and stays above that threshold for a persistent amount of time, a "Node Anomaly Event" will be triggered.
These anomaly events are currently exposed via /api/v1/anomaly_events
Note: Clicking the link below will likely return an empty list of []. This is the response when no anomaly events exist in the specified range. The example response below is illustrative of what the response would be when one or more anomaly events exist within the range of after to before.
https://london.my-netdata.io/api/v1/anomaly_events?after=1638365182000&before=1638365602000
If an event exists within the window, the result would be a list of start and end times.
[
[
1638367788,
1638367851
]
]
Information about each anomaly event can then be found at the /api/v1/anomaly_event_info endpoint (making sure to pass the after and before params):
Note: If you click the below url you will get a null since no such anomaly event exists as the response is just an illustrative example taken from a node that did have such an anomaly event.
https://london.my-netdata.io/api/v1/anomaly_event_info?after=1638367788&before=1638367851
[
[
0.66,
"netdata.response_time|max"
],
[
0.63,
"netdata.response_time|average"
],
[
0.54,
"netdata.requests|requests"
],
...
The query returns a list of dimension anomaly rates for all dimensions that were considered part of the detected anomaly event.
Note: We plan to build additional anomaly detection and exploration features into both Netdata Agent and Netdata Cloud. The current endpoints are still under active development to power the upcoming features.
If you are running a netdata version after v1.35.0-29-nightly then ML will be enabled by default.
To enable or disable anomaly detection:
Note: If you would like to learn more about configuring Netdata please see the configuration guide.
Below is a list of all the available configuration params and their default values.
[ml] # enabled = yes # maximum num samples to train = 14400 # minimum num samples to train = 3600 # train every = 3600 # dbengine anomaly rate every = 30 # num samples to diff = 1 # num samples to smooth = 3 # num samples to lag = 5 # random sampling ratio = 0.2 # maximum number of k-means iterations = 1000 # dimension anomaly score threshold = 0.99 # host anomaly rate threshold = 0.01000 # minimum window size = 30.00000 # maximum window size = 600.00000 # idle window size = 30.00000 # window minimum anomaly rate = 0.25000 # anomaly event min dimension rate threshold = 0.05000 # hosts to skip from training = !* # charts to skip from training = netdata.*
If you would like to run ML on a parent instead of at the edge, some configuration options are illustrated below.
This example assumes 3 child nodes streaming to 1 parent node and illustrates the main ways you might want to configure running ML for the children on the parent, running ML on the children themselves, or even a mix of approaches.
# parent will run ML for itself and child 1,2, it will skip running ML for child 0.
# child 0 will run its own ML at the edge.
# child 1 will run its own ML at the edge, even though parent will also run ML for it, a bit wasteful potentially to run ML in both places but is possible (Netdata Cloud will essentially average any overlapping models).
# child 2 will not run ML at the edge, it will be run in the parent only.
# parent-ml-enabled
# run ML on all hosts apart from child-ml-enabled
[ml]
enabled = yes
hosts to skip from training = child-0-ml-enabled
# child-0-ml-enabled
# run ML on child-0-ml-enabled
[ml]
enabled = yes
# child-1-ml-enabled
# run ML on child-1-ml-enabled
[ml]
enabled = yes
# child-2-ml-disabled
# do not run ML on child-2-ml-disabled
[ml]
enabled = no
Once enabled, the "Anomaly Detection" menu and charts will be available on the dashboard.
In terms of anomaly detection, the most interesting charts would be the anomaly_detection.dimensions and anomaly_detection.anomaly_rate ones, which hold the anomalous and anomaly_rate dimensions that show the overall number of dimensions considered anomalous at any time and the corresponding anomaly rate.
Below is an example of how these charts may look in the presence of an anomaly event.
Initially we see a jump in anomalous dimensions:
And a corresponding jump in the anomaly_rate:
After a short while the rolling node anomaly rate goes above_threshold, and once it stays above threshold for long enough a new_anomaly_event is created:
A feature vector is what the ML model is trained on and uses for prediction. The most simple feature vector would be just the latest raw dimension value itself [x]. By default Netdata will use a feature vector consisting of the 6 latest differences and smoothed values of the dimension so conceptually something like [avg3(diff1(x-5)), avg3(diff1(x-4)), avg3(diff1(x-3)), avg3(diff1(x-2)), avg3(diff1(x-1)), avg3(diff1(x))] which ends up being just 6 floating point numbers that try and represent the "shape" of recent data.
At prediction time the anomaly score is just the distance of the most recent feature vector to the trained cluster centers of the model, which are themselves just feature vectors, albeit supposedly the best most representative feature vectors that could be "learned" from the training data. So if the most recent feature vector is very far away in terms of euclidean distance it's more likely that the recent data it represents consists of some strange pattern not commonly found in the training data.
If the anomaly score is greater than a specified threshold then the most recent feature vector, and hence most recent raw data, is considered anomalous. Since storing the raw anomaly score would essentially double amount of storage space Netdata would need, we instead efficiently store just the anomaly bit in the existing internal Netdata data representation without any additional storage overhead.
An anomaly rate is really just an average over one or more anomaly bits. An anomaly rate can be calculated over time for one or more dimensions or at a point in time across multiple dimensions, or some combination of the two. Its just an average of some collection of anomaly bits.
The is essentially business logic that just tries to process a collection of anomaly bits to determine if there is enough active anomaly bits to merit investigation or declaration of a node level anomaly event.
Anomaly events are triggered by the anomaly detector and represent a window of time on the node with sufficiently elevated anomaly rates across all dimensions.
The anomaly rate of a specific dimension over some window of time.
The anomaly rate across all dimensions of a node.
| Back | FazBrowse Home | New Git URL |