·
Last changedVersion:
This version passed the hardening gate. Hardening updated the skill content and independently checked the resulting changes. Classified findings before hardening: 3. Classified findings closed: 0. Classified findings remaining: 3. Unclassified scanner findings remaining: 0. Review findings closed: 1. Review findings remaining: 17.
1
2
1
2
Expand | File | Group | Subtype | Severity | Status |
|---|---|---|---|---|---|
SKILL.md | Tool & MCP Manipulation | MCP configuration abuse | Medium | Open | |
SKILL.md | Malicious Code & Command Execution | — | Low | Open | |
SKILL.md | Supply Chain & Install-Time Trust | Install-time download and execute | Low | Open |
3 findings
Read this before building any rule. It gives you the mental model to construct the right filter and catch edge cases.
What remapping does: A rule intercepts telemetry at ingestion time and rewrites the service name before indexing. A rule says: "for any entity matching this filter, replace its service name with this new value."
Two entity types — pick the right one:
| Entity type | rule_type integer | What it targets |
|---|---|---|
SERVICE |
| Instrumented services — have spans with an explicit |
INFERRED_ENTITY |
| Auto-detected from outbound calls — named from |
Prerequisite for inferred entity remapping — peer.service must be set:
Inferred entity remapping only works when the tracer sets peer.service on outbound spans. Without it, entities are keyed by peer.hostname and remapping rules will not apply.
To enable this, set the following env var on the instrumented service (not the downstream dependency):
This makes the ddtrace tracer automatically propagate peer.service from peer.hostname on outbound HTTP, gRPC, and database calls. Without this, pup traces search will show spans with peer.hostname but no peer.service, and no service remapping rule will match.
To verify peer.service is being set before building a rule:
If zero results — the tracer is not setting peer.service. Ask the user to add DD_TRACE_PEER_SERVICE_DEFAULTS_ENABLED=true to their service's environment and redeploy before continuing.
Filter syntax — a standard Datadog event-grammar query string:
| Goal | Filter |
|---|---|
Exact service match |
|
All services with a prefix |
|
All services with a suffix |
|
All services containing a string |
|
All inferred services under a domain |
|
Service in one environment only |
|
Multiple possible values |
|
New name syntax — the value field in rewrite_tag_rules:
| Form | Example | Use for |
|---|---|---|
Static string |
| Every matched entity gets exactly this name |
Tag interpolation |
| Substitute the full value of a tag |
Tag + regex capture |
| Extract part of a tag value (non-greedy capture) |
Regex constraints for {{tag\|regex}}:
(.+?) not (.+), (.*?) not (.*)(foo)+) are not allowed^(.*)$) is currently rejected by the UI and will soon be rejected by the API — if you want the full tag value, use tag interpolation ({{service}}) instead of a regexFive remapping patterns:
| Pattern | User says… | Filter example | New name example |
|---|---|---|---|
N:1 group | "These N services are all the same thing" |
|
|
Strip suffix/prefix | "The name has junk at the end/start" |
|
|
1:1 rename | "We renamed this service and Datadog needs to match" |
|
|
Env split | "I want separate services per env but they all have the same name" |
|
|
Prefix normalization | "All services should start with an env or team name" |
|
|
Invoke this skill when the user wants to:
api.shopify.com/* variants → shopify)peer.service names to something meaningfulmy-service + env:prod → my-service-prod)Do NOT invoke this skill if:
DD_SERVICE), not a remapping ruleIf not found:
Check auth:
If not authenticated:
pup apm service-remapping list and get work with OAuth. Create, update, and delete require API keys (DD_API_KEY, DD_APP_KEY, DD_SITE) until apm_service_renaming_write is added to pup's OAuth scopes.
If any are missing and you need to create/update/delete rules:
Wait for the user to set credentials, then re-run the check above before continuing.
| Variable | How to resolve |
|---|---|
| Required before creating the rule (Step 4). Ask the user — do NOT assume |
| Current service name(s) to remap — discover with |
| Instrumented service ( |
| The desired new service name — ask the user |
| Which pattern applies — identify from the user's description (see Domain Knowledge above) |
If the user hasn't specified exact names to remap, discover what exists first:
Use the output to help the user identify exact service names. Ask the user to confirm which names they want remapped before proceeding.
Work through each component before writing any JSON.
Some service names (e.g. grpc-client, net/http, aws.s3, redis) are integration-generated overrides — the tracer auto-tags spans with them based on the library being used, not a user-set service tag. Remapping these with a service remapping rule is the wrong tool: the override is injected per-span by the integration, so the remapped name will keep re-appearing unless the override itself is removed.
How to detect: if the service name looks like a well-known integration name (single-word library names, <protocol>-<client> patterns, <vendor>.<resource> patterns), ask the user:
If the user confirms it is an integration override, stop here and direct them to the UI. Do not create a remapping rule.
[DECISION: entity type — ask the user if unclear]
service tag? → rule_type: 0 (SERVICE)rule_type: 1 (INFERRED_ENTITY)If the user wants to remap an inferred entity, verify peer.service is set before proceeding — see the prerequisite in Domain Knowledge. If it is not set, stop and ask the user to enable DD_TRACE_PEER_SERVICE_DEFAULTS_ENABLED=true first.
Write a single event-grammar query string targeting the service(s) to remap. Use the filter syntax and pattern table in Domain Knowledge to pick the right form. State the filter expression verbatim in the planned-rule preview (Step 3) — it is the user's primary way to verify the rule will match the intended entities, and they cannot evaluate the rule without it.
value)Use the new name syntax and regex table in Domain Knowledge to pick the right form. For regex values, apply the constraints listed there.
Suggest a descriptive name. Examples:
collapse-shopify-inferred-servicesstrip-tropos-suffixrename-old-auth-to-auth-serviceenv-split-my-service-prodBefore constructing the JSON, check what will be affected:
Report to the user:
| Item | What to surface |
|---|---|
Telemetry volume | Non-zero spans confirm the filter will match real data. Zero = likely wrong service name or env. |
Monitors | Any monitor referencing the old service name will silently break after remapping. |
Dashboards | Any dashboard with the old service name in its title will have stale references after remapping. |
Conflicting rules | Existing rules targeting the same service may be overridden. Show conflicts and ask the user to confirm. |
Known gaps — Claude cannot verify these automatically:
Remapping a service name can also break the following. Claude has no pup commands to check them today, so surface this as a manual checklist for the user before they confirm:
Show the user the planned rule and confirm before creating. Batch any unresolved context variables into this same prompt — do not ask for them in a separate earlier turn. One round-trip, not two.
If the filter doesn't already scope to an environment, ask whether to add one — env scoping is done by appending AND env:<ENV> to the filter expression, not via a separate API parameter.
Wait for confirmation before continuing.
If the response contains an id field — creation succeeded. Record the id and version values from the response.
ERROR: 400 Bad Request with "Filter expression has invalid syntax" — the filter query is malformed. Check glob syntax and boolean operators.
ERROR: 400 Bad Request with "Template value in target name is invalid" — the value regex is invalid. Check: max 1 capture group, non-greedy quantifiers inside groups ((.+?) not (.+)).
ERROR: 401 Unauthorized — credentials are invalid or expired. Re-check DD_API_KEY and DD_APP_KEY.
ERROR: 403 Forbidden — the API key lacks apm_service_renaming_write permission.
Allow 2–5 minutes for the rule to propagate, then confirm it is active.
If <TARGET_NAME> appears in either — rule is active.
Inferred entities don't produce their own spans, so they won't appear in pup apm services list or pup traces search. Verify in two steps:
Step 5a — confirm the rule is stored correctly:
Confirm the filter and value match what you intended.
Step 5b — confirm the entity name changed in the service map:
Ask the user to check the APM Service Map in the Datadog UI and look for <TARGET_NAME> where <ORIGINAL_SERVICE> used to appear. The service map is the authoritative view for inferred entity names.
Alternatively, confirm new peer.service values are arriving on spans from the instrumented service:
If spans appear with peer.service:<TARGET_NAME> — rule is active.
ERROR: New name not appearing after 5 minutes:
peer.service: pup traces search --query "@peer.service:<ORIGINAL_SERVICE>" --from 5mDD_TRACE_PEER_SERVICE_DEFAULTS_ENABLED=true is set on the instrumented service — without it peer.service is never set and the rule will never fireUpdate requires the current version from list/get output. Show the proposed changes to the user and confirm before running:
ERROR: 409 Conflict — the rule was modified since you fetched it. Re-fetch with get to get the current version and retry.
Show the user the rule's name and filter first, then ask for confirmation. Delete requires both the rule id and version from the list/get output:
ERROR: 409 Conflict — the rule was modified since you fetched it. Re-fetch with get to get the current version and retry.
Exit when ALL of the following are true:
id returned in responsepup apm services list or pup traces searchpeer.service:<TARGET_NAME>$DD_API_KEY and $DD_APP_KEYprod as the environment — always confirm with the userGet started with chainctlchainctl skill install public/datadog-labs/service-remapping:latest
Bring Chainguard's hardening pipeline to your first-party skills — custom rulesets, automated remediation, full audit trail.
skills.cgr.dev/public/github.com/datadog-labs/dd-apm/service-remapping:latest
MIT
HARDENING.md
LICENSE
SKILL.md