For AI agents: A markdown version of this page is available at https://dnd37xeb23o8n.cloudfront.net/jen.gilbert/astro-base/ko/api/latest/apm-retention-filters/create-a-retention-filter.md. A documentation index is available at /llms.txt.
Language
Datadog site

보존 필터 생성

POSThttps://api.datadoghq.com/api/v2/apm/config/retention-filtershttps://api.us3.datadoghq.com/api/v2/apm/config/retention-filtershttps://api.us5.datadoghq.com/api/v2/apm/config/retention-filtershttps://api.datadoghq.eu/api/v2/apm/config/retention-filtershttps://api.ap1.datadoghq.com/api/v2/apm/config/retention-filtershttps://api.ap2.datadoghq.com/api/v2/apm/config/retention-filtershttps://api.uk1.datadoghq.com/api/v2/apm/config/retention-filtershttps://api.ddog-gov.com/api/v2/apm/config/retention-filtershttps://api.us2.ddog-gov.com/api/v2/apm/config/retention-filters

개요

소속 조직에서 스팬을 인덱싱하기 위한 보존 필터를 생성합니다. 요청이 성공하면 보존 필터 정의를 반환합니다.

spans-errors-sampling-processor 및 spans-appsec-sampling-processor 유형의 기본 필터는 생성할 수 없습니다.

This endpoint requires the apm_retention_filter_write permission.

요청

Body Data (required)

새로운 보존 필터의 정의입니다.

항목
유형
설명
data [required]
object

생성할 보존 필터의 본문

응답

OK

The retention filters definition.

항목
유형
설명
data
object

The definition of the retention filter.

코드 예시

Create a retention filter returns "OK" response
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/apm/config/retention-filters" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "enabled": true,
      "filter": {
        "query": "@http.status_code:200 service:my-service"
      },
      "filter_type": "spans-sampling-processor",
      "name": "my retention filter",
      "rate": 1.0
    },
    "type": "apm_retention_filter"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/apm/config/retention-filters" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "enabled": true,
      "filter": {
        "query": "@http.status_code:200 service:my-service"
      },
      "filter_type": "spans-sampling-processor",
      "name": "my retention filter",
      "rate": 1.0
    },
    "type": "apm_retention_filter"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/apm/config/retention-filters" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "enabled": true,
      "filter": {
        "query": "@http.status_code:200 service:my-service"
      },
      "filter_type": "spans-sampling-processor",
      "name": "my retention filter",
      "rate": 1.0
    },
    "type": "apm_retention_filter"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/apm/config/retention-filters" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "enabled": true,
      "filter": {
        "query": "@http.status_code:200 service:my-service"
      },
      "filter_type": "spans-sampling-processor",
      "name": "my retention filter",
      "rate": 1.0
    },
    "type": "apm_retention_filter"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/apm/config/retention-filters" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "enabled": true,
      "filter": {
        "query": "@http.status_code:200 service:my-service"
      },
      "filter_type": "spans-sampling-processor",
      "name": "my retention filter",
      "rate": 1.0
    },
    "type": "apm_retention_filter"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/apm/config/retention-filters" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "enabled": true,
      "filter": {
        "query": "@http.status_code:200 service:my-service"
      },
      "filter_type": "spans-sampling-processor",
      "name": "my retention filter",
      "rate": 1.0
    },
    "type": "apm_retention_filter"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/apm/config/retention-filters" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "enabled": true,
      "filter": {
        "query": "@http.status_code:200 service:my-service"
      },
      "filter_type": "spans-sampling-processor",
      "name": "my retention filter",
      "rate": 1.0
    },
    "type": "apm_retention_filter"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/apm/config/retention-filters" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "enabled": true,
      "filter": {
        "query": "@http.status_code:200 service:my-service"
      },
      "filter_type": "spans-sampling-processor",
      "name": "my retention filter",
      "rate": 1.0
    },
    "type": "apm_retention_filter"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/apm/config/retention-filters" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "enabled": true,
      "filter": {
        "query": "@http.status_code:200 service:my-service"
      },
      "filter_type": "spans-sampling-processor",
      "name": "my retention filter",
      "rate": 1.0
    },
    "type": "apm_retention_filter"
  }
}
EOF
Create a retention filter with trace rate returns "OK" response
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/apm/config/retention-filters" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "enabled": true,
      "filter": {
        "query": "@http.status_code:200 service:my-service"
      },
      "filter_type": "spans-sampling-processor",
      "name": "my retention filter",
      "rate": 1.0,
      "trace_rate": 1.0
    },
    "type": "apm_retention_filter"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/apm/config/retention-filters" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "enabled": true,
      "filter": {
        "query": "@http.status_code:200 service:my-service"
      },
      "filter_type": "spans-sampling-processor",
      "name": "my retention filter",
      "rate": 1.0,
      "trace_rate": 1.0
    },
    "type": "apm_retention_filter"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/apm/config/retention-filters" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "enabled": true,
      "filter": {
        "query": "@http.status_code:200 service:my-service"
      },
      "filter_type": "spans-sampling-processor",
      "name": "my retention filter",
      "rate": 1.0,
      "trace_rate": 1.0
    },
    "type": "apm_retention_filter"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/apm/config/retention-filters" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "enabled": true,
      "filter": {
        "query": "@http.status_code:200 service:my-service"
      },
      "filter_type": "spans-sampling-processor",
      "name": "my retention filter",
      "rate": 1.0,
      "trace_rate": 1.0
    },
    "type": "apm_retention_filter"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/apm/config/retention-filters" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "enabled": true,
      "filter": {
        "query": "@http.status_code:200 service:my-service"
      },
      "filter_type": "spans-sampling-processor",
      "name": "my retention filter",
      "rate": 1.0,
      "trace_rate": 1.0
    },
    "type": "apm_retention_filter"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/apm/config/retention-filters" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "enabled": true,
      "filter": {
        "query": "@http.status_code:200 service:my-service"
      },
      "filter_type": "spans-sampling-processor",
      "name": "my retention filter",
      "rate": 1.0,
      "trace_rate": 1.0
    },
    "type": "apm_retention_filter"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/apm/config/retention-filters" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "enabled": true,
      "filter": {
        "query": "@http.status_code:200 service:my-service"
      },
      "filter_type": "spans-sampling-processor",
      "name": "my retention filter",
      "rate": 1.0,
      "trace_rate": 1.0
    },
    "type": "apm_retention_filter"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/apm/config/retention-filters" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "enabled": true,
      "filter": {
        "query": "@http.status_code:200 service:my-service"
      },
      "filter_type": "spans-sampling-processor",
      "name": "my retention filter",
      "rate": 1.0,
      "trace_rate": 1.0
    },
    "type": "apm_retention_filter"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/apm/config/retention-filters" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "enabled": true,
      "filter": {
        "query": "@http.status_code:200 service:my-service"
      },
      "filter_type": "spans-sampling-processor",
      "name": "my retention filter",
      "rate": 1.0,
      "trace_rate": 1.0
    },
    "type": "apm_retention_filter"
  }
}
EOF