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

위젯 생성

POSThttps://api.datadoghq.com/api/v2/widgets/{experience_type}https://api.us3.datadoghq.com/api/v2/widgets/{experience_type}https://api.us5.datadoghq.com/api/v2/widgets/{experience_type}https://api.datadoghq.eu/api/v2/widgets/{experience_type}https://api.ap1.datadoghq.com/api/v2/widgets/{experience_type}https://api.ap2.datadoghq.com/api/v2/widgets/{experience_type}https://api.uk1.datadoghq.com/api/v2/widgets/{experience_type}https://api.ddog-gov.com/api/v2/widgets/{experience_type}https://api.us2.ddog-gov.com/api/v2/widgets/{experience_type}

개요

지정된 경험 유형에 대한 새 위젯을 생성합니다.

This endpoint requires any of the following permissions:

  • cloud_cost_management_write
  • generate_log_reports
  • manage_log_reports
  • product_analytics_saved_widgets_write

인수

경로 파라미터

이름
유형
설명
experience_type [required]
enum

The experience type for the widget.

Allowed enum values: ccm_reports, logs_reports, csv_reports, product_analytics

요청

Body Data (required)

위젯 요청 본문입니다. definition 객체의 필수 필드는 widget.definition.type에 따라 다릅니다. 모든 유형에는 requests가 필요하며 일부 유형에는 추가 필드가 필요합니다(예: cloud_cost_summary에는 graph_options가, geomap에는 style 및 view가 필요함). 아래 예시는 ccm_reports 경험 유형에 대한 전체 cloud_cost_summary 페이로드를 보여줍니다.

항목
유형
설명
data [required]
object

위젯을 생성하거나 업데이트하기 위한 요청 본문입니다.

응답

OK

Response containing a single widget.

항목
유형
설명
data [required]
object

A widget resource object.

included
[object]

Array of user resources related to the widget.

코드 예시

위젯 생성
# Path parameters
export experience_type="ccm_reports"

# 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/widgets/${experience_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "definition": {
        "graph_options": [
          {
            "type": "query_value",
            "view": "total"
          },
          {
            "type": "query_value",
            "view": "change"
          },
          {
            "display_type": "bars",
            "type": "timeseries"
          },
          {
            "type": "cloud_cost_table",
            "view": "summary"
          }
        ],
        "requests": [
          {
            "formulas": [
              {
                "formula": "query1"
              }
            ],
            "queries": [
              {
                "data_source": "cloud_cost",
                "name": "query1",
                "query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
              }
            ],
            "response_format": "timeseries"
          }
        ],
        "time": {
          "type": "live",
          "unit": "day",
          "value": 30
        },
        "title": "AWS spend by service (last 30 days)",
        "type": "cloud_cost_summary"
      },
      "tags": [
        "finops",
        "aws"
      ]
    },
    "type": "widgets"
  }
}
EOF
# Path parameters
export experience_type="ccm_reports"

# 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/widgets/${experience_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "definition": {
        "graph_options": [
          {
            "type": "query_value",
            "view": "total"
          },
          {
            "type": "query_value",
            "view": "change"
          },
          {
            "display_type": "bars",
            "type": "timeseries"
          },
          {
            "type": "cloud_cost_table",
            "view": "summary"
          }
        ],
        "requests": [
          {
            "formulas": [
              {
                "formula": "query1"
              }
            ],
            "queries": [
              {
                "data_source": "cloud_cost",
                "name": "query1",
                "query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
              }
            ],
            "response_format": "timeseries"
          }
        ],
        "time": {
          "type": "live",
          "unit": "day",
          "value": 30
        },
        "title": "AWS spend by service (last 30 days)",
        "type": "cloud_cost_summary"
      },
      "tags": [
        "finops",
        "aws"
      ]
    },
    "type": "widgets"
  }
}
EOF
# Path parameters
export experience_type="ccm_reports"

# 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/widgets/${experience_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "definition": {
        "graph_options": [
          {
            "type": "query_value",
            "view": "total"
          },
          {
            "type": "query_value",
            "view": "change"
          },
          {
            "display_type": "bars",
            "type": "timeseries"
          },
          {
            "type": "cloud_cost_table",
            "view": "summary"
          }
        ],
        "requests": [
          {
            "formulas": [
              {
                "formula": "query1"
              }
            ],
            "queries": [
              {
                "data_source": "cloud_cost",
                "name": "query1",
                "query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
              }
            ],
            "response_format": "timeseries"
          }
        ],
        "time": {
          "type": "live",
          "unit": "day",
          "value": 30
        },
        "title": "AWS spend by service (last 30 days)",
        "type": "cloud_cost_summary"
      },
      "tags": [
        "finops",
        "aws"
      ]
    },
    "type": "widgets"
  }
}
EOF
# Path parameters
export experience_type="ccm_reports"

# 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/widgets/${experience_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "definition": {
        "graph_options": [
          {
            "type": "query_value",
            "view": "total"
          },
          {
            "type": "query_value",
            "view": "change"
          },
          {
            "display_type": "bars",
            "type": "timeseries"
          },
          {
            "type": "cloud_cost_table",
            "view": "summary"
          }
        ],
        "requests": [
          {
            "formulas": [
              {
                "formula": "query1"
              }
            ],
            "queries": [
              {
                "data_source": "cloud_cost",
                "name": "query1",
                "query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
              }
            ],
            "response_format": "timeseries"
          }
        ],
        "time": {
          "type": "live",
          "unit": "day",
          "value": 30
        },
        "title": "AWS spend by service (last 30 days)",
        "type": "cloud_cost_summary"
      },
      "tags": [
        "finops",
        "aws"
      ]
    },
    "type": "widgets"
  }
}
EOF
# Path parameters
export experience_type="ccm_reports"

# 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/widgets/${experience_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "definition": {
        "graph_options": [
          {
            "type": "query_value",
            "view": "total"
          },
          {
            "type": "query_value",
            "view": "change"
          },
          {
            "display_type": "bars",
            "type": "timeseries"
          },
          {
            "type": "cloud_cost_table",
            "view": "summary"
          }
        ],
        "requests": [
          {
            "formulas": [
              {
                "formula": "query1"
              }
            ],
            "queries": [
              {
                "data_source": "cloud_cost",
                "name": "query1",
                "query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
              }
            ],
            "response_format": "timeseries"
          }
        ],
        "time": {
          "type": "live",
          "unit": "day",
          "value": 30
        },
        "title": "AWS spend by service (last 30 days)",
        "type": "cloud_cost_summary"
      },
      "tags": [
        "finops",
        "aws"
      ]
    },
    "type": "widgets"
  }
}
EOF
# Path parameters
export experience_type="ccm_reports"

# 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/widgets/${experience_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "definition": {
        "graph_options": [
          {
            "type": "query_value",
            "view": "total"
          },
          {
            "type": "query_value",
            "view": "change"
          },
          {
            "display_type": "bars",
            "type": "timeseries"
          },
          {
            "type": "cloud_cost_table",
            "view": "summary"
          }
        ],
        "requests": [
          {
            "formulas": [
              {
                "formula": "query1"
              }
            ],
            "queries": [
              {
                "data_source": "cloud_cost",
                "name": "query1",
                "query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
              }
            ],
            "response_format": "timeseries"
          }
        ],
        "time": {
          "type": "live",
          "unit": "day",
          "value": 30
        },
        "title": "AWS spend by service (last 30 days)",
        "type": "cloud_cost_summary"
      },
      "tags": [
        "finops",
        "aws"
      ]
    },
    "type": "widgets"
  }
}
EOF
# Path parameters
export experience_type="ccm_reports"

# 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/widgets/${experience_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "definition": {
        "graph_options": [
          {
            "type": "query_value",
            "view": "total"
          },
          {
            "type": "query_value",
            "view": "change"
          },
          {
            "display_type": "bars",
            "type": "timeseries"
          },
          {
            "type": "cloud_cost_table",
            "view": "summary"
          }
        ],
        "requests": [
          {
            "formulas": [
              {
                "formula": "query1"
              }
            ],
            "queries": [
              {
                "data_source": "cloud_cost",
                "name": "query1",
                "query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
              }
            ],
            "response_format": "timeseries"
          }
        ],
        "time": {
          "type": "live",
          "unit": "day",
          "value": 30
        },
        "title": "AWS spend by service (last 30 days)",
        "type": "cloud_cost_summary"
      },
      "tags": [
        "finops",
        "aws"
      ]
    },
    "type": "widgets"
  }
}
EOF
# Path parameters
export experience_type="ccm_reports"

# 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/widgets/${experience_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "definition": {
        "graph_options": [
          {
            "type": "query_value",
            "view": "total"
          },
          {
            "type": "query_value",
            "view": "change"
          },
          {
            "display_type": "bars",
            "type": "timeseries"
          },
          {
            "type": "cloud_cost_table",
            "view": "summary"
          }
        ],
        "requests": [
          {
            "formulas": [
              {
                "formula": "query1"
              }
            ],
            "queries": [
              {
                "data_source": "cloud_cost",
                "name": "query1",
                "query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
              }
            ],
            "response_format": "timeseries"
          }
        ],
        "time": {
          "type": "live",
          "unit": "day",
          "value": 30
        },
        "title": "AWS spend by service (last 30 days)",
        "type": "cloud_cost_summary"
      },
      "tags": [
        "finops",
        "aws"
      ]
    },
    "type": "widgets"
  }
}
EOF
# Path parameters
export experience_type="ccm_reports"

# 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/widgets/${experience_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "definition": {
        "graph_options": [
          {
            "type": "query_value",
            "view": "total"
          },
          {
            "type": "query_value",
            "view": "change"
          },
          {
            "display_type": "bars",
            "type": "timeseries"
          },
          {
            "type": "cloud_cost_table",
            "view": "summary"
          }
        ],
        "requests": [
          {
            "formulas": [
              {
                "formula": "query1"
              }
            ],
            "queries": [
              {
                "data_source": "cloud_cost",
                "name": "query1",
                "query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
              }
            ],
            "response_format": "timeseries"
          }
        ],
        "time": {
          "type": "live",
          "unit": "day",
          "value": 30
        },
        "title": "AWS spend by service (last 30 days)",
        "type": "cloud_cost_summary"
      },
      "tags": [
        "finops",
        "aws"
      ]
    },
    "type": "widgets"
  }
}
EOF