Skip to content

Commit

Permalink
Fix connection_rate_per_dest_subnet metric to use new conntrack
Browse files Browse the repository at this point in the history
  • Loading branch information
ronensc committed Sep 1, 2022
1 parent 8a56d8f commit 1c0697b
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 19 deletions.
2 changes: 1 addition & 1 deletion contrib/dashboards/dashboard_details.json
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@
"steppedLine": false,
"targets": [
{
"expr": "topk(10,rate(flp_connections_per_destination_subnet[1m]))",
"expr": "topk(10,rate(flp_connections_per_destination_subnet{_RecordType=\"newConnection\"}[1m]))",
"format": "time_series",
"intervalFactor": 2,
"legendFormat": "",
Expand Down
2 changes: 1 addition & 1 deletion contrib/dashboards/jsonnet/dashboard_details.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ dashboard.new(
)
.addTarget(
prometheus.target(
expr='topk(10,rate(flp_connections_per_destination_subnet[1m]))',
expr='topk(10,rate(flp_connections_per_destination_subnet{_RecordType="newConnection"}[1m]))',
)
), gridPos={
x: 0,
Expand Down
11 changes: 4 additions & 7 deletions contrib/kubernetes/flowlogs-pipeline.conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ parameters:
output: srcSubnet
type: add_subnet
parameters: /16
- input: '{{.srcIP}},{{.srcPort}},{{.dstIP}},{{.dstPort}},{{.proto}}'
output: isNewFlow
type: conn_tracking
parameters: "1"
- input: dstIP
output: dstSubnet
type: add_subnet
Expand All @@ -100,10 +96,12 @@ parameters:
fields:
- srcIP
- srcPort
- srcSubnet
- name: dst
fields:
- dstIP
- dstPort
- dstSubnet
- name: protocol
fields:
- proto
Expand Down Expand Up @@ -181,7 +179,6 @@ parameters:
- dstSubnet
- _RecordType
operation: count
recordKey: isNewFlow
- name: src_connection_count
by:
- srcSubnet
Expand Down Expand Up @@ -324,8 +321,8 @@ parameters:
value: dest_connection_subnet_count
valueKey: recent_count
labels:
- by
- aggregate
- _RecordType
- dstSubnet
buckets: []
- name: connections_per_source_subnet
type: counter
Expand Down
2 changes: 1 addition & 1 deletion docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ and the transformation to generate the exported metric.
| **Details** | Counts the number of connections per subnet with network prefix length /16 |
| **Usage** | Evaluate network connections per subnet |
| **Tags** | rate, subnet |
| **Operation** | aggregate by `dstSubnet, _RecordType` and `count` field `isNewFlow` |
| **Operation** | aggregate by `dstSubnet, _RecordType` and `count` |
| **Exposed as** | `flp_connections_per_destination_subnet` of type `counter` |
| **Visualized as** | "Connections rate per destinationIP /16 subnets" on dashboard `details` |
|||
Expand Down
2 changes: 2 additions & 0 deletions network_definitions/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ extract:
fields:
- srcIP
- srcPort
- srcSubnet
- name: dst
fields:
- dstIP
- dstPort
- dstSubnet
- name: protocol
fields:
- proto
Expand Down
12 changes: 3 additions & 9 deletions network_definitions/connection_rate_per_dest_subnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ tags:
- subnet
transform:
rules:
# TODO: use new connection tracking module instead of the following
- input: "{{.srcIP}},{{.srcPort}},{{.dstIP}},{{.dstPort}},{{.proto}}"
output: isNewFlow
type: conn_tracking
parameters: "1"
- input: dstIP
output: dstSubnet
type: add_subnet
Expand All @@ -27,7 +22,6 @@ extract:
- dstSubnet
- _RecordType
operation: count
recordKey: isNewFlow
encode:
type: prom
prom:
Expand All @@ -37,12 +31,12 @@ encode:
filter: {key: name, value: dest_connection_subnet_count}
valueKey: recent_count
labels:
- by
- aggregate
- _RecordType
- dstSubnet
visualization:
type: grafana
grafana:
- expr: 'topk(10,rate(flp_connections_per_destination_subnet[1m]))'
- expr: 'topk(10,rate(flp_connections_per_destination_subnet{_RecordType="newConnection"}[1m]))'
type: graphPanel
dashboard: details
title:
Expand Down

0 comments on commit 1c0697b

Please sign in to comment.