Crear una configuración de etiquetas
https://api.datadoghq.com/api/v2/query/timeserieshttps://api.us3.datadoghq.com/api/v2/query/timeserieshttps://api.us5.datadoghq.com/api/v2/query/timeserieshttps://api.datadoghq.eu/api/v2/query/timeserieshttps://api.ap1.datadoghq.com/api/v2/query/timeserieshttps://api.ap2.datadoghq.com/api/v2/query/timeserieshttps://api.uk1.datadoghq.com/api/v2/query/timeserieshttps://api.ddog-gov.com/api/v2/query/timeserieshttps://api.us2.ddog-gov.com/api/v2/query/timeseriesDescripción general
Consulta datos de series temporales a través de varios orígenes de datos y procesa los datos aplicando fórmulas y funciones.
OAuth apps require the timeseries_query authorization scope to access this endpoint.
Solicitud
Body Data (required)
data [required]Una solicitud de función contenedora sobre una única consulta de series temporales a ejecutar.
attributes [required]The object describing a timeseries formula request.
formulasList of formulas to be calculated and returned as responses.
formula [required]Formula string, referencing one or more queries with their name property.
limitMessage for specifying limits to the number of values returned by a query. This limit is only for scalar queries and has no effect on timeseries queries.
countThe number of results to which to limit.
orderDirection of sort.
descasc, descfrom [required]Start date (inclusive) of the query in milliseconds since the Unix epoch.
intervalA time interval in milliseconds. May be overridden by a larger interval if the query would result in too many points for the specified timeframe. Defaults to a reasonable interval for the given timeframe.
queries [required]List of queries to be run and used as inputs to the formulas.
Object 1A query against Datadog custom metrics or Cloud Cost data sources.
cross_org_uuidsOrganization UUIDs to query when using cross-organization visibility. Limited to one organization UUID.
data_source [required]A data source that is powered by the Metrics platform.
metricsmetrics, cloud_costnameThe variable name for use in formulas.
query [required]A classic metrics query string.
Object 2An individual timeseries query for logs, RUM, traces, CI pipelines, security signals, and other event-based data sources. Use this query type for any data source powered by the Events Platform. See the data_source field for the full list of supported sources.
compute [required]The instructions for what to compute for this query.
aggregation [required]The type of aggregation that can be performed on events-based queries.
countcount, cardinality, pc75, pc90, pc95, pc98, pc99, sum, min, maxShow 1 more
avgintervalInterval for compute in milliseconds.
metricThe "measure" attribute on which to perform the computation.
cross_org_uuidsOrganization UUIDs to query when using cross-organization visibility. Limited to one organization UUID.
data_source [required]A data source that is powered by the Events Platform.
logslogs, spans, network, rum, security_signals, profiles, audit, events, ci_tests, ci_pipelinesShow 4 more
incident_analytics, product_analytics, on_call_events, doragroup_byThe list of facets on which to split results.
facet [required]The facet by which to split groups.
limitThe maximum buckets to return for this group by. Note: at most 10000 buckets are allowed. If grouping by multiple facets, the product of limits must not exceed 10000.
10sortThe dimension by which to sort a query's results.
aggregation [required]The type of aggregation that can be performed on events-based queries.
countcount, cardinality, pc75, pc90, pc95, pc98, pc99, sum, min, maxShow 1 more
avgmetricThe metric's calculated value which should be used to define the sort order of a query's results.
orderDirection of sort.
descasc, desctypeThe type of sort to use on the calculated value.
alphabetical, measureindexesThe indexes in which to search.
nameThe variable name for use in formulas.
searchConfiguration of the search/filter for an events query.
queryThe search/filter string for an events query.
<data_source=apm_resource_stats>A query for APM resource statistics such as latency, error rate, and hit count, grouped by resource name.
cross_org_uuidsOrganization UUIDs to query when using cross-organization visibility. Limited to one organization UUID.
data_source [required]A data source for APM resource statistics queries.
apm_resource_statsapm_resource_statsenv [required]The environment to query.
group_byTag keys to group results by.
name [required]The variable name for use in formulas.
operation_nameThe APM operation name.
primary_tag_nameName of the second primary tag used within APM. Required when primary_tag_value is specified. See https://docs.datadoghq.com/tracing/guide/setting_primary_tags_to_scope/#add-a-second-primary-tag-in-datadog
primary_tag_valueValue of the second primary tag by which to filter APM data. primary_tag_name must also be specified.
resource_nameThe resource name to filter by.
service [required]The service name to filter by.
stat [required]The APM resource statistic to query.
error_rate, errors, hits, latency_avg, latency_max, latency_p50, latency_p75, latency_p90, latency_p95, latency_p99Show 2 more
latency_distribution, total_time<data_source=apm_metrics>A query for APM trace metrics such as hits, errors, and latency percentiles, aggregated across services.
cross_org_uuidsOrganization UUIDs to query when using cross-organization visibility. Limited to one organization UUID.
data_source [required]A data source for APM metrics queries.
apm_metricsapm_metricsgroup_byOptional fields to group the query results by.
name [required]The variable name for use in formulas.
operation_modeOptional operation mode to aggregate across operation names.
operation_nameName of operation on service. If not provided, the primary operation name is used.
peer_tagsTags to query for a specific downstream entity (peer.service, peer.db_instance, peer.s3, peer.s3.bucket, etc.).
query_filterAdditional filters for the query using metrics query syntax (for example, env, primary_tag).
resource_hashThe resource hash for exact matching.
resource_nameThe full name of a specific resource to filter by.
serviceThe service name to filter by.
span_kindDescribes the relationship between the span, its parents, and its children in a trace.
consumer, server, client, producer, internalstat [required]The APM metric statistic to query.
error_rate, errors, errors_per_second, hits, hits_per_second, apdex, latency_avg, latency_max, latency_p50, latency_p75Show 6 more
latency_p90, latency_p95, latency_p99, latency_p999, latency_distribution, total_time<data_source=apm_dependency_stats>A query for APM dependency statistics between services, such as call latency and error rates.
cross_org_uuidsOrganization UUIDs to query when using cross-organization visibility. Limited to one organization UUID.
data_source [required]A data source for APM dependency statistics queries.
apm_dependency_statsapm_dependency_statsenv [required]The environment to query.
is_upstreamDetermines whether stats for upstream or downstream dependencies should be queried.
name [required]The variable name for use in formulas.
operation_name [required]The APM operation name.
primary_tag_nameThe name of the second primary tag used within APM; required when primary_tag_value is specified. See https://docs.datadoghq.com/tracing/guide/setting_primary_tags_to_scope/#add-a-second-primary-tag-in-datadog.
primary_tag_valueFilter APM data by the second primary tag. primary_tag_name must also be specified.
resource_name [required]The resource name to filter by.
service [required]The service name to filter by.
stat [required]The APM dependency statistic to query.
avg_duration, avg_root_duration, avg_spans_per_trace, error_rate, pct_exec_time, pct_of_traces, total_traces_count<data_source=slo>A query for SLO status, error budget, and burn rate metrics.
additional_query_filtersAdditional filters applied to the SLO query.
cross_org_uuidsOrganization UUIDs to query when using cross-organization visibility. Limited to one organization UUID.
data_source [required]A data source for SLO queries.
sloslogroup_modeHow SLO results are grouped in the response.
overall, componentsmeasure [required]The SLO measurement to retrieve.
good_events, bad_events, slo_status, error_budget_remaining, error_budget_remaining_history, error_budget_burndown, burn_rate, slo_status_history, good_minutes, bad_minutesnameThe variable name for use in formulas.
slo_id [required]The unique identifier of the SLO to query.
slo_query_typeThe type of SLO definition being queried.
metric, time_slice, monitor<data_source=process>Per-process metrics from Live Processes over time, such as CPU and memory usage. To scope to one
process, set tag_filters to its identifying_tags from GET /api/v2/processes.
cross_org_uuidsOrganization UUIDs to query when using cross-organization visibility. Limited to one organization UUID.
data_source [required]A data source for process-level infrastructure metrics.
processprocessis_normalized_cpuWhether CPU metrics should be normalized by core count.
limitMaximum number of processes or groups to return. Large values can fail with an Unprocessable Content error. If so, retry with a smaller limit.
metric [required]The process metric to query, such as process.stat.cpu.total_pct, process.stat.memory.rss, or
process.stat.memory.vms.
name [required]The variable name for use in formulas.
sortDirection of sort.
descasc, desctag_filtersTags to narrow down processes. To scope to one process, use its identifying_tags from
GET /api/v2/processes, for example host:web-01 and pid:1234.
text_filterA full-text search filter to match process names or commands.
<data_source=container>A query for container-level metrics such as CPU and memory usage.
cross_org_uuidsOrganization UUIDs to query when using cross-organization visibility. Limited to one organization UUID.
data_source [required]A data source for container-level infrastructure metrics.
containercontaineris_normalized_cpuWhether CPU metrics should be normalized by core count.
limitMaximum number of results to return.
metric [required]The container metric to query.
name [required]The variable name for use in formulas.
sortDirection of sort.
descasc, desctag_filtersTag filters to narrow down containers.
text_filterA full-text search filter to match container names.
to [required]End date (exclusive) of the query in milliseconds since the Unix epoch.
type [required]The type of the resource. The value should always be timeseries_request.
timeseries_requesttimeseries_requestTimeseries cross product query returns "OK" response
{
"data": {
"attributes": {
"formulas": [
{
"formula": "a",
"limit": {
"count": 10,
"order": "desc"
}
}
],
"from": 1636625471000,
"interval": 5000,
"queries": [
{
"data_source": "metrics",
"query": "avg:datadog.estimated_usage.metrics.custom{*}",
"name": "a"
}
],
"to": 1636629071000
},
"type": "timeseries_request"
}
}Timeseries cross product query with RUM data source returns "OK" response
{
"data": {
"attributes": {
"formulas": [
{
"formula": "a",
"limit": {
"count": 10,
"order": "desc"
}
}
],
"from": 1636625471000,
"interval": 5000,
"queries": [
{
"data_source": "rum",
"name": "a",
"compute": {
"aggregation": "count"
},
"search": {
"query": "*"
},
"indexes": [
"*"
]
}
],
"to": 1636629071000
},
"type": "timeseries_request"
}
}Timeseries cross product query with apm_dependency_stats data source returns "OK" response
{
"data": {
"attributes": {
"formulas": [
{
"formula": "a",
"limit": {
"count": 10,
"order": "desc"
}
}
],
"from": 1636625471000,
"interval": 5000,
"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": "timeseries_request"
}
}Respuesta
OK
A message containing one response to a timeseries query made with timeseries formula query request.
dataA message containing the response to a timeseries query.
attributesThe object describing a timeseries response.
seriesArray of response series. The index here corresponds to the index in the formulas or queries array from the request.
group_tagsList of tags that apply to a single response value.
query_indexThe index of the query in the "formulas" array (or "queries" array if no "formulas" was specified).
unitDetailed information about the unit.
The first element describes the "primary unit" (for example, bytes in bytes per second).
The second element describes the "per unit" (for example, second in bytes per second).
If the second element is not present, the API returns null.
familyUnit family, allows for conversion between units of the same family, for scaling.
nameUnit name
pluralPlural form of the unit name.
scale_factorFactor for scaling between units of the same family.
short_nameAbbreviation of the unit.
timesArray of times, 1-1 match with individual values arrays.
valuesArray of value-arrays. The index here corresponds to the index in the formulas or queries array from the request.
typeThe type of the resource. The value should always be timeseries_response.
timeseries_responsetimeseries_responseerrorsThe error generated by the request.
{
"data": {
"attributes": {
"series": [
{
"group_tags": [
"env:production"
],
"query_index": 0,
"unit": [
{
"family": "time",
"name": "minute",
"plural": "minutes",
"scale_factor": 60,
"short_name": "min"
}
]
}
],
"times": [],
"values": [
1575317847,
0.5
]
},
"type": "timeseries_response"
},
"errors": "string"
}Bad Request
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Unauthorized
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Forbidden
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Ejemplo de código
Timeseries 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/timeseries" \
-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,
"interval": 5000,
"queries": [
{
"data_source": "metrics",
"query": "avg:datadog.estimated_usage.metrics.custom{*}",
"name": "a"
}
],
"to": 1636629071000
},
"type": "timeseries_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/timeseries" \
-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,
"interval": 5000,
"queries": [
{
"data_source": "metrics",
"query": "avg:datadog.estimated_usage.metrics.custom{*}",
"name": "a"
}
],
"to": 1636629071000
},
"type": "timeseries_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/timeseries" \
-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,
"interval": 5000,
"queries": [
{
"data_source": "metrics",
"query": "avg:datadog.estimated_usage.metrics.custom{*}",
"name": "a"
}
],
"to": 1636629071000
},
"type": "timeseries_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/timeseries" \
-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,
"interval": 5000,
"queries": [
{
"data_source": "metrics",
"query": "avg:datadog.estimated_usage.metrics.custom{*}",
"name": "a"
}
],
"to": 1636629071000
},
"type": "timeseries_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/timeseries" \
-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,
"interval": 5000,
"queries": [
{
"data_source": "metrics",
"query": "avg:datadog.estimated_usage.metrics.custom{*}",
"name": "a"
}
],
"to": 1636629071000
},
"type": "timeseries_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/timeseries" \
-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,
"interval": 5000,
"queries": [
{
"data_source": "metrics",
"query": "avg:datadog.estimated_usage.metrics.custom{*}",
"name": "a"
}
],
"to": 1636629071000
},
"type": "timeseries_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/timeseries" \
-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,
"interval": 5000,
"queries": [
{
"data_source": "metrics",
"query": "avg:datadog.estimated_usage.metrics.custom{*}",
"name": "a"
}
],
"to": 1636629071000
},
"type": "timeseries_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/timeseries" \
-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,
"interval": 5000,
"queries": [
{
"data_source": "metrics",
"query": "avg:datadog.estimated_usage.metrics.custom{*}",
"name": "a"
}
],
"to": 1636629071000
},
"type": "timeseries_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/timeseries" \
-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,
"interval": 5000,
"queries": [
{
"data_source": "metrics",
"query": "avg:datadog.estimated_usage.metrics.custom{*}",
"name": "a"
}
],
"to": 1636629071000
},
"type": "timeseries_request"
}
}
EOFTimeseries 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/timeseries" \
-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,
"interval": 5000,
"queries": [
{
"data_source": "rum",
"name": "a",
"compute": {
"aggregation": "count"
},
"search": {
"query": "*"
},
"indexes": [
"*"
]
}
],
"to": 1636629071000
},
"type": "timeseries_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/timeseries" \
-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,
"interval": 5000,
"queries": [
{
"data_source": "rum",
"name": "a",
"compute": {
"aggregation": "count"
},
"search": {
"query": "*"
},
"indexes": [
"*"
]
}
],
"to": 1636629071000
},
"type": "timeseries_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/timeseries" \
-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,
"interval": 5000,
"queries": [
{
"data_source": "rum",
"name": "a",
"compute": {
"aggregation": "count"
},
"search": {
"query": "*"
},
"indexes": [
"*"
]
}
],
"to": 1636629071000
},
"type": "timeseries_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/timeseries" \
-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,
"interval": 5000,
"queries": [
{
"data_source": "rum",
"name": "a",
"compute": {
"aggregation": "count"
},
"search": {
"query": "*"
},
"indexes": [
"*"
]
}
],
"to": 1636629071000
},
"type": "timeseries_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/timeseries" \
-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,
"interval": 5000,
"queries": [
{
"data_source": "rum",
"name": "a",
"compute": {
"aggregation": "count"
},
"search": {
"query": "*"
},
"indexes": [
"*"
]
}
],
"to": 1636629071000
},
"type": "timeseries_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/timeseries" \
-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,
"interval": 5000,
"queries": [
{
"data_source": "rum",
"name": "a",
"compute": {
"aggregation": "count"
},
"search": {
"query": "*"
},
"indexes": [
"*"
]
}
],
"to": 1636629071000
},
"type": "timeseries_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/timeseries" \
-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,
"interval": 5000,
"queries": [
{
"data_source": "rum",
"name": "a",
"compute": {
"aggregation": "count"
},
"search": {
"query": "*"
},
"indexes": [
"*"
]
}
],
"to": 1636629071000
},
"type": "timeseries_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/timeseries" \
-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,
"interval": 5000,
"queries": [
{
"data_source": "rum",
"name": "a",
"compute": {
"aggregation": "count"
},
"search": {
"query": "*"
},
"indexes": [
"*"
]
}
],
"to": 1636629071000
},
"type": "timeseries_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/timeseries" \
-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,
"interval": 5000,
"queries": [
{
"data_source": "rum",
"name": "a",
"compute": {
"aggregation": "count"
},
"search": {
"query": "*"
},
"indexes": [
"*"
]
}
],
"to": 1636629071000
},
"type": "timeseries_request"
}
}
EOFTimeseries 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/timeseries" \
-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,
"interval": 5000,
"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": "timeseries_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/timeseries" \
-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,
"interval": 5000,
"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": "timeseries_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/timeseries" \
-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,
"interval": 5000,
"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": "timeseries_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/timeseries" \
-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,
"interval": 5000,
"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": "timeseries_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/timeseries" \
-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,
"interval": 5000,
"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": "timeseries_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/timeseries" \
-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,
"interval": 5000,
"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": "timeseries_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/timeseries" \
-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,
"interval": 5000,
"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": "timeseries_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/timeseries" \
-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,
"interval": 5000,
"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": "timeseries_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/timeseries" \
-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,
"interval": 5000,
"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": "timeseries_request"
}
}
EOFTimeseries cross product query returns "OK" response
// Timeseries cross product query returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
body := datadogV2.TimeseriesFormulaQueryRequest{
Data: datadogV2.TimeseriesFormulaRequest{
Attributes: datadogV2.TimeseriesFormulaRequestAttributes{
Formulas: []datadogV2.QueryFormula{
{
Formula: "a",
Limit: &datadogV2.FormulaLimit{
Count: datadog.PtrInt32(10),
Order: datadogV2.QUERYSORTORDER_DESC.Ptr(),
},
},
},
From: 1636625471000,
Interval: datadog.PtrInt64(5000),
Queries: []datadogV2.TimeseriesQuery{
datadogV2.TimeseriesQuery{
MetricsTimeseriesQuery: &datadogV2.MetricsTimeseriesQuery{
DataSource: datadogV2.METRICSDATASOURCE_METRICS,
Query: "avg:datadog.estimated_usage.metrics.custom{*}",
Name: datadog.PtrString("a"),
}},
},
To: 1636629071000,
},
Type: datadogV2.TIMESERIESFORMULAREQUESTTYPE_TIMESERIES_REQUEST,
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewMetricsApi(apiClient)
resp, r, err := api.QueryTimeseriesData(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `MetricsApi.QueryTimeseriesData`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `MetricsApi.QueryTimeseriesData`:\n%s\n", responseContent)
}
Timeseries cross product query with RUM data source returns "OK" response
// Timeseries cross product query with RUM data source returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
body := datadogV2.TimeseriesFormulaQueryRequest{
Data: datadogV2.TimeseriesFormulaRequest{
Attributes: datadogV2.TimeseriesFormulaRequestAttributes{
Formulas: []datadogV2.QueryFormula{
{
Formula: "a",
Limit: &datadogV2.FormulaLimit{
Count: datadog.PtrInt32(10),
Order: datadogV2.QUERYSORTORDER_DESC.Ptr(),
},
},
},
From: 1636625471000,
Interval: datadog.PtrInt64(5000),
Queries: []datadogV2.TimeseriesQuery{
datadogV2.TimeseriesQuery{
EventsTimeseriesQuery: &datadogV2.EventsTimeseriesQuery{
DataSource: datadogV2.EVENTSDATASOURCE_RUM,
Name: datadog.PtrString("a"),
Compute: datadogV2.EventsCompute{
Aggregation: datadogV2.EVENTSAGGREGATION_COUNT,
},
Search: &datadogV2.EventsSearch{
Query: datadog.PtrString("*"),
},
Indexes: []string{
"*",
},
}},
},
To: 1636629071000,
},
Type: datadogV2.TIMESERIESFORMULAREQUESTTYPE_TIMESERIES_REQUEST,
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewMetricsApi(apiClient)
resp, r, err := api.QueryTimeseriesData(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `MetricsApi.QueryTimeseriesData`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `MetricsApi.QueryTimeseriesData`:\n%s\n", responseContent)
}
Timeseries cross product query with apm_dependency_stats data source returns "OK" response
// Timeseries cross product query with apm_dependency_stats data source returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
body := datadogV2.TimeseriesFormulaQueryRequest{
Data: datadogV2.TimeseriesFormulaRequest{
Attributes: datadogV2.TimeseriesFormulaRequestAttributes{
Formulas: []datadogV2.QueryFormula{
{
Formula: "a",
Limit: &datadogV2.FormulaLimit{
Count: datadog.PtrInt32(10),
Order: datadogV2.QUERYSORTORDER_DESC.Ptr(),
},
},
},
From: 1636625471000,
Interval: datadog.PtrInt64(5000),
Queries: []datadogV2.TimeseriesQuery{
datadogV2.TimeseriesQuery{
ApmDependencyStatsQuery: &datadogV2.ApmDependencyStatsQuery{
DataSource: datadogV2.APMDEPENDENCYSTATSDATASOURCE_APM_DEPENDENCY_STATS,
Name: "a",
Env: "ci",
Service: "cassandra",
Stat: datadogV2.APMDEPENDENCYSTATNAME_AVG_DURATION,
OperationName: "cassandra.query",
ResourceName: "DELETE FROM monitor_history.monitor_state_change_history WHERE org_id = ? AND monitor_id IN ? AND group = ?",
PrimaryTagName: datadog.PtrString("datacenter"),
PrimaryTagValue: datadog.PtrString("edge-eu1.prod.dog"),
}},
},
To: 1636629071000,
},
Type: datadogV2.TIMESERIESFORMULAREQUESTTYPE_TIMESERIES_REQUEST,
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewMetricsApi(apiClient)
resp, r, err := api.QueryTimeseriesData(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `MetricsApi.QueryTimeseriesData`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `MetricsApi.QueryTimeseriesData`:\n%s\n", responseContent)
}
Instructions
First install the library and its dependencies and then save the example to main.go and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"Timeseries cross product query returns "OK" response
// Timeseries cross product query returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.MetricsApi;
import com.datadog.api.client.v2.model.FormulaLimit;
import com.datadog.api.client.v2.model.MetricsDataSource;
import com.datadog.api.client.v2.model.MetricsTimeseriesQuery;
import com.datadog.api.client.v2.model.QueryFormula;
import com.datadog.api.client.v2.model.QuerySortOrder;
import com.datadog.api.client.v2.model.TimeseriesFormulaQueryRequest;
import com.datadog.api.client.v2.model.TimeseriesFormulaQueryResponse;
import com.datadog.api.client.v2.model.TimeseriesFormulaRequest;
import com.datadog.api.client.v2.model.TimeseriesFormulaRequestAttributes;
import com.datadog.api.client.v2.model.TimeseriesFormulaRequestType;
import com.datadog.api.client.v2.model.TimeseriesQuery;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
MetricsApi apiInstance = new MetricsApi(defaultClient);
TimeseriesFormulaQueryRequest body =
new TimeseriesFormulaQueryRequest()
.data(
new TimeseriesFormulaRequest()
.attributes(
new TimeseriesFormulaRequestAttributes()
.formulas(
Collections.singletonList(
new QueryFormula()
.formula("a")
.limit(
new FormulaLimit()
.count(10)
.order(QuerySortOrder.DESC))))
.from(1636625471000L)
.interval(5000L)
.queries(
Collections.singletonList(
new TimeseriesQuery(
new MetricsTimeseriesQuery()
.dataSource(MetricsDataSource.METRICS)
.query("avg:datadog.estimated_usage.metrics.custom{*}")
.name("a"))))
.to(1636629071000L))
.type(TimeseriesFormulaRequestType.TIMESERIES_REQUEST));
try {
TimeseriesFormulaQueryResponse result = apiInstance.queryTimeseriesData(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MetricsApi#queryTimeseriesData");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Timeseries cross product query with RUM data source returns "OK" response
// Timeseries cross product query with RUM data source returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.MetricsApi;
import com.datadog.api.client.v2.model.EventsAggregation;
import com.datadog.api.client.v2.model.EventsCompute;
import com.datadog.api.client.v2.model.EventsDataSource;
import com.datadog.api.client.v2.model.EventsSearch;
import com.datadog.api.client.v2.model.EventsTimeseriesQuery;
import com.datadog.api.client.v2.model.FormulaLimit;
import com.datadog.api.client.v2.model.QueryFormula;
import com.datadog.api.client.v2.model.QuerySortOrder;
import com.datadog.api.client.v2.model.TimeseriesFormulaQueryRequest;
import com.datadog.api.client.v2.model.TimeseriesFormulaQueryResponse;
import com.datadog.api.client.v2.model.TimeseriesFormulaRequest;
import com.datadog.api.client.v2.model.TimeseriesFormulaRequestAttributes;
import com.datadog.api.client.v2.model.TimeseriesFormulaRequestType;
import com.datadog.api.client.v2.model.TimeseriesQuery;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
MetricsApi apiInstance = new MetricsApi(defaultClient);
TimeseriesFormulaQueryRequest body =
new TimeseriesFormulaQueryRequest()
.data(
new TimeseriesFormulaRequest()
.attributes(
new TimeseriesFormulaRequestAttributes()
.formulas(
Collections.singletonList(
new QueryFormula()
.formula("a")
.limit(
new FormulaLimit()
.count(10)
.order(QuerySortOrder.DESC))))
.from(1636625471000L)
.interval(5000L)
.queries(
Collections.singletonList(
new TimeseriesQuery(
new EventsTimeseriesQuery()
.dataSource(EventsDataSource.RUM)
.name("a")
.compute(
new EventsCompute()
.aggregation(EventsAggregation.COUNT))
.search(new EventsSearch().query("*"))
.indexes(Collections.singletonList("*")))))
.to(1636629071000L))
.type(TimeseriesFormulaRequestType.TIMESERIES_REQUEST));
try {
TimeseriesFormulaQueryResponse result = apiInstance.queryTimeseriesData(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MetricsApi#queryTimeseriesData");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Timeseries cross product query with apm_dependency_stats data source returns "OK" response
// Timeseries cross product query with apm_dependency_stats data source returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.MetricsApi;
import com.datadog.api.client.v2.model.ApmDependencyStatName;
import com.datadog.api.client.v2.model.ApmDependencyStatsDataSource;
import com.datadog.api.client.v2.model.ApmDependencyStatsQuery;
import com.datadog.api.client.v2.model.FormulaLimit;
import com.datadog.api.client.v2.model.QueryFormula;
import com.datadog.api.client.v2.model.QuerySortOrder;
import com.datadog.api.client.v2.model.TimeseriesFormulaQueryRequest;
import com.datadog.api.client.v2.model.TimeseriesFormulaQueryResponse;
import com.datadog.api.client.v2.model.TimeseriesFormulaRequest;
import com.datadog.api.client.v2.model.TimeseriesFormulaRequestAttributes;
import com.datadog.api.client.v2.model.TimeseriesFormulaRequestType;
import com.datadog.api.client.v2.model.TimeseriesQuery;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
MetricsApi apiInstance = new MetricsApi(defaultClient);
TimeseriesFormulaQueryRequest body =
new TimeseriesFormulaQueryRequest()
.data(
new TimeseriesFormulaRequest()
.attributes(
new TimeseriesFormulaRequestAttributes()
.formulas(
Collections.singletonList(
new QueryFormula()
.formula("a")
.limit(
new FormulaLimit()
.count(10)
.order(QuerySortOrder.DESC))))
.from(1636625471000L)
.interval(5000L)
.queries(
Collections.singletonList(
new TimeseriesQuery(
new ApmDependencyStatsQuery()
.dataSource(
ApmDependencyStatsDataSource.APM_DEPENDENCY_STATS)
.name("a")
.env("ci")
.service("cassandra")
.stat(ApmDependencyStatName.AVG_DURATION)
.operationName("cassandra.query")
.resourceName(
"DELETE FROM"
+ " monitor_history.monitor_state_change_history"
+ " WHERE org_id = ? AND monitor_id IN ? AND"
+ " group = ?")
.primaryTagName("datacenter")
.primaryTagValue("edge-eu1.prod.dog"))))
.to(1636629071000L))
.type(TimeseriesFormulaRequestType.TIMESERIES_REQUEST));
try {
TimeseriesFormulaQueryResponse result = apiInstance.queryTimeseriesData(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MetricsApi#queryTimeseriesData");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Instructions
First install the library and its dependencies and then save the example to Example.java and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"Timeseries cross product query returns "OK" response
"""
Timeseries cross product query returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.metrics_api import MetricsApi
from datadog_api_client.v2.model.formula_limit import FormulaLimit
from datadog_api_client.v2.model.metrics_data_source import MetricsDataSource
from datadog_api_client.v2.model.metrics_timeseries_query import MetricsTimeseriesQuery
from datadog_api_client.v2.model.query_formula import QueryFormula
from datadog_api_client.v2.model.query_sort_order import QuerySortOrder
from datadog_api_client.v2.model.timeseries_formula_query_request import TimeseriesFormulaQueryRequest
from datadog_api_client.v2.model.timeseries_formula_request import TimeseriesFormulaRequest
from datadog_api_client.v2.model.timeseries_formula_request_attributes import TimeseriesFormulaRequestAttributes
from datadog_api_client.v2.model.timeseries_formula_request_queries import TimeseriesFormulaRequestQueries
from datadog_api_client.v2.model.timeseries_formula_request_type import TimeseriesFormulaRequestType
body = TimeseriesFormulaQueryRequest(
data=TimeseriesFormulaRequest(
attributes=TimeseriesFormulaRequestAttributes(
formulas=[
QueryFormula(
formula="a",
limit=FormulaLimit(
count=10,
order=QuerySortOrder.DESC,
),
),
],
_from=1636625471000,
interval=5000,
queries=TimeseriesFormulaRequestQueries(
[
MetricsTimeseriesQuery(
data_source=MetricsDataSource.METRICS,
query="avg:datadog.estimated_usage.metrics.custom{*}",
name="a",
),
]
),
to=1636629071000,
),
type=TimeseriesFormulaRequestType.TIMESERIES_REQUEST,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = MetricsApi(api_client)
response = api_instance.query_timeseries_data(body=body)
print(response)
Timeseries cross product query with RUM data source returns "OK" response
"""
Timeseries cross product query with RUM data source returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.metrics_api import MetricsApi
from datadog_api_client.v2.model.events_aggregation import EventsAggregation
from datadog_api_client.v2.model.events_compute import EventsCompute
from datadog_api_client.v2.model.events_data_source import EventsDataSource
from datadog_api_client.v2.model.events_search import EventsSearch
from datadog_api_client.v2.model.events_timeseries_query import EventsTimeseriesQuery
from datadog_api_client.v2.model.formula_limit import FormulaLimit
from datadog_api_client.v2.model.query_formula import QueryFormula
from datadog_api_client.v2.model.query_sort_order import QuerySortOrder
from datadog_api_client.v2.model.timeseries_formula_query_request import TimeseriesFormulaQueryRequest
from datadog_api_client.v2.model.timeseries_formula_request import TimeseriesFormulaRequest
from datadog_api_client.v2.model.timeseries_formula_request_attributes import TimeseriesFormulaRequestAttributes
from datadog_api_client.v2.model.timeseries_formula_request_queries import TimeseriesFormulaRequestQueries
from datadog_api_client.v2.model.timeseries_formula_request_type import TimeseriesFormulaRequestType
body = TimeseriesFormulaQueryRequest(
data=TimeseriesFormulaRequest(
attributes=TimeseriesFormulaRequestAttributes(
formulas=[
QueryFormula(
formula="a",
limit=FormulaLimit(
count=10,
order=QuerySortOrder.DESC,
),
),
],
_from=1636625471000,
interval=5000,
queries=TimeseriesFormulaRequestQueries(
[
EventsTimeseriesQuery(
data_source=EventsDataSource.RUM,
name="a",
compute=EventsCompute(
aggregation=EventsAggregation.COUNT,
),
search=EventsSearch(
query="*",
),
indexes=[
"*",
],
),
]
),
to=1636629071000,
),
type=TimeseriesFormulaRequestType.TIMESERIES_REQUEST,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = MetricsApi(api_client)
response = api_instance.query_timeseries_data(body=body)
print(response)
Timeseries cross product query with apm_dependency_stats data source returns "OK" response
"""
Timeseries cross product query with apm_dependency_stats data source returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.metrics_api import MetricsApi
from datadog_api_client.v2.model.apm_dependency_stat_name import ApmDependencyStatName
from datadog_api_client.v2.model.apm_dependency_stats_data_source import ApmDependencyStatsDataSource
from datadog_api_client.v2.model.apm_dependency_stats_query import ApmDependencyStatsQuery
from datadog_api_client.v2.model.formula_limit import FormulaLimit
from datadog_api_client.v2.model.query_formula import QueryFormula
from datadog_api_client.v2.model.query_sort_order import QuerySortOrder
from datadog_api_client.v2.model.timeseries_formula_query_request import TimeseriesFormulaQueryRequest
from datadog_api_client.v2.model.timeseries_formula_request import TimeseriesFormulaRequest
from datadog_api_client.v2.model.timeseries_formula_request_attributes import TimeseriesFormulaRequestAttributes
from datadog_api_client.v2.model.timeseries_formula_request_queries import TimeseriesFormulaRequestQueries
from datadog_api_client.v2.model.timeseries_formula_request_type import TimeseriesFormulaRequestType
body = TimeseriesFormulaQueryRequest(
data=TimeseriesFormulaRequest(
attributes=TimeseriesFormulaRequestAttributes(
formulas=[
QueryFormula(
formula="a",
limit=FormulaLimit(
count=10,
order=QuerySortOrder.DESC,
),
),
],
_from=1636625471000,
interval=5000,
queries=TimeseriesFormulaRequestQueries(
[
ApmDependencyStatsQuery(
data_source=ApmDependencyStatsDataSource.APM_DEPENDENCY_STATS,
name="a",
env="ci",
service="cassandra",
stat=ApmDependencyStatName.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=TimeseriesFormulaRequestType.TIMESERIES_REQUEST,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = MetricsApi(api_client)
response = api_instance.query_timeseries_data(body=body)
print(response)
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"Timeseries cross product query returns "OK" response
# Timeseries cross product query returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::MetricsAPI.new
body = DatadogAPIClient::V2::TimeseriesFormulaQueryRequest.new({
data: DatadogAPIClient::V2::TimeseriesFormulaRequest.new({
attributes: DatadogAPIClient::V2::TimeseriesFormulaRequestAttributes.new({
formulas: [
DatadogAPIClient::V2::QueryFormula.new({
formula: "a",
limit: DatadogAPIClient::V2::FormulaLimit.new({
count: 10,
order: DatadogAPIClient::V2::QuerySortOrder::DESC,
}),
}),
],
from: 1636625471000,
interval: 5000,
queries: [
DatadogAPIClient::V2::MetricsTimeseriesQuery.new({
data_source: DatadogAPIClient::V2::MetricsDataSource::METRICS,
query: "avg:datadog.estimated_usage.metrics.custom{*}",
name: "a",
}),
],
to: 1636629071000,
}),
type: DatadogAPIClient::V2::TimeseriesFormulaRequestType::TIMESERIES_REQUEST,
}),
})
p api_instance.query_timeseries_data(body)
Timeseries cross product query with RUM data source returns "OK" response
# Timeseries cross product query with RUM data source returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::MetricsAPI.new
body = DatadogAPIClient::V2::TimeseriesFormulaQueryRequest.new({
data: DatadogAPIClient::V2::TimeseriesFormulaRequest.new({
attributes: DatadogAPIClient::V2::TimeseriesFormulaRequestAttributes.new({
formulas: [
DatadogAPIClient::V2::QueryFormula.new({
formula: "a",
limit: DatadogAPIClient::V2::FormulaLimit.new({
count: 10,
order: DatadogAPIClient::V2::QuerySortOrder::DESC,
}),
}),
],
from: 1636625471000,
interval: 5000,
queries: [
DatadogAPIClient::V2::EventsTimeseriesQuery.new({
data_source: DatadogAPIClient::V2::EventsDataSource::RUM,
name: "a",
compute: DatadogAPIClient::V2::EventsCompute.new({
aggregation: DatadogAPIClient::V2::EventsAggregation::COUNT,
}),
search: DatadogAPIClient::V2::EventsSearch.new({
query: "*",
}),
indexes: [
"*",
],
}),
],
to: 1636629071000,
}),
type: DatadogAPIClient::V2::TimeseriesFormulaRequestType::TIMESERIES_REQUEST,
}),
})
p api_instance.query_timeseries_data(body)
Timeseries cross product query with apm_dependency_stats data source returns "OK" response
# Timeseries cross product query with apm_dependency_stats data source returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::MetricsAPI.new
body = DatadogAPIClient::V2::TimeseriesFormulaQueryRequest.new({
data: DatadogAPIClient::V2::TimeseriesFormulaRequest.new({
attributes: DatadogAPIClient::V2::TimeseriesFormulaRequestAttributes.new({
formulas: [
DatadogAPIClient::V2::QueryFormula.new({
formula: "a",
limit: DatadogAPIClient::V2::FormulaLimit.new({
count: 10,
order: DatadogAPIClient::V2::QuerySortOrder::DESC,
}),
}),
],
from: 1636625471000,
interval: 5000,
queries: [
DatadogAPIClient::V2::ApmDependencyStatsQuery.new({
data_source: DatadogAPIClient::V2::ApmDependencyStatsDataSource::APM_DEPENDENCY_STATS,
name: "a",
env: "ci",
service: "cassandra",
stat: DatadogAPIClient::V2::ApmDependencyStatName::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: DatadogAPIClient::V2::TimeseriesFormulaRequestType::TIMESERIES_REQUEST,
}),
})
p api_instance.query_timeseries_data(body)
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"Timeseries cross product query returns "OK" response
// Timeseries cross product query returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;
use datadog_api_client::datadogV2::model::FormulaLimit;
use datadog_api_client::datadogV2::model::MetricsDataSource;
use datadog_api_client::datadogV2::model::MetricsTimeseriesQuery;
use datadog_api_client::datadogV2::model::QueryFormula;
use datadog_api_client::datadogV2::model::QuerySortOrder;
use datadog_api_client::datadogV2::model::TimeseriesFormulaQueryRequest;
use datadog_api_client::datadogV2::model::TimeseriesFormulaRequest;
use datadog_api_client::datadogV2::model::TimeseriesFormulaRequestAttributes;
use datadog_api_client::datadogV2::model::TimeseriesFormulaRequestType;
use datadog_api_client::datadogV2::model::TimeseriesQuery;
#[tokio::main]
async fn main() {
let body = TimeseriesFormulaQueryRequest::new(TimeseriesFormulaRequest::new(
TimeseriesFormulaRequestAttributes::new(
1636625471000,
vec![TimeseriesQuery::MetricsTimeseriesQuery(Box::new(
MetricsTimeseriesQuery::new(
MetricsDataSource::METRICS,
"avg:datadog.estimated_usage.metrics.custom{*}".to_string(),
)
.name("a".to_string()),
))],
1636629071000,
)
.formulas(vec![QueryFormula::new("a".to_string())
.limit(FormulaLimit::new().count(10).order(QuerySortOrder::DESC))])
.interval(5000),
TimeseriesFormulaRequestType::TIMESERIES_REQUEST,
));
let configuration = datadog::Configuration::new();
let api = MetricsAPI::with_config(configuration);
let resp = api.query_timeseries_data(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Timeseries cross product query with RUM data source returns "OK" response
// Timeseries cross product query with RUM data source returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;
use datadog_api_client::datadogV2::model::EventsAggregation;
use datadog_api_client::datadogV2::model::EventsCompute;
use datadog_api_client::datadogV2::model::EventsDataSource;
use datadog_api_client::datadogV2::model::EventsSearch;
use datadog_api_client::datadogV2::model::EventsTimeseriesQuery;
use datadog_api_client::datadogV2::model::FormulaLimit;
use datadog_api_client::datadogV2::model::QueryFormula;
use datadog_api_client::datadogV2::model::QuerySortOrder;
use datadog_api_client::datadogV2::model::TimeseriesFormulaQueryRequest;
use datadog_api_client::datadogV2::model::TimeseriesFormulaRequest;
use datadog_api_client::datadogV2::model::TimeseriesFormulaRequestAttributes;
use datadog_api_client::datadogV2::model::TimeseriesFormulaRequestType;
use datadog_api_client::datadogV2::model::TimeseriesQuery;
#[tokio::main]
async fn main() {
let body = TimeseriesFormulaQueryRequest::new(TimeseriesFormulaRequest::new(
TimeseriesFormulaRequestAttributes::new(
1636625471000,
vec![TimeseriesQuery::EventsTimeseriesQuery(Box::new(
EventsTimeseriesQuery::new(
EventsCompute::new(EventsAggregation::COUNT),
EventsDataSource::RUM,
)
.indexes(vec!["*".to_string()])
.name("a".to_string())
.search(EventsSearch::new().query("*".to_string())),
))],
1636629071000,
)
.formulas(vec![QueryFormula::new("a".to_string())
.limit(FormulaLimit::new().count(10).order(QuerySortOrder::DESC))])
.interval(5000),
TimeseriesFormulaRequestType::TIMESERIES_REQUEST,
));
let configuration = datadog::Configuration::new();
let api = MetricsAPI::with_config(configuration);
let resp = api.query_timeseries_data(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Timeseries cross product query with apm_dependency_stats data source returns "OK" response
// Timeseries cross product query with apm_dependency_stats data source returns
// "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;
use datadog_api_client::datadogV2::model::ApmDependencyStatName;
use datadog_api_client::datadogV2::model::ApmDependencyStatsDataSource;
use datadog_api_client::datadogV2::model::ApmDependencyStatsQuery;
use datadog_api_client::datadogV2::model::FormulaLimit;
use datadog_api_client::datadogV2::model::QueryFormula;
use datadog_api_client::datadogV2::model::QuerySortOrder;
use datadog_api_client::datadogV2::model::TimeseriesFormulaQueryRequest;
use datadog_api_client::datadogV2::model::TimeseriesFormulaRequest;
use datadog_api_client::datadogV2::model::TimeseriesFormulaRequestAttributes;
use datadog_api_client::datadogV2::model::TimeseriesFormulaRequestType;
use datadog_api_client::datadogV2::model::TimeseriesQuery;
#[tokio::main]
async fn main() {
let body =
TimeseriesFormulaQueryRequest::new(
TimeseriesFormulaRequest::new(
TimeseriesFormulaRequestAttributes::new(
1636625471000,
vec![
TimeseriesQuery::ApmDependencyStatsQuery(
Box::new(
ApmDependencyStatsQuery::new(
ApmDependencyStatsDataSource::APM_DEPENDENCY_STATS,
"ci".to_string(),
"a".to_string(),
"cassandra.query".to_string(),
"DELETE FROM monitor_history.monitor_state_change_history WHERE org_id = ? AND monitor_id IN ? AND group = ?".to_string(),
"cassandra".to_string(),
ApmDependencyStatName::AVG_DURATION,
)
.primary_tag_name("datacenter".to_string())
.primary_tag_value("edge-eu1.prod.dog".to_string()),
),
)
],
1636629071000,
)
.formulas(
vec![
QueryFormula::new(
"a".to_string(),
).limit(FormulaLimit::new().count(10).order(QuerySortOrder::DESC))
],
)
.interval(5000),
TimeseriesFormulaRequestType::TIMESERIES_REQUEST,
),
);
let configuration = datadog::Configuration::new();
let api = MetricsAPI::with_config(configuration);
let resp = api.query_timeseries_data(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Instructions
First install the library and its dependencies and then save the example to src/main.rs and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runTimeseries cross product query returns "OK" response
/**
* Timeseries cross product query returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
const apiInstance = new v2.MetricsApi(configuration);
const params: v2.MetricsApiQueryTimeseriesDataRequest = {
body: {
data: {
attributes: {
formulas: [
{
formula: "a",
limit: {
count: 10,
order: "desc",
},
},
],
from: 1636625471000,
interval: 5000,
queries: [
{
dataSource: "metrics",
query: "avg:datadog.estimated_usage.metrics.custom{*}",
name: "a",
},
],
to: 1636629071000,
},
type: "timeseries_request",
},
},
};
apiInstance
.queryTimeseriesData(params)
.then((data: v2.TimeseriesFormulaQueryResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Timeseries cross product query with RUM data source returns "OK" response
/**
* Timeseries cross product query with RUM data source returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
const apiInstance = new v2.MetricsApi(configuration);
const params: v2.MetricsApiQueryTimeseriesDataRequest = {
body: {
data: {
attributes: {
formulas: [
{
formula: "a",
limit: {
count: 10,
order: "desc",
},
},
],
from: 1636625471000,
interval: 5000,
queries: [
{
dataSource: "rum",
name: "a",
compute: {
aggregation: "count",
},
search: {
query: "*",
},
indexes: ["*"],
},
],
to: 1636629071000,
},
type: "timeseries_request",
},
},
};
apiInstance
.queryTimeseriesData(params)
.then((data: v2.TimeseriesFormulaQueryResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Timeseries cross product query with apm_dependency_stats data source returns "OK" response
/**
* Timeseries cross product query with apm_dependency_stats data source returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
const apiInstance = new v2.MetricsApi(configuration);
const params: v2.MetricsApiQueryTimeseriesDataRequest = {
body: {
data: {
attributes: {
formulas: [
{
formula: "a",
limit: {
count: 10,
order: "desc",
},
},
],
from: 1636625471000,
interval: 5000,
queries: [
{
dataSource: "apm_dependency_stats",
name: "a",
env: "ci",
service: "cassandra",
stat: "avg_duration",
operationName: "cassandra.query",
resourceName:
"DELETE FROM monitor_history.monitor_state_change_history WHERE org_id = ? AND monitor_id IN ? AND group = ?",
primaryTagName: "datacenter",
primaryTagValue: "edge-eu1.prod.dog",
},
],
to: 1636629071000,
},
type: "timeseries_request",
},
},
};
apiInstance
.queryTimeseriesData(params)
.then((data: v2.TimeseriesFormulaQueryResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Instructions
First install the library and its dependencies and then save the example to example.ts and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"