Skip to content

Commit 9ef41e7

Browse files
authored
Merge pull request #1368 from hzxuzhonghu/fix-accesslog-regression
Skip output accesslog on connection establishment
2 parents 5b4fada + c1c00fb commit 9ef41e7

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

docs/proposal/tcp_long_connection_metrics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ documentation such as release notes or a development roadmap.
3232
A good summary is probably at least a paragraph in length.
3333
-->
3434

35-
Currently kmesh provides access logs during termination and establisment of a TCP connection with more detailed information about the connection, such as bytes sent, received, packet lost, rtt and retransmits.
35+
Currently kmesh provides access logs after close of a TCP connection with more detailed information about the connection, such as bytes sent, received, packet lost, rtt and retransmits.
3636

3737
Kmesh also provides workload and service specific metrics such as bytes sent and received, lost packets, minimum rtt, total connection opened and closed by a pod, These metrics are only updated after a connection is closed. In this proposal we are aiming to update these metrics periodically.
3838

pkg/controller/telemetry/accesslog.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ func (l *logInfo) withDestinationService(service *workloadapi.Service) *logInfo
7878
}
7979

8080
func OutputAccesslog(data requestMetric, conn_metrics connMetric, accesslog logInfo) {
81+
// Skip output access log on connection establishment
82+
if data.state == TCP_ESTABLISHED && data.duration < LONG_CONN_METRIC_THRESHOLD {
83+
return
84+
}
8185
logStr := buildAccesslog(data, conn_metrics, accesslog)
8286
fmt.Println("accesslog:", logStr)
8387
}

pkg/controller/telemetry/metric.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const (
4848

4949
DEFAULT_UNKNOWN = "-"
5050

51-
LONG_CONN_METRIC_THRESHOLD = uint64(30 * time.Second)
51+
LONG_CONN_METRIC_THRESHOLD = uint64(5 * time.Second)
5252
)
5353

5454
var osStartTime time.Time
@@ -512,7 +512,7 @@ func (m *MetricController) Run(ctx context.Context, mapOfTcpInfo *ebpf.Map) {
512512
connectionLabels = m.buildConnectionMetric(&data)
513513
}
514514
if m.EnableAccesslog.Load() {
515-
// accesslogs at start of connection, at interval of 5 sec during connection lifecycle and at close of connection
515+
// accesslogs at interval of 5 sec during connection lifecycle and at close of connection
516516
OutputAccesslog(data, tcpConns[data.conSrcDstInfo], accesslog)
517517
}
518518

0 commit comments

Comments
 (0)