diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d521fc36..d4beb42d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,8 +13,7 @@ - ### Bug fixes -- -- +- Fix retransmission count is not consistent with the real value on Linux 4.7 or higher([#450](https://github.com/KindlingProject/kindling/pull/450)) - Fix the bug that the agent panics when it receives DeletedFinalStateUnknown by watching K8s metadata. ([#456](https://github.com/KindlingProject/kindling/pull/456)) - diff --git a/collector/internal/application/application.go b/collector/internal/application/application.go index 5ff76dc51..e481c6f3a 100644 --- a/collector/internal/application/application.go +++ b/collector/internal/application/application.go @@ -128,7 +128,7 @@ func (a *Application) buildPipeline() error { aggregateProcessorForTcp := aggregateProcessorFactory.NewFunc(aggregateProcessorFactory.Config, a.telemetry.GetTelemetryTools(aggregateprocessor.Type), otelExporter) k8sMetadataProcessor2 := k8sProcessorFactory.NewFunc(k8sProcessorFactory.Config, a.telemetry.GetTelemetryTools(aggregateprocessor.Type), aggregateProcessorForTcp) tcpAnalyzerFactory := a.componentsFactory.Analyzers[tcpmetricanalyzer.TcpMetric.String()] - tcpAnalyzer := tcpAnalyzerFactory.NewFunc(tcpAnalyzerFactory.Config, a.telemetry.GetTelemetryTools(tcpconnectanalyzer.Type.String()), []consumer.Consumer{k8sMetadataProcessor2}) + tcpAnalyzer := tcpAnalyzerFactory.NewFunc(tcpAnalyzerFactory.Config, a.telemetry.GetTelemetryTools(tcpmetricanalyzer.TcpMetric.String()), []consumer.Consumer{k8sMetadataProcessor2}) tcpConnectAnalyzerFactory := a.componentsFactory.Analyzers[tcpconnectanalyzer.Type.String()] tcpConnectAnalyzer := tcpConnectAnalyzerFactory.NewFunc(tcpConnectAnalyzerFactory.Config, a.telemetry.GetTelemetryTools(tcpconnectanalyzer.Type.String()), []consumer.Consumer{k8sMetadataProcessor}) diff --git a/collector/pkg/component/analyzer/tcpmetricanalyzer/tcp_analyzer.go b/collector/pkg/component/analyzer/tcpmetricanalyzer/tcp_analyzer.go index 5df86b70d..d8dbd70fc 100644 --- a/collector/pkg/component/analyzer/tcpmetricanalyzer/tcp_analyzer.go +++ b/collector/pkg/component/analyzer/tcpmetricanalyzer/tcp_analyzer.go @@ -79,6 +79,9 @@ func (a *TcpMetricAnalyzer) ConsumeEvent(event *model.KindlingEvent) error { if dataGroup == nil { return nil } + if ce := a.telemetry.Logger.Check(zapcore.DebugLevel, ""); ce != nil { + a.telemetry.Logger.Debug("TcpMetricAnalyzer To NextProcess:\n" + dataGroup.String()) + } var retError error for _, nextConsumer := range a.consumers { err := nextConsumer.Consume(dataGroup) @@ -110,7 +113,14 @@ func (a *TcpMetricAnalyzer) generateRetransmit(event *model.KindlingEvent) (*mod if err != nil { return nil, err } - metric := model.NewIntMetric(constnames.TcpRetransmitMetricName, 1) + + var segs = int64(1) + p_segs := event.GetUserAttribute("segs") + if p_segs != nil && p_segs.GetValueType() == model.ValueType_INT32 { + segs = p_segs.GetIntValue() + } + + metric := model.NewIntMetric(constnames.TcpRetransmitMetricName, segs) return model.NewDataGroup(constnames.TcpRetransmitMetricGroupName, labels, event.Timestamp, metric), nil } diff --git a/docs/prometheus_metrics.md b/docs/prometheus_metrics.md index 6fde6e201..57e3aa05f 100644 --- a/docs/prometheus_metrics.md +++ b/docs/prometheus_metrics.md @@ -206,7 +206,7 @@ We made some rules for considering whether a request is abnormal. For the abnorm | --- | --- | --- | | `kindling_tcp_srtt_microseconds` | Gauge | Smoothed round trip time of the TCP socket | | `kindling_tcp_packet_loss_total` | Counter | Total number of dropped packets | -| `kindling_tcp_retransmit_total` | Counter | Total times of retransmitting happens (not packets count) | +| `kindling_tcp_retransmit_total` | Counter | Total number of resending segments | ### Labels List | **Label Name** | **Example** | **Notes** | @@ -230,6 +230,9 @@ We made some rules for considering whether a request is abnormal. For the abnorm | `dst_ip` | 10.1.11.24 | Pod's IP by default. If the destination is not a pod in Kubernetes, this is the IP address of an external entity | | `dst_port` | 80 | The listening port of the destination container, if applicable | +### Notes +**Note 1**: Before Kindling v0.7.0, the `kindling_tcp_retransmit_total` was used to count how many retransmit events happened, which is less than total number of resending segments since Linux may resend mutiple segments during one retransmit event. + ## TCP Socket Connects Metrics ### Metrics List diff --git a/probe/cmake/modules/agent-libs.cmake b/probe/cmake/modules/agent-libs.cmake index 4721aff6e..0e909a80e 100644 --- a/probe/cmake/modules/agent-libs.cmake +++ b/probe/cmake/modules/agent-libs.cmake @@ -31,8 +31,8 @@ else() # default below In case you want to test against another falcosecurity/libs version just pass the variable - ie., `cmake # -DAGENT_LIBS_VERSION=dev ..` if(NOT AGENT_LIBS_VERSION) - set(AGENT_LIBS_VERSION "5afa674d0c7e2758c2d49e04dfebcd05b46bfce4") - set(AGENT_LIBS_CHECKSUM "SHA256=c0307898a81160d2edc38eeb97485df35f67ceed3e868a99afa4f6fee6caf515") + set(AGENT_LIBS_VERSION "568e3cd8cd246a416d2354707ff14df20f4541a1") + set(AGENT_LIBS_CHECKSUM "SHA256=cd22256791a94d918fa842c5e7c39c58f0f2c403690ab2a0f4472b2a78b94cce") endif() # cd /path/to/build && cmake /path/to/source diff --git a/probe/src/cgo/kindling.cpp b/probe/src/cgo/kindling.cpp index 3f7aee5f5..dbf6ef9d4 100644 --- a/probe/src/cgo/kindling.cpp +++ b/probe/src/cgo/kindling.cpp @@ -345,7 +345,6 @@ int getEvent(void** pp_kindling_event) { break; } case PPME_TCP_DROP_E: - case PPME_TCP_RETRANCESMIT_SKB_E: case PPME_TCP_SET_STATE_E: { auto pTuple = ev->get_param_value_raw("tuple"); userAttNumber = setTuple(p_kindling_event, pTuple, userAttNumber); @@ -375,6 +374,21 @@ int getEvent(void** pp_kindling_event) { userAttNumber = setTuple(p_kindling_event, pTuple, userAttNumber); break; } + case PPME_TCP_RETRANCESMIT_SKB_E:{ + auto pTuple = ev->get_param_value_raw("tuple"); + userAttNumber = setTuple(p_kindling_event, pTuple, userAttNumber); + + auto segs = ev->get_param_value_raw("segs"); + if (segs != NULL){ + strcpy(p_kindling_event->userAttributes[userAttNumber].key, "segs"); + memcpy(p_kindling_event->userAttributes[userAttNumber].value, segs->m_val, + segs->m_len); + p_kindling_event->userAttributes[userAttNumber].len = segs->m_len; + p_kindling_event->userAttributes[userAttNumber].valueType = INT32; + userAttNumber++; + } + break; + } default: { uint16_t paramsNumber = ev->get_num_params(); // Since current data structure specifies the maximum count of `user_attributes`