For AI agents: A markdown version of this page is available at https://dnd37xeb23o8n.cloudfront.net/jen.gilbert/astro-base/api/latest/metrics/query-scalar-data-across-multiple-products.md. A documentation index is available at /llms.txt.
Language
Datadog site

Query scalar data across multiple products

POSThttps://api.datadoghq.com/api/v2/query/scalarhttps://api.us3.datadoghq.com/api/v2/query/scalarhttps://api.us5.datadoghq.com/api/v2/query/scalarhttps://api.datadoghq.eu/api/v2/query/scalarhttps://api.ap1.datadoghq.com/api/v2/query/scalarhttps://api.ap2.datadoghq.com/api/v2/query/scalarhttps://api.uk1.datadoghq.com/api/v2/query/scalarhttps://api.ddog-gov.com/api/v2/query/scalarhttps://api.us2.ddog-gov.com/api/v2/query/scalar

Overview

Query scalar values (as seen on Query Value, Table, and Toplist widgets). Multiple data sources are supported with the ability to process the data using formulas and functions.

This endpoint requires the timeseries_query permission.

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

Request

Body Data (required)

Field
Type
Description
data [required]
object

A single scalar query to be executed.

Response

OK

A message containing one or more responses to scalar queries.

Field
Type
Description
data
object

A message containing the response to a scalar query.

errors
string

An error generated when processing a request.

Code Example

Scalar cross product query 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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "aggregator": "avg",
          "data_source": "metrics",
          "query": "avg:system.cpu.user{*}",
          "name": "a"
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "aggregator": "avg",
          "data_source": "metrics",
          "query": "avg:system.cpu.user{*}",
          "name": "a"
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "aggregator": "avg",
          "data_source": "metrics",
          "query": "avg:system.cpu.user{*}",
          "name": "a"
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "aggregator": "avg",
          "data_source": "metrics",
          "query": "avg:system.cpu.user{*}",
          "name": "a"
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "aggregator": "avg",
          "data_source": "metrics",
          "query": "avg:system.cpu.user{*}",
          "name": "a"
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "aggregator": "avg",
          "data_source": "metrics",
          "query": "avg:system.cpu.user{*}",
          "name": "a"
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "aggregator": "avg",
          "data_source": "metrics",
          "query": "avg:system.cpu.user{*}",
          "name": "a"
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "aggregator": "avg",
          "data_source": "metrics",
          "query": "avg:system.cpu.user{*}",
          "name": "a"
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "aggregator": "avg",
          "data_source": "metrics",
          "query": "avg:system.cpu.user{*}",
          "name": "a"
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
EOF
Scalar cross product query with RUM data source 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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "data_source": "rum",
          "name": "a",
          "compute": {
            "aggregation": "count"
          },
          "search": {
            "query": "*"
          },
          "indexes": [
            "*"
          ]
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "data_source": "rum",
          "name": "a",
          "compute": {
            "aggregation": "count"
          },
          "search": {
            "query": "*"
          },
          "indexes": [
            "*"
          ]
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "data_source": "rum",
          "name": "a",
          "compute": {
            "aggregation": "count"
          },
          "search": {
            "query": "*"
          },
          "indexes": [
            "*"
          ]
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "data_source": "rum",
          "name": "a",
          "compute": {
            "aggregation": "count"
          },
          "search": {
            "query": "*"
          },
          "indexes": [
            "*"
          ]
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "data_source": "rum",
          "name": "a",
          "compute": {
            "aggregation": "count"
          },
          "search": {
            "query": "*"
          },
          "indexes": [
            "*"
          ]
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "data_source": "rum",
          "name": "a",
          "compute": {
            "aggregation": "count"
          },
          "search": {
            "query": "*"
          },
          "indexes": [
            "*"
          ]
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "data_source": "rum",
          "name": "a",
          "compute": {
            "aggregation": "count"
          },
          "search": {
            "query": "*"
          },
          "indexes": [
            "*"
          ]
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "data_source": "rum",
          "name": "a",
          "compute": {
            "aggregation": "count"
          },
          "search": {
            "query": "*"
          },
          "indexes": [
            "*"
          ]
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "data_source": "rum",
          "name": "a",
          "compute": {
            "aggregation": "count"
          },
          "search": {
            "query": "*"
          },
          "indexes": [
            "*"
          ]
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
EOF
Scalar cross product query with apm_dependency_stats data source 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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "data_source": "apm_dependency_stats",
          "name": "a",
          "env": "ci",
          "service": "cassandra",
          "stat": "avg_duration",
          "operation_name": "cassandra.query",
          "resource_name": "DELETE FROM monitor_history.monitor_state_change_history WHERE org_id = ? AND monitor_id IN ? AND group = ?",
          "primary_tag_name": "datacenter",
          "primary_tag_value": "edge-eu1.prod.dog"
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "data_source": "apm_dependency_stats",
          "name": "a",
          "env": "ci",
          "service": "cassandra",
          "stat": "avg_duration",
          "operation_name": "cassandra.query",
          "resource_name": "DELETE FROM monitor_history.monitor_state_change_history WHERE org_id = ? AND monitor_id IN ? AND group = ?",
          "primary_tag_name": "datacenter",
          "primary_tag_value": "edge-eu1.prod.dog"
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "data_source": "apm_dependency_stats",
          "name": "a",
          "env": "ci",
          "service": "cassandra",
          "stat": "avg_duration",
          "operation_name": "cassandra.query",
          "resource_name": "DELETE FROM monitor_history.monitor_state_change_history WHERE org_id = ? AND monitor_id IN ? AND group = ?",
          "primary_tag_name": "datacenter",
          "primary_tag_value": "edge-eu1.prod.dog"
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "data_source": "apm_dependency_stats",
          "name": "a",
          "env": "ci",
          "service": "cassandra",
          "stat": "avg_duration",
          "operation_name": "cassandra.query",
          "resource_name": "DELETE FROM monitor_history.monitor_state_change_history WHERE org_id = ? AND monitor_id IN ? AND group = ?",
          "primary_tag_name": "datacenter",
          "primary_tag_value": "edge-eu1.prod.dog"
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "data_source": "apm_dependency_stats",
          "name": "a",
          "env": "ci",
          "service": "cassandra",
          "stat": "avg_duration",
          "operation_name": "cassandra.query",
          "resource_name": "DELETE FROM monitor_history.monitor_state_change_history WHERE org_id = ? AND monitor_id IN ? AND group = ?",
          "primary_tag_name": "datacenter",
          "primary_tag_value": "edge-eu1.prod.dog"
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "data_source": "apm_dependency_stats",
          "name": "a",
          "env": "ci",
          "service": "cassandra",
          "stat": "avg_duration",
          "operation_name": "cassandra.query",
          "resource_name": "DELETE FROM monitor_history.monitor_state_change_history WHERE org_id = ? AND monitor_id IN ? AND group = ?",
          "primary_tag_name": "datacenter",
          "primary_tag_value": "edge-eu1.prod.dog"
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "data_source": "apm_dependency_stats",
          "name": "a",
          "env": "ci",
          "service": "cassandra",
          "stat": "avg_duration",
          "operation_name": "cassandra.query",
          "resource_name": "DELETE FROM monitor_history.monitor_state_change_history WHERE org_id = ? AND monitor_id IN ? AND group = ?",
          "primary_tag_name": "datacenter",
          "primary_tag_value": "edge-eu1.prod.dog"
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "data_source": "apm_dependency_stats",
          "name": "a",
          "env": "ci",
          "service": "cassandra",
          "stat": "avg_duration",
          "operation_name": "cassandra.query",
          "resource_name": "DELETE FROM monitor_history.monitor_state_change_history WHERE org_id = ? AND monitor_id IN ? AND group = ?",
          "primary_tag_name": "datacenter",
          "primary_tag_value": "edge-eu1.prod.dog"
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
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/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "data_source": "apm_dependency_stats",
          "name": "a",
          "env": "ci",
          "service": "cassandra",
          "stat": "avg_duration",
          "operation_name": "cassandra.query",
          "resource_name": "DELETE FROM monitor_history.monitor_state_change_history WHERE org_id = ? AND monitor_id IN ? AND group = ?",
          "primary_tag_name": "datacenter",
          "primary_tag_value": "edge-eu1.prod.dog"
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
EOF