Compute timeseries analytics
https://api.datadoghq.com/api/v2/product-analytics/analytics/timeserieshttps://api.us3.datadoghq.com/api/v2/product-analytics/analytics/timeserieshttps://api.us5.datadoghq.com/api/v2/product-analytics/analytics/timeserieshttps://api.datadoghq.eu/api/v2/product-analytics/analytics/timeserieshttps://api.ap1.datadoghq.com/api/v2/product-analytics/analytics/timeserieshttps://api.ap2.datadoghq.com/api/v2/product-analytics/analytics/timeserieshttps://api.uk1.datadoghq.com/api/v2/product-analytics/analytics/timeserieshttps://api.ddog-gov.com/api/v2/product-analytics/analytics/timeserieshttps://api.us2.ddog-gov.com/api/v2/product-analytics/analytics/timeseriesOverview
Compute timeseries analytics results for Product Analytics data.
Returns time-bucketed values for charts and trend analysis.
The compute.interval field (milliseconds) is required for time bucketing.
Request
Body Data (required)
data [required]Data object for an analytics request.
attributes [required]Attributes for an analytics request.
enforced_execution_typeDEPRECATED Deprecated. Selects the internal query execution infrastructure and will be removed. Do not set this field.
simple, background, trino-multistep, materialized-viewfrom [required]Start time in epoch milliseconds. Must be less than to.
query [required]The analytics query definition containing a base query, compute rule, and optional grouping.
audience_filtersAudience filter definitions for targeting specific user segments.
accountsAccount audience queries.
name [required]Name of this query, referenced in the formula.
querySearch query for filtering accounts.
formulaBoolean formula combining audience queries by name.
segmentsSegment audience queries.
name [required]Name of this query, referenced in the formula.
segment_id [required]UUID of the segment to filter by.
usersUser audience queries.
name [required]Name of this query, referenced in the formula.
querySearch query for filtering users.
compute [required]A compute rule for aggregating data.
aggregation [required]The aggregation function (count, cardinality, avg, sum, min, max, etc.).
intervalTime bucket size in milliseconds. Required for timeseries queries; ignored by the scalar endpoint, which returns a single value.
metricThe metric to aggregate on. Required for non-count aggregations.
group_byGroup-by rules for segmenting results.
facet [required]The facet to group by.
limitMaximum number of groups to return.
should_exclude_missingExclude results with missing facet values.
falsesortSort configuration for group-by results.
aggregationThe aggregation function to sort by.
metricThe metric to sort by.
orderDirection of sort.
descasc, descsourceThe source for audience-filter-based group-by.
indexesDEPRECATED Deprecated. Index selection is a rollout detail and will be removed. Do not set this field.
query [required]A query definition discriminated by the data_source field.
Use product_analytics for standard event queries, or
product_analytics_occurrence for occurrence-filtered queries.
<data_source=product_analytics>A standard Product Analytics event query.
data_source [required]The data source identifier.
product_analyticssearch [required]Search parameters for an event query.
queryThe search query using Datadog search syntax.
<data_source=product_analytics_occurrence>A Product Analytics occurrence-filtered query.
data_source [required]The data source identifier for occurrence queries.
product_analytics_occurrencesearch [required]Search parameters for an occurrence query.
occurrencesFilter for occurrence-based queries.
metaAdditional metadata.
<any-key>operator [required]Comparison operator (=, >=, <=, >, <).
value [required]The occurrence count threshold as a string.
queryThe search query using Datadog search syntax.
request_idUnique identifier of the query.
to [required]End time in epoch milliseconds.
type [required]The resource type for analytics requests.
formula_analytics_extended_request{
"data": {
"attributes": {
"enforced_execution_type": "string",
"from": 1771232048460,
"query": {
"audience_filters": {
"accounts": [
{
"name": "",
"query": "string"
}
],
"formula": "u",
"segments": [
{
"name": "",
"segment_id": "00000000-0000-0000-0000-000000000000"
}
],
"users": [
{
"name": "u",
"query": "*"
}
]
},
"compute": {
"aggregation": "count",
"interval": 3600000,
"metric": "@session.time_spent"
},
"group_by": [
{
"facet": "@view.name",
"limit": 10,
"should_exclude_missing": false,
"sort": {
"aggregation": "count",
"metric": "string",
"order": "string"
},
"source": "string"
}
],
"indexes": [],
"query": {
"data_source": "product_analytics",
"search": {
"query": "@type:view"
}
}
},
"request_id": "string",
"to": 1771836848262
},
"type": "formula_analytics_extended_request"
}
}Response
OK
Response for a timeseries analytics query.
dataData object for a timeseries analytics response.
attributesAttributes of a timeseries analytics response, containing series data, timestamps, and interval definitions.
intervalsInterval definitions describing the time buckets used in the response.
millisecondsThe duration of each time bucket in milliseconds.
start_timeThe start of this interval as an epoch timestamp in milliseconds.
timesEpoch timestamps (in milliseconds) for each bucket in this interval.
typeThe interval type (e.g., fixed or auto-computed bucket size).
seriesThe list of series, each corresponding to a query or group-by combination.
group_tagsThe group-by tag values that identify this series.
query_indexThe index of the query that produced this series.
unitUnit definitions for the series values.
familyThe unit family (e.g., time, bytes).
idNumeric identifier for the unit.
nameThe full name of the unit (e.g., nanosecond).
pluralPlural form of the unit name (e.g., nanoseconds).
scale_factorConversion factor relative to the base unit of the family.
short_nameAbbreviated unit name (e.g., ns).
timesTimestamps for each data point (epoch milliseconds).
valuesValues for each series at each time point.
idUnique identifier for this response data object.
typeThe resource type identifier for a timeseries analytics response.
timeseries_responsemetaMetadata for a Product Analytics query response.
request_idUnique identifier of the query.
statusThe execution status of a Product Analytics query.
done, running, timeout{
"data": {
"attributes": {
"intervals": [
{
"milliseconds": "integer",
"start_time": "integer",
"times": [],
"type": "string"
}
],
"series": [
{
"group_tags": [],
"query_index": "integer",
"unit": [
{
"family": "time",
"id": "integer",
"name": "nanosecond",
"plural": "string",
"scale_factor": "number",
"short_name": "string"
}
]
}
],
"times": [],
"values": []
},
"id": "string",
"type": "string"
},
"meta": {
"request_id": "string",
"status": "string"
}
}Bad Request
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Not Authorized
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"
]
}Code Example
# 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/product-analytics/analytics/timeseries" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"from": 1771232048460,
"query": {
"compute": {
"aggregation": "count"
},
"query": {
"data_source": "product_analytics",
"search": {
"query": "@type:view"
}
}
},
"to": 1771836848262
},
"type": "formula_analytics_extended_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/product-analytics/analytics/timeseries" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"from": 1771232048460,
"query": {
"compute": {
"aggregation": "count"
},
"query": {
"data_source": "product_analytics",
"search": {
"query": "@type:view"
}
}
},
"to": 1771836848262
},
"type": "formula_analytics_extended_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/product-analytics/analytics/timeseries" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"from": 1771232048460,
"query": {
"compute": {
"aggregation": "count"
},
"query": {
"data_source": "product_analytics",
"search": {
"query": "@type:view"
}
}
},
"to": 1771836848262
},
"type": "formula_analytics_extended_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/product-analytics/analytics/timeseries" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"from": 1771232048460,
"query": {
"compute": {
"aggregation": "count"
},
"query": {
"data_source": "product_analytics",
"search": {
"query": "@type:view"
}
}
},
"to": 1771836848262
},
"type": "formula_analytics_extended_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/product-analytics/analytics/timeseries" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"from": 1771232048460,
"query": {
"compute": {
"aggregation": "count"
},
"query": {
"data_source": "product_analytics",
"search": {
"query": "@type:view"
}
}
},
"to": 1771836848262
},
"type": "formula_analytics_extended_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/product-analytics/analytics/timeseries" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"from": 1771232048460,
"query": {
"compute": {
"aggregation": "count"
},
"query": {
"data_source": "product_analytics",
"search": {
"query": "@type:view"
}
}
},
"to": 1771836848262
},
"type": "formula_analytics_extended_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/product-analytics/analytics/timeseries" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"from": 1771232048460,
"query": {
"compute": {
"aggregation": "count"
},
"query": {
"data_source": "product_analytics",
"search": {
"query": "@type:view"
}
}
},
"to": 1771836848262
},
"type": "formula_analytics_extended_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/product-analytics/analytics/timeseries" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"from": 1771232048460,
"query": {
"compute": {
"aggregation": "count"
},
"query": {
"data_source": "product_analytics",
"search": {
"query": "@type:view"
}
}
},
"to": 1771836848262
},
"type": "formula_analytics_extended_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/product-analytics/analytics/timeseries" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"from": 1771232048460,
"query": {
"compute": {
"aggregation": "count"
},
"query": {
"data_source": "product_analytics",
"search": {
"query": "@type:view"
}
}
},
"to": 1771836848262
},
"type": "formula_analytics_extended_request"
}
}
EOF// Compute timeseries analytics 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.ProductAnalyticsAnalyticsRequest{
Data: datadogV2.ProductAnalyticsAnalyticsRequestData{
Attributes: datadogV2.ProductAnalyticsAnalyticsRequestAttributes{
From: 1771232048460,
Query: datadogV2.ProductAnalyticsAnalyticsQuery{
Compute: datadogV2.ProductAnalyticsCompute{
Aggregation: "count",
},
Query: datadogV2.ProductAnalyticsBaseQuery{
ProductAnalyticsEventQuery: &datadogV2.ProductAnalyticsEventQuery{
DataSource: datadogV2.PRODUCTANALYTICSEVENTQUERYDATASOURCE_PRODUCT_ANALYTICS,
Search: datadogV2.ProductAnalyticsEventSearch{
Query: datadog.PtrString("@type:view"),
},
}},
},
To: 1771836848262,
},
Type: datadogV2.PRODUCTANALYTICSANALYTICSREQUESTTYPE_FORMULA_ANALYTICS_EXTENDED_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.NewProductAnalyticsApi(apiClient)
resp, r, err := api.QueryProductAnalyticsTimeseries(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `ProductAnalyticsApi.QueryProductAnalyticsTimeseries`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `ProductAnalyticsApi.QueryProductAnalyticsTimeseries`:\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"// Compute timeseries analytics returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.ProductAnalyticsApi;
import com.datadog.api.client.v2.model.ProductAnalyticsAnalyticsQuery;
import com.datadog.api.client.v2.model.ProductAnalyticsAnalyticsRequest;
import com.datadog.api.client.v2.model.ProductAnalyticsAnalyticsRequestAttributes;
import com.datadog.api.client.v2.model.ProductAnalyticsAnalyticsRequestData;
import com.datadog.api.client.v2.model.ProductAnalyticsAnalyticsRequestType;
import com.datadog.api.client.v2.model.ProductAnalyticsBaseQuery;
import com.datadog.api.client.v2.model.ProductAnalyticsCompute;
import com.datadog.api.client.v2.model.ProductAnalyticsEventQuery;
import com.datadog.api.client.v2.model.ProductAnalyticsEventQueryDataSource;
import com.datadog.api.client.v2.model.ProductAnalyticsEventSearch;
import com.datadog.api.client.v2.model.ProductAnalyticsTimeseriesResponse;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
ProductAnalyticsApi apiInstance = new ProductAnalyticsApi(defaultClient);
ProductAnalyticsAnalyticsRequest body =
new ProductAnalyticsAnalyticsRequest()
.data(
new ProductAnalyticsAnalyticsRequestData()
.attributes(
new ProductAnalyticsAnalyticsRequestAttributes()
.from(1771232048460L)
.query(
new ProductAnalyticsAnalyticsQuery()
.compute(new ProductAnalyticsCompute().aggregation("count"))
.query(
new ProductAnalyticsBaseQuery(
new ProductAnalyticsEventQuery()
.dataSource(
ProductAnalyticsEventQueryDataSource
.PRODUCT_ANALYTICS)
.search(
new ProductAnalyticsEventSearch()
.query("@type:view")))))
.to(1771836848262L))
.type(ProductAnalyticsAnalyticsRequestType.FORMULA_ANALYTICS_EXTENDED_REQUEST));
try {
ProductAnalyticsTimeseriesResponse result = apiInstance.queryProductAnalyticsTimeseries(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println(
"Exception when calling ProductAnalyticsApi#queryProductAnalyticsTimeseries");
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""""
Compute timeseries analytics returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.product_analytics_api import ProductAnalyticsApi
from datadog_api_client.v2.model.product_analytics_analytics_query import ProductAnalyticsAnalyticsQuery
from datadog_api_client.v2.model.product_analytics_analytics_request import ProductAnalyticsAnalyticsRequest
from datadog_api_client.v2.model.product_analytics_analytics_request_attributes import (
ProductAnalyticsAnalyticsRequestAttributes,
)
from datadog_api_client.v2.model.product_analytics_analytics_request_data import ProductAnalyticsAnalyticsRequestData
from datadog_api_client.v2.model.product_analytics_analytics_request_type import ProductAnalyticsAnalyticsRequestType
from datadog_api_client.v2.model.product_analytics_compute import ProductAnalyticsCompute
from datadog_api_client.v2.model.product_analytics_event_query import ProductAnalyticsEventQuery
from datadog_api_client.v2.model.product_analytics_event_query_data_source import ProductAnalyticsEventQueryDataSource
from datadog_api_client.v2.model.product_analytics_event_search import ProductAnalyticsEventSearch
body = ProductAnalyticsAnalyticsRequest(
data=ProductAnalyticsAnalyticsRequestData(
attributes=ProductAnalyticsAnalyticsRequestAttributes(
_from=1771232048460,
query=ProductAnalyticsAnalyticsQuery(
compute=ProductAnalyticsCompute(
aggregation="count",
),
query=ProductAnalyticsEventQuery(
data_source=ProductAnalyticsEventQueryDataSource.PRODUCT_ANALYTICS,
search=ProductAnalyticsEventSearch(
query="@type:view",
),
),
),
to=1771836848262,
),
type=ProductAnalyticsAnalyticsRequestType.FORMULA_ANALYTICS_EXTENDED_REQUEST,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = ProductAnalyticsApi(api_client)
response = api_instance.query_product_analytics_timeseries(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"# Compute timeseries analytics returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::ProductAnalyticsAPI.new
body = DatadogAPIClient::V2::ProductAnalyticsAnalyticsRequest.new({
data: DatadogAPIClient::V2::ProductAnalyticsAnalyticsRequestData.new({
attributes: DatadogAPIClient::V2::ProductAnalyticsAnalyticsRequestAttributes.new({
from: 1771232048460,
query: DatadogAPIClient::V2::ProductAnalyticsAnalyticsQuery.new({
compute: DatadogAPIClient::V2::ProductAnalyticsCompute.new({
aggregation: "count",
}),
query: DatadogAPIClient::V2::ProductAnalyticsEventQuery.new({
data_source: DatadogAPIClient::V2::ProductAnalyticsEventQueryDataSource::PRODUCT_ANALYTICS,
search: DatadogAPIClient::V2::ProductAnalyticsEventSearch.new({
query: "@type:view",
}),
}),
}),
to: 1771836848262,
}),
type: DatadogAPIClient::V2::ProductAnalyticsAnalyticsRequestType::FORMULA_ANALYTICS_EXTENDED_REQUEST,
}),
})
p api_instance.query_product_analytics_timeseries(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"// Compute timeseries analytics returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_product_analytics::ProductAnalyticsAPI;
use datadog_api_client::datadogV2::model::ProductAnalyticsAnalyticsQuery;
use datadog_api_client::datadogV2::model::ProductAnalyticsAnalyticsRequest;
use datadog_api_client::datadogV2::model::ProductAnalyticsAnalyticsRequestAttributes;
use datadog_api_client::datadogV2::model::ProductAnalyticsAnalyticsRequestData;
use datadog_api_client::datadogV2::model::ProductAnalyticsAnalyticsRequestType;
use datadog_api_client::datadogV2::model::ProductAnalyticsBaseQuery;
use datadog_api_client::datadogV2::model::ProductAnalyticsCompute;
use datadog_api_client::datadogV2::model::ProductAnalyticsEventQuery;
use datadog_api_client::datadogV2::model::ProductAnalyticsEventQueryDataSource;
use datadog_api_client::datadogV2::model::ProductAnalyticsEventSearch;
#[tokio::main]
async fn main() {
let body = ProductAnalyticsAnalyticsRequest::new(ProductAnalyticsAnalyticsRequestData::new(
ProductAnalyticsAnalyticsRequestAttributes::new(
1771232048460,
ProductAnalyticsAnalyticsQuery::new(
ProductAnalyticsCompute::new("count".to_string()),
ProductAnalyticsBaseQuery::ProductAnalyticsEventQuery(Box::new(
ProductAnalyticsEventQuery::new(
ProductAnalyticsEventQueryDataSource::PRODUCT_ANALYTICS,
ProductAnalyticsEventSearch::new().query("@type:view".to_string()),
),
)),
),
1771836848262,
),
ProductAnalyticsAnalyticsRequestType::FORMULA_ANALYTICS_EXTENDED_REQUEST,
));
let configuration = datadog::Configuration::new();
let api = ProductAnalyticsAPI::with_config(configuration);
let resp = api.query_product_analytics_timeseries(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="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run/**
* Compute timeseries analytics 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.ProductAnalyticsApi(configuration);
const params: v2.ProductAnalyticsApiQueryProductAnalyticsTimeseriesRequest = {
body: {
data: {
attributes: {
from: 1771232048460,
query: {
compute: {
aggregation: "count",
},
query: {
dataSource: "product_analytics",
search: {
query: "@type:view",
},
},
},
to: 1771836848262,
},
type: "formula_analytics_extended_request",
},
},
};
apiInstance
.queryProductAnalyticsTimeseries(params)
.then((data: v2.ProductAnalyticsTimeseriesResponse) => {
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"