Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sourceHost and destHost to flow metrics. #1824

Draft
wants to merge 1 commit into
base: 1.8
Choose a base branch
from
Draft
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
14 changes: 7 additions & 7 deletions pkg/flow/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,45 +75,45 @@ func (fc *FlowCollector) NewMetrics(reg prometheus.Registerer) *collectorMetrics
Name: "flows_total",
Help: "Total Flows",
},
[]string{"sourceSite", "destSite", "address", "protocol", "direction", "sourceProcess", "destProcess"}),
[]string{"sourceSite", "destSite", "address", "protocol", "direction", "sourceProcess", "destProcess", "sourceHost", "destHost"}),
octets: prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "octets_total",
Help: "Total Octets",
},
[]string{"sourceSite", "destSite", "address", "protocol", "direction", "sourceProcess", "destProcess"}),
[]string{"sourceSite", "destSite", "address", "protocol", "direction", "sourceProcess", "destProcess", "sourceHost", "destHost"}),
httpReqsMethod: prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "http_requests_method_total",
Help: "How many HTTP requests processed, partitioned by method",
},
[]string{"sourceSite", "destSite", "address", "protocol", "direction", "sourceProcess", "destProcess", "method"}),
[]string{"sourceSite", "destSite", "address", "protocol", "direction", "sourceProcess", "destProcess", "method", "sourceHost", "destHost"}),
httpReqsResult: prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "http_requests_result_total",
Help: "How many HTTP requests processed, partitioned by result code",
},
[]string{"sourceSite", "destSite", "address", "protocol", "direction", "sourceProcess", "destProcess", "code"}),
[]string{"sourceSite", "destSite", "address", "protocol", "direction", "sourceProcess", "destProcess", "code", "sourceHost", "destHost"}),
activeFlows: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "active_flows",
Help: "Number of flows that are currently active, partitioned by source and destination",
},
[]string{"sourceSite", "destSite", "address", "protocol", "direction", "sourceProcess", "destProcess"}),
[]string{"sourceSite", "destSite", "address", "protocol", "direction", "sourceProcess", "destProcess", "sourceHost", "destHost"}),
lastAccessed: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "address_last_time_seconds",
Help: "The last time the address was served",
},
[]string{"sourceSite", "destSite", "address", "protocol", "direction", "sourceProcess", "destProcess"}),
[]string{"sourceSite", "destSite", "address", "protocol", "direction", "sourceProcess", "destProcess", "sourceHost", "destHost"}),
flowLatency: prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Name: "flow_latency_microseconds",
Help: "The measure latency for the direction of flow",
// 1ms, 2 ms, 5ms, 10ms, 100ms, 1s, 10s
Buckets: []float64{1000, 2000, 5000, 10000, 100000, 1000000, 10000000},
},
[]string{"sourceSite", "destSite", "address", "protocol", "direction", "sourceProcess", "destProcess"}),
[]string{"sourceSite", "destSite", "address", "protocol", "direction", "sourceProcess", "destProcess", "sourceHost", "destHost"}),
activeReconcile: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "active_reconciles",
Expand Down
10 changes: 10 additions & 0 deletions pkg/flow/flow_mem_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,11 +421,15 @@ func (fc *FlowCollector) linkFlowPair(flow *FlowRecord) (*FlowPairRecord, bool)
fwdLabels["destSite"] = destSiteName + "@_@" + destSiteId
fwdLabels["sourceProcess"] = *sourceFlow.ProcessName
fwdLabels["destProcess"] = *destFlow.ProcessName
fwdLabels["sourceHost"] = *sourceFlow.SourceHost
fwdLabels["destHost"] = *destFlow.SourceHost
delete(fwdLabels, "process")
revLabels["sourceSite"] = destSiteName + "@_@" + destSiteId
revLabels["destSite"] = sourceSiteName + "@_@" + sourceSiteId
revLabels["sourceProcess"] = *destFlow.ProcessName
revLabels["destProcess"] = *sourceFlow.ProcessName
revLabels["sourceHost"] = *destFlow.SourceHost
fwdLabels["destHost"] = *sourceFlow.SourceHost
delete(revLabels, "process")

fp := &FlowPairRecord{
Expand Down Expand Up @@ -2262,6 +2266,12 @@ func (fc *FlowCollector) setupFlowMetrics(va *VanAddressRecord, flow *FlowRecord
if key.sourceProcess, ok = metricLabel["sourceProcess"]; !ok {
return fmt.Errorf("Metric label missing source process key")
}
if key.sourceHost, ok = metricLabel["sourceHost"]; !ok {
return fmt.Errorf("Metric label missing source host key")
}
if key.sourceHost, ok = metricLabel["destHost"]; !ok {
return fmt.Errorf("Metric label missing dest host key")
}
if key.destSite, ok = metricLabel["destSite"]; !ok {
return fmt.Errorf("Metric label missing dest site key")
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/flow/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ type LogEventRecord struct {
type metricKey struct {
sourceSite string
sourceProcess string
sourceHost string
destHost string
destSite string
destProcess string
}
Expand Down