For AI agents: A markdown version of this page is available at https://dnd37xeb23o8n.cloudfront.net/stefon.simmons/docs-astro-web-10435/ja/api/latest/experiments/update-metric-sql-model.md. A documentation index is available at /llms.txt.
Language
Datadog site
注意This product is not supported for your selected Datadog site. (US1-FED).
注意This product is not supported for your selected Datadog site. (US2-FED).

Update metric SQL model

PUThttps://api.datadoghq.com/api/v2/experiments/metric-sql-models/{metric_sql_model_id}https://api.us3.datadoghq.com/api/v2/experiments/metric-sql-models/{metric_sql_model_id}https://api.us5.datadoghq.com/api/v2/experiments/metric-sql-models/{metric_sql_model_id}https://api.datadoghq.eu/api/v2/experiments/metric-sql-models/{metric_sql_model_id}https://api.ap1.datadoghq.com/api/v2/experiments/metric-sql-models/{metric_sql_model_id}https://api.ap2.datadoghq.com/api/v2/experiments/metric-sql-models/{metric_sql_model_id}https://api.uk1.datadoghq.com/api/v2/experiments/metric-sql-models/{metric_sql_model_id}https://api.ddog-gov.com/api/v2/experiments/metric-sql-models/{metric_sql_model_id}https://api.us2.ddog-gov.com/api/v2/experiments/metric-sql-models/{metric_sql_model_id}

概要

Replace a metric SQL model. This is a destructive full replace: subject types, customer-defined measures, and properties absent from the body are deleted, so send the complete set. Properties are matched by name; changing a property's column, type, or description preserves its ID. column_type is required for every measure and property. Removing a measure or property that an active metric references returns 409 Conflict. Server-generated IDs returned by GET are read-only and can be left in a replayed body. The response reports removals in meta.deleted_subject_types, meta.deleted_measures, and meta.deleted_properties. Certification is read-only. Certified models cannot be replaced through this endpoint.

This endpoint requires the product_analytics_warehouse_model_write permission.

OAuth apps require the product_analytics_warehouse_model_write authorization scope to access this endpoint.

引数

パスパラメーター

名前
タイプ
説明
metric_sql_model_id [required]
string

The UUID of the metric SQL model.

リクエスト

Body Data (required)

フィールド
タイプ
説明
data [required]
object

Metric SQL model resource to create.

応答

OK

Updated metric SQL model and its removed entries.

フィールド
タイプ
説明
data [required]
object

JSON:API resource containing the metric SQL model identity and fields.

meta
object

Model entries removed by the update. Empty arrays mean no entries were removed.

コード例

Update metric SQL model
# Path parameters
export metric_sql_model_id="550e8400-e29b-41d4-a716-446655440000"

# 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 PUT "https://api.${DD_SITE}/api/v2/experiments/metric-sql-models/${metric_sql_model_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "date_partition_column": null,
      "description": null,
      "measures": [
        {
          "column_name": "revenue",
          "column_type": "FLOAT",
          "description": null,
          "name": null
        }
      ],
      "name": "Order facts",
      "sql": "SELECT user_id, order_id, item_type, revenue, created_at FROM analytics.orders",
      "subject_types": [
        {
          "column_name": "user_id",
          "subject_type_id": "550e8400-e29b-41d4-a716-446655440010"
        }
      ],
      "timestamp_column": "created_at"
    },
    "type": "metric-sql-models"
  }
}
EOF
# Path parameters
export metric_sql_model_id="550e8400-e29b-41d4-a716-446655440000"

# 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 PUT "https://api.${DD_SITE}/api/v2/experiments/metric-sql-models/${metric_sql_model_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "date_partition_column": null,
      "description": null,
      "measures": [
        {
          "column_name": "revenue",
          "column_type": "FLOAT",
          "description": null,
          "name": null
        }
      ],
      "name": "Order facts",
      "sql": "SELECT user_id, order_id, item_type, revenue, created_at FROM analytics.orders",
      "subject_types": [
        {
          "column_name": "user_id",
          "subject_type_id": "550e8400-e29b-41d4-a716-446655440010"
        }
      ],
      "timestamp_column": "created_at"
    },
    "type": "metric-sql-models"
  }
}
EOF
# Path parameters
export metric_sql_model_id="550e8400-e29b-41d4-a716-446655440000"

# 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 PUT "https://api.${DD_SITE}/api/v2/experiments/metric-sql-models/${metric_sql_model_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "date_partition_column": null,
      "description": null,
      "measures": [
        {
          "column_name": "revenue",
          "column_type": "FLOAT",
          "description": null,
          "name": null
        }
      ],
      "name": "Order facts",
      "sql": "SELECT user_id, order_id, item_type, revenue, created_at FROM analytics.orders",
      "subject_types": [
        {
          "column_name": "user_id",
          "subject_type_id": "550e8400-e29b-41d4-a716-446655440010"
        }
      ],
      "timestamp_column": "created_at"
    },
    "type": "metric-sql-models"
  }
}
EOF
# Path parameters
export metric_sql_model_id="550e8400-e29b-41d4-a716-446655440000"

# 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 PUT "https://api.${DD_SITE}/api/v2/experiments/metric-sql-models/${metric_sql_model_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "date_partition_column": null,
      "description": null,
      "measures": [
        {
          "column_name": "revenue",
          "column_type": "FLOAT",
          "description": null,
          "name": null
        }
      ],
      "name": "Order facts",
      "sql": "SELECT user_id, order_id, item_type, revenue, created_at FROM analytics.orders",
      "subject_types": [
        {
          "column_name": "user_id",
          "subject_type_id": "550e8400-e29b-41d4-a716-446655440010"
        }
      ],
      "timestamp_column": "created_at"
    },
    "type": "metric-sql-models"
  }
}
EOF
# Path parameters
export metric_sql_model_id="550e8400-e29b-41d4-a716-446655440000"

# 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 PUT "https://api.${DD_SITE}/api/v2/experiments/metric-sql-models/${metric_sql_model_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "date_partition_column": null,
      "description": null,
      "measures": [
        {
          "column_name": "revenue",
          "column_type": "FLOAT",
          "description": null,
          "name": null
        }
      ],
      "name": "Order facts",
      "sql": "SELECT user_id, order_id, item_type, revenue, created_at FROM analytics.orders",
      "subject_types": [
        {
          "column_name": "user_id",
          "subject_type_id": "550e8400-e29b-41d4-a716-446655440010"
        }
      ],
      "timestamp_column": "created_at"
    },
    "type": "metric-sql-models"
  }
}
EOF
# Path parameters
export metric_sql_model_id="550e8400-e29b-41d4-a716-446655440000"

# 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 PUT "https://api.${DD_SITE}/api/v2/experiments/metric-sql-models/${metric_sql_model_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "date_partition_column": null,
      "description": null,
      "measures": [
        {
          "column_name": "revenue",
          "column_type": "FLOAT",
          "description": null,
          "name": null
        }
      ],
      "name": "Order facts",
      "sql": "SELECT user_id, order_id, item_type, revenue, created_at FROM analytics.orders",
      "subject_types": [
        {
          "column_name": "user_id",
          "subject_type_id": "550e8400-e29b-41d4-a716-446655440010"
        }
      ],
      "timestamp_column": "created_at"
    },
    "type": "metric-sql-models"
  }
}
EOF
# Path parameters
export metric_sql_model_id="550e8400-e29b-41d4-a716-446655440000"

# 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 PUT "https://api.${DD_SITE}/api/v2/experiments/metric-sql-models/${metric_sql_model_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "date_partition_column": null,
      "description": null,
      "measures": [
        {
          "column_name": "revenue",
          "column_type": "FLOAT",
          "description": null,
          "name": null
        }
      ],
      "name": "Order facts",
      "sql": "SELECT user_id, order_id, item_type, revenue, created_at FROM analytics.orders",
      "subject_types": [
        {
          "column_name": "user_id",
          "subject_type_id": "550e8400-e29b-41d4-a716-446655440010"
        }
      ],
      "timestamp_column": "created_at"
    },
    "type": "metric-sql-models"
  }
}
EOF
# Path parameters
export metric_sql_model_id="550e8400-e29b-41d4-a716-446655440000"

# 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 PUT "https://api.${DD_SITE}/api/v2/experiments/metric-sql-models/${metric_sql_model_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "date_partition_column": null,
      "description": null,
      "measures": [
        {
          "column_name": "revenue",
          "column_type": "FLOAT",
          "description": null,
          "name": null
        }
      ],
      "name": "Order facts",
      "sql": "SELECT user_id, order_id, item_type, revenue, created_at FROM analytics.orders",
      "subject_types": [
        {
          "column_name": "user_id",
          "subject_type_id": "550e8400-e29b-41d4-a716-446655440010"
        }
      ],
      "timestamp_column": "created_at"
    },
    "type": "metric-sql-models"
  }
}
EOF
# Path parameters
export metric_sql_model_id="550e8400-e29b-41d4-a716-446655440000"

# 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 PUT "https://api.${DD_SITE}/api/v2/experiments/metric-sql-models/${metric_sql_model_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "date_partition_column": null,
      "description": null,
      "measures": [
        {
          "column_name": "revenue",
          "column_type": "FLOAT",
          "description": null,
          "name": null
        }
      ],
      "name": "Order facts",
      "sql": "SELECT user_id, order_id, item_type, revenue, created_at FROM analytics.orders",
      "subject_types": [
        {
          "column_name": "user_id",
          "subject_type_id": "550e8400-e29b-41d4-a716-446655440010"
        }
      ],
      "timestamp_column": "created_at"
    },
    "type": "metric-sql-models"
  }
}
EOF