基于 SOC 职业分类
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/DataDog/datadog-agent --skill create-core-check命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
Monitor the current PR's GitLab pipeline to completion, then report success or investigate a failure. Use when the user asks to follow, babysit, watch, or wait on a PR/pipeline, or just after pushing to / creating a PR.
Classify a failed CI as either caused by an active incident, flakiness, or a true code regression. Use when a PR's pipeline is red and it isn't obvious whether the PR's own changes are at fault. Trigger phrases include: - "investigate this CI failure" - "please fix CI" - "why did this job fail" - "is there an incident affecting CI" - "should I retry this" This should also be invoked whenever the user asks you to investigate _or fix_ a failing CI, to ensure we don't spend hours trying to fix something broken upstream.
Write or extend Datadog Agent new-e2e tests, including fakeintake coverage and the GitLab wiring that runs them; derives scope from the current diff when no target is named. Not for running tests that already exist (run-e2e, run-windows-e2e), or for judging whether a behavior belongs in E2E at all (e2e-audit).
| name | create-core-check |
| description | Create a new Go core check that collects metrics and sends them to Datadog |
| allowed-tools | Bash, Read, Write, Edit, Glob, Grep, AskUserQuestion |
| argument-hint | [check-name] |
| model | sonnet |
Create a new Go-based core check for the Datadog Agent. Core checks collect metrics, service checks, or events and send them to Datadog at regular intervals.
Use AskUserQuestion to collect the following. If $ARGUMENTS provides the check name, skip that question.
Check name: The identifier for the check (e.g. uptime, memory, ntp). Used as the package name, registration key, and config directory name.
Check category: Where should the check live under pkg/collector/corechecks/?
system/ — System-level checks (CPU, memory, uptime, disk)net/ — Network checks (NTP, DNS)containers/ — Container-related checksebpf/ — eBPF-based checks (these are more complex, see pkg/collector/corechecks/ebpf/AGENTS.md)embed/ — Embedded service checkscorechecks/ — For standalone checksWhat does it collect?: Describe the metrics, service checks, or events it produces.
Configuration: Does it need instance-level configuration?
uptime)memory with collect_memory_pressure)ntp with different servers)Component dependencies: Does the check need injected components?
Long-running?: Does the check run continuously in the background?
Run() is called at regular intervals (default 15s)Run() never returns, processes events in a loopPlatform restrictions: Does the check only work on certain platforms?
Before writing any code, read the appropriate reference files based on the check type determined in Step 1. Follow the patterns found in these files exactly.
| Check type | Reference file to read |
|---|---|
| Simple, no config | pkg/collector/corechecks/system/uptime/uptime.go |
| Simple with config | pkg/collector/corechecks/system/memory/memory.go |
| Multi-instance with config | pkg/collector/corechecks/net/ntp/ntp.go |
| With component dependencies | pkg/collector/corechecks/containerimage/check.go |
| Long-running | Read the NewLongRunningCheckWrapper usage in pkg/collector/corechecks/containerimage/check.go |
| Platform-specific stubs | Find a _no*.go or _stub.go file alongside a platform-specific check in pkg/collector/corechecks/system/ |
Also read these files for registration and test patterns:
pkg/commonchecks/corechecks.go — to see how checks are registered (import alias convention, RegisterCheck calls)_test.go file alongside whichever reference check you read — to see mock sender patternsDirectory: pkg/collector/corechecks/<category>/<checkname>/
Create the check implementation file following the patterns from the reference files read in Step 2. Key structural elements that every check needs:
CheckName constant — string identifier for the checkCheck struct — embeds core.CheckBase, plus any config or component fieldsFactory() function — returns option.Option[func() check.Check]. Components are injected as Factory parameters.Configure() method — calls CommonConfigure, then FinalizeCheckServiceTag, then parses instance config if neededRun() method — collects data, calls sender methods, ends with sender.Commit()Key rules to follow:
c.BuildID(integrationConfigDigest, rawInstance, rawInitConfig) before CommonConfigure()core.NewLongRunningCheckWrapper() in Factory, return 0 from Interval(), implement Stop()//go:build <platform> tag and create a stub file for other platforms that returns option.None[func() check.Check]()Edit pkg/commonchecks/corechecks.go:
corecheckLoader.RegisterCheck() call in RegisterChecks(), matching the Factory signature to available component parametersFile: cmd/agent/dist/conf.d/<checkname>.d/conf.yaml.default
Look at an existing example in cmd/agent/dist/conf.d/ for the format. At minimum:
init_config:
instances:
- {}
For checks with configuration, use @param annotations following the same format as other conf.yaml.default files in the tree.
File: pkg/collector/corechecks/<category>/<checkname>/<checkname>_test.go
Follow the test patterns from the reference file read in Step 2. The standard test flow is:
mocksender.NewMockSender("")mockSender.On("FinalizeCheckServiceTag").Return()Configure the check with mockSender.GetSenderManager()mocksender.SetSender(mockSender, check.ID())Run() and assert expectationsRun the check tests:
dda inv test --targets=./pkg/collector/corechecks/<category>/<checkname>
Build the agent:
dda inv agent.build --build-exclude=systemd
Run the linter:
dda inv linter.go
Report the results to the user.
The sender (c.GetSender()) provides these methods for submitting data:
| Method | Description |
|---|---|
Gauge(metric, value, hostname, tags) | Submit a gauge metric |
Rate(metric, value, hostname, tags) | Submit a rate metric |
Count(metric, value, hostname, tags) | Submit a count metric |
MonotonicCount(metric, value, hostname, tags) | Submit a monotonic count |
Histogram(metric, value, hostname, tags) | Submit a histogram metric |
Distribution(metric, value, hostname, tags) | Submit a distribution metric |
ServiceCheck(name, status, hostname, tags, message) | Submit a service check |
Event(event) | Submit an event |
Commit() | Flush all submitted data — must be called at end of Run() |
"" for hostname to use the agent's default hostname.nil for tags if no tags are needed.servicecheck.ServiceCheckOK, ServiceCheckWarning, ServiceCheckCritical, ServiceCheckUnknown (from pkg/metrics/servicecheck).CheckBase provides default implementations for most Check interface methods. You only need to override Run() and optionally Configure(), Stop(), and Interval().CommonConfigure handles standard configuration: collection interval (min_collection_interval), custom tags, service tag, etc.FinalizeCheckServiceTag() must be called after CommonConfigure to apply the service tag to the sender.sender.Commit() at the end of Run() to flush data.BuildID() must be called before CommonConfigure().option.None[func() check.Check]() pattern is used for platform stubs — the loader skips checks with no factory.integration.FakeConfigHash is the constant to use in tests for the config digest parameter./create-core-check — Interactive: prompts for all details/create-core-check my_check — Pre-fills the check name