Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ wanguard_announcements_finished 1
### Anomalies Collector
Metric | Type | Description | Labels
-------|------|-------------|-------
wanguard_anomalies_active | gauge | Active anomalies at the moment | anomaly, anomaly_id, bits, bits_s, duration, packets, pkts_s, prefix
wanguard_anomalies_active | gauge | Active anomalies at the moment | anomaly, anomaly_id, bits, bits_s, duration, latest_value, packets, pkts_s, prefix, sensor_interface_name
wanguard_anomalies_finished | gauge | Number of finished anomalies |

Example:
```
wanguard_anomalies_active{anomaly="ICMP pkts/s > 1",anomaly_id="1",bits="169576384000",bits_s="9014400",duration="60",packets="320020500",pkts_s="17500",prefix="10.10.10.10/32"} 1
wanguard_anomalies_active{anomaly="ICMP pkts/s > 1",anomaly_id="1",bits="169576384000",bits_s="9014400",duration="60",latest_value="17500",packets="320020500",pkts_s="17500",prefix="10.10.10.10/32",sensor_interface_name="Interface 1"} 1
wanguard_anomalies_finished 1
```

Expand Down
28 changes: 17 additions & 11 deletions collectors/anomalies_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,25 @@ type AnomaliesCount struct {
}

type Anomaly struct {
AnomalyId string `json:"anomaly_id"`
Prefix string
Anomaly string
Duration string
Pkts_s string `json:"pkts/s"`
Bits_s string `json:"bits/s"`
Packets string
Bits string
AnomalyId string `json:"anomaly_id"`
Prefix string
Anomaly string
Duration string
Pkts_s string `json:"pkts/s"`
Bits_s string `json:"bits/s"`
Packets string
Bits string
LatestValue string `json:"latest_value"`
Sensor struct {
SensorInterfaceName string `json:"sensor_interface_name"`
} `json:"sensor"`
}

func NewAnomaliesCollector(wgclient *wgc.Client) *AnomaliesCollector {
prefix := "wanguard_anomalies_"
return &AnomaliesCollector{
wgClient: wgclient,
AnomalyActive: prometheus.NewDesc(prefix+"active", "Active anomalies at the moment", []string{"prefix", "anomaly", "anomaly_id", "duration", "pkts_s", "packets", "bits_s", "bits"}, nil),
AnomalyActive: prometheus.NewDesc(prefix+"active", "Active anomalies at the moment", []string{"prefix", "anomaly", "anomaly_id", "duration", "pkts_s", "packets", "bits_s", "bits", "latest_value", "sensor_interface_name"}, nil),
AnomaliesFinished: prometheus.NewDesc(prefix+"finished", "Number of finished anomalies", nil, nil),
}
}
Expand All @@ -51,7 +55,7 @@ func (c *AnomaliesCollector) Collect(ch chan<- prometheus.Metric) {
func collectActiveAnomalies(desc *prometheus.Desc, wgclient *wgc.Client, ch chan<- prometheus.Metric) {
var anomalies []Anomaly

err := wgclient.GetParsed("anomalies?status=Active&fields=anomaly_id,anomaly,prefix,duration,pkts/s,packets,bits/s,bits", &anomalies)
err := wgclient.GetParsed("anomalies?status=Active&fields=anomaly_id,anomaly,prefix,duration,pkts/s,packets,bits/s,bits,latest_value,sensor", &anomalies)
if err != nil {
return
}
Expand All @@ -65,7 +69,9 @@ func collectActiveAnomalies(desc *prometheus.Desc, wgclient *wgc.Client, ch chan
anomaly.Pkts_s,
anomaly.Packets,
anomaly.Bits_s,
anomaly.Bits)
anomaly.Bits,
anomaly.LatestValue,
anomaly.Sensor.SensorInterfaceName)
}
}

Expand Down
2 changes: 1 addition & 1 deletion collectors/anomalies_collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func anomaliesExpectedMetrics() string {
return `
# HELP wanguard_anomalies_active Active anomalies at the moment
# TYPE wanguard_anomalies_active gauge
wanguard_anomalies_active{anomaly="ICMP pkts/s > 1",anomaly_id="1",bits="169576384000",bits_s="9014400",duration="60",packets="320020500",pkts_s="17500",prefix="10.10.10.10/32"} 1
wanguard_anomalies_active{anomaly="ICMP pkts/s > 1",anomaly_id="1",bits="169576384000",bits_s="9014400",duration="60",latest_value="130961807",packets="320020500",pkts_s="17500",prefix="10.10.10.10/32",sensor_interface_name="sFlows Filter Cluster"} 1

# HELP wanguard_anomalies_finished Number of finished anomalies
# TYPE wanguard_anomalies_finished gauge
Expand Down
6 changes: 6 additions & 0 deletions collectors/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,12 @@ func anomaliesPayload() string {
"bits/s": "9014400",
"packets": "320020500",
"bits": "169576384000",
"latest_value": "130961807",
"sensor": {
"sensor_interface_name": "sFlows Filter Cluster",
"sensor_interface_id": "4-1-0",
"href": "/wanguard-api/v1/sensor_clusters/1"
},
"href": "/wanguard-api/v1/anomalies/1"
}
]`
Expand Down
2 changes: 1 addition & 1 deletion wanguard_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

const (
version string = "1.6"
version string = "1.7"
)

type collectorsList struct {
Expand Down
Loading