datadog-agent icon indicating copy to clipboard operation
datadog-agent copied to clipboard

[CWS-2599] on-demand probes

Open paulcacheux opened this issue 1 year ago • 3 comments
trafficstars

What does this PR do?

This PR introduces the notion of on-demand probes, events that are not based on hard coded eBPF hooks, but that rely on user specified hooks.

This PR adds a new section in the policy:

on_demand:
  - name: chdir
    syscall: true
    args:
      n: 1
      type: null-terminated-string
rules: ...

that allows the specification of new hook points. Those hook points represent the kernel function to hook (or a given syscall entrypoint), the position and expected type of the arguments we are interested in. We then allow the creation of rules using those new events.

rules:
  expression: ondemand.name == “chdir” && ondemand.arg1.str == "/sys/fs/cgroup" && process.file.name =~ "runc.*"

The process and container process is filled as usual.

To protect the agent against those new events, we currently force disable the on demand sub-system if more than a fixed amount of events are unmarshalled from the ring buffer per second. We keep the regular probes and rules, we just disable on demand probes.

This feature is currently disabled by default.

The serialization part (what is included in the json payload sent to the backend) is not included in this PR and will come in a follow up.

Motivation

Additional Notes

Possible Drawbacks / Trade-offs

Describe how to test/QA your changes

paulcacheux avatar Apr 09 '24 10:04 paulcacheux

Regression Detector

Regression Detector Results

Run ID: db52770e-aabf-4ef8-80a8-bf3519613549 Metrics dashboard Target profiles

Baseline: 620b9d1799ed80287794b8202b3fbad0b5be818e Comparison: 50806836c052629b98f6d059fe2073dbe68581ee

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

No significant changes in experiment optimization goals

Confidence level: 90.00% Effect size tolerance: |Δ mean %| ≥ 5.00%

There were no significant changes in experiment optimization goals at this confidence level and effect size tolerance.

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI links
tcp_syslog_to_blackhole ingress throughput +0.44 [-12.35, +13.24] Logs
uds_dogstatsd_to_api_cpu % cpu utilization +0.32 [-0.58, +1.21] Logs
file_tree memory utilization +0.23 [+0.19, +0.27] Logs
tcp_dd_logs_filter_exclude ingress throughput +0.00 [-0.01, +0.01] Logs
uds_dogstatsd_to_api ingress throughput +0.00 [-0.00, +0.00] Logs
otel_to_otel_logs ingress throughput -0.18 [-1.00, +0.63] Logs
idle memory utilization -0.31 [-0.34, -0.28] Logs
basic_py_check % cpu utilization -0.70 [-3.31, +1.92] Logs
pycheck_1000_100byte_tags % cpu utilization -0.99 [-5.70, +3.72] Logs

Explanation

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

pr-commenter[bot] avatar Apr 09 '24 11:04 pr-commenter[bot]

Test changes on VM

Use this command from test-infra-definitions to manually test this PR changes on a VM:

inv create-vm --pipeline-id=38361682 --os-family=ubuntu

Note: This applies to commit c715bcb4

pr-commenter[bot] avatar Apr 11 '24 08:04 pr-commenter[bot]

Codecov Report

Attention: Patch coverage is 21.89055% with 157 lines in your changes missing coverage. Please review.

Project coverage is 24.47%. Comparing base (789363c) to head (766fc77). Report is 2 commits behind head on main.

:exclamation: Current head 766fc77 differs from pull request most recent head 0bd9a8d

Please upload reports for the commit 0bd9a8d to get more accurate results.

Files Patch % Lines
pkg/security/probe/probe_ebpf.go 0.00% 77 Missing :warning:
pkg/security/secl/model/accessors_unix.go 44.26% 31 Missing and 3 partials :warning:
pkg/security/secl/model/field_accessors_unix.go 0.00% 15 Missing :warning:
pkg/security/probe/field_handlers_ebpf.go 0.00% 10 Missing :warning:
pkg/security/secl/model/unmarshallers_linux.go 0.00% 7 Missing :warning:
pkg/security/probe/field_handlers_ebpfless.go 0.00% 6 Missing :warning:
pkg/security/secl/model/field_handlers_unix.go 63.63% 4 Missing :warning:
pkg/security/secl/model/events.go 0.00% 2 Missing :warning:
pkg/security/secl/rules/ruleset.go 0.00% 2 Missing :warning:
Additional details and impacted files
@@             Coverage Diff             @@
##             main   #24516       +/-   ##
===========================================
- Coverage   36.12%   24.47%   -11.66%     
===========================================
  Files        3342      279     -3063     
  Lines      361632    88886   -272746     
===========================================
- Hits       130647    21753   -108894     
+ Misses     220816    63754   -157062     
+ Partials    10169     3379     -6790     
Flag Coverage Δ
amzn_aarch64 25.86% <21.89%> (-11.02%) :arrow_down:
centos_x86_64 25.86% <21.89%> (-10.94%) :arrow_down:
ubuntu_aarch64 25.86% <21.89%> (-11.03%) :arrow_down:
ubuntu_x86_64 25.86% <21.89%> (-11.02%) :arrow_down:
windows_amd64 21.71% <0.00%> (-17.21%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jun 03 '24 11:06 codecov[bot]

/merge

paulcacheux avatar Jul 04 '24 09:07 paulcacheux

:steam_locomotive: MergeQueue: waiting for PR to be ready

This merge request is not mergeable yet, because of pending checks/missing approvals. It will be added to the queue as soon as checks pass and/or get approvals. Note: if you pushed new commits since the last approval, you may need additional approval. You can remove it from the waiting list with /remove command.

Use /merge -c to cancel this operation!

dd-devflow[bot] avatar Jul 04 '24 09:07 dd-devflow[bot]

:steam_locomotive: MergeQueue: pull request added to the queue

The median merge time in main is 25m.

Use /merge -c to cancel this operation!

dd-devflow[bot] avatar Jul 04 '24 10:07 dd-devflow[bot]