- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- Administrator's Guide
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
You can configure CoTerm to take specific actions when it intercepts certain commands by adding lints and rules to your .ddcoterm/config.yaml
file under process_config
.
These lints and rules are written in Lua. For syntax and further details, see Lua’s documentation.
process_config:
commands:
- command: "kubectl"
lints:
- |
if has_arg("scale") and flags.context == nil then
return string.format("No kubectl context specified (effective context: '%s'). It is recommended to always explicitly specify the context when running `kubectl scale`.", k8s_context)
end
Each item under lints
is a Lua snippet that can return a string. Lints are evaluated in order. If a lint returns a string, that string is shown to the user as a warning prompt:
The user then has the option to continue or abort.
process_config:
commands:
- command: "kubectl"
rules:
# Record and require approval for all executions of `kubectl scale` in a production context
- rule: |
local k8s_context = flags.context or k8s_current_context or "unknown"
local matches = has_arg("scale") and k8s_context:match("prod")
local user_message = "Proceed with caution. This command may disrupt your Kubernetes cluster setup."
local approver_message = "Ensure that the user has documented a rollback plan before approving."
return matches, user_message, approver_message
actions: ["record", "logs", "process_info", "approval"]
# Record all other executions of kubectl scale, but don't require approval and don't bother with messages for users+approvers
- rule: has_arg("scale")
actions: ["record", "logs", "process_info"]
# For all other kubectl commands, just run the command with ~zero overhead; no recording, no requiring approval
- rule: true
actions: []
Rules are more powerful than lints. For each item under rules
, set rule
, a Lua snippet that returns 1-3 values; and actions
, a list of actions for CoTerm to take.
Each rule
returns 1-3 values: boolean, [string], [string]
.
true
.true
and the corresponding actions
field contains approval
, this string is displayed in the approval request in Datadog.CoTerm can take the following actions when rule
returns true
:
record
: Record the terminal session and send it to Datadog.logs
: Generate Datadog logs, containing searchable snapshots of terminal output.process_info
: Record all processes launched inside the terminal session and generate an event for each process.approval
: Require approval before running the command.incidents
: Associate the recording with the Datadog Incident that the user is responding to, if any. If the user is responding to more than one incident, they are prompted to pick one.To take no action (other than running the command) when rule
returns true
, set actions: []
.
Rules are evaluated in order. CoTerm runs the actions specified for the first rule that evaluates to true
, and does not evaluate any further rules.
You can specify actions for CoTerm to take in a number of different ways. CoTerm decides which actions to take according to the following hierarchy:
--save-level
, --approval
), CoTerm takes only the actions specified through these CLI flags. This overrides all other configurations..ddcoterm/config.yaml
evaluates to true
, CoTerm takes the actions specified with the first rule that evalutes to true
. Overrides all configurations other than CLI flags.process_config.default_actions
: If no CLI flags specify actions, and no Lua rules match, CoTerm takes the actions specified in process_config.default_actions
in .ddcoterm/config.yaml
, if any.process_config.default_actions
is not set, CoTerm takes the following actions: ["record", "logs", "process_info"]
.All Lua snippets are executed inside a sandboxed Luau runtime. CoTerm injects the following variables and functions into the runtime:
executable
- stringkubectl foo bar
, executable
is kubectl
.args
- array<string>kubectl foo --bar=baz
, args
is ["foo", "--bar=baz"]
.flags
- table--
key-value flags in your command.command foo --bar baz
or command foo --bar=baz
, flags
has one entry where key
is bar
and value
is baz
. That is, flags.bar = baz
.k8s_current_context
- stringcurrent-context
value from ~./kube/config
. If this value is not found, k8s_current_context
is nil.has_arg(<string>)
true
if argument is present.kubectl foo bar
, has_arg("bar")
returns true
.