kubectl apply -f manifest.yml
# From the root of the anomaly-detection directory.
docker build ../.. -f Dockerfile -t ghcr.io/azure-samples/explore-iot-operations/anomaly-detection:latest
# Or if running from the root of the explore-iot-operations repository.
# docker build . -f ./samples/anomaly-detection/Dockerfile -t ghcr.io/azure-samples/explore-iot-operations/anomaly-detection:latest
# Push or load your newly built image into your cluster, depending on the k8s setup.
# docker push ghcr.io/azure-samples/explore-iot-operations/anomaly-detection:latest # Using AKS + Connected ACR
# minikube load ghcr.io/azure-samples/explore-iot-operations/anomaly-detection:latest # Using minikube
# docker save ghcr.io/azure-samples/explore-iot-operations/anomaly-detection:latest | k3s ctr images import - # Using K3s
kubectl apply -f manifest.yml
logger: # Logger settings
level: 0
server: # Server settings
route: /anomaly
port: 3333
algorithm: # Algorithm settings
temperature: # Temperature related algorithm settings
lambda: 0.25 # Lambda value for temperature anomaly detection
lFactor: 3 # L factor for temperature anomaly detection
controlT: 90 # Control limit T constant
controlS: 20 # Control limit S constant
controlN: 10 # Control limit N constant
vibration: # Vibration related algorithm settings
lambda: 0.25
lFactor: 3
type: dynamic # Use dynamic algorithm, no requirement for control limit T, S, or N values
humidity: # Humidity related algorithm settings
lambda: 0.25
lFactor: 3
controlT: 80
controlS: 20
controlN: 10
Important Note: The anomaly detection server is a stateful server, meaning that it will keep track of the EWMA values and control limits over time. If the pod is destroyed and then reinitialized, the state will be lost and the EWMA will be recalculated starting from the initial value of 0. All algorithms in the anomaly detector use a recursive algorithm, where the ewma value and control limits calculated at observation ./lib/ewma
package of this directory.
// POST localhost:3333/anomaly
{
"payload": {
"Payload": {
"assetID": "Tac_S1",
"asset_id": "Tac_S1",
"asset_name": "Tacoma_Slicer_Tacoma_Slicer__asset_0",
"humidity": 82.34915832237789,
"machine_status": 1,
"maintenanceStatus": "Upcoming",
"name": "Contoso",
"operating_time": 5999,
"serialNumber": "SN010",
"site": "Tacoma",
"source_timestamp": "2023-11-02T20:27:09.143Z",
"temperature": 93.56069711661576,
"vibration": 50.98858025013501
}
}
}
// Status 200 OK
{
"payload": {
"payload": {
"asset_id": "Tac_S1",
"asset_name": "Tacoma_Slicer_Tacoma_Slicer__asset_0",
"maintainence_status": "",
"name": "Contoso",
"serialNumber": "SN010",
"site": "Tacoma",
"source_timestamp": "2023-11-02T20:27:09.143Z",
"operating_time": 5999,
"machineStatus": 0,
"humidity": 82.34915832237789,
"temperature": 93.56069711661576,
"vibration": 50.98858025013501,
"humidityAnomalyFactor": 77.71178778387797,
"humidityAnomaly": false,
"temperatureAnomalyFactor": 88.2919654233107,
"temperatureAnomaly": false,
"vibrationAnomalyFactor": 48.11723408620391,
"vibrationAnomaly": false
}
}
}
// Status 200 OK
{
"payload": {
"payload": {
"asset_id": "Tac_S1",
"asset_name": "Tacoma_Slicer_Tacoma_Slicer__asset_0",
"maintainence_status": "",
"name": "Contoso",
"serialNumber": "SN010",
"site": "Tacoma",
"source_timestamp": "2023-11-02T20:27:09.143Z",
"operating_time": 5999,
"machineStatus": 0,
"humidity": 1082.349158322378, // Humidity has an anomaly.
"temperature": 93.56069711661576,
"vibration": 50.98858025013501,
"humidityAnomalyFactor": 328.87113041850296, // Anomaly factor rose sharply.
"humidityAnomaly": true, // Humidity anomaly was detected.
"temperatureAnomalyFactor": 89.60914834663697,
"temperatureAnomaly": false,
"vibrationAnomalyFactor": 48.83507062718669,
"vibrationAnomaly": false
}
}
}
Use the type: dynamic
property in the configuration to choose an algorithm from the following.
Symbol | Meaning |
---|---|
Control Limit Value | |
Upper Control Limit | |
Lower Control Limit | |
L Factor | |
Lambda Factor |
|
Iteration or Count | |
Constant Estimation of Sample Mean | |
Constant Estimation of Sample Std Dev | |
Constant Estimation of Rational Subgroup Size |
Symbol | Meaning |
---|---|
Control Limit Value | |
Upper Control Limit | |
Lower Control Limit | |
L Factor | |
Lambda Factor |
|
Iteration or Count | |
Sample Mean from Iteration |
|
Sample Std Dev from Iteration |
The following formulas are shared between the two algorithms.
EWMA Value Formula
Anomaly Condition
Symbol | Meaning |
---|---|
Upper Control Limit | |
Lower Control Limit | |
Lambda Factor |
|
Iteration or Count | |
Observed Value from Iteration |
|
EWMA Value for Iteration |
|
Anomaly Occurance, |