Sankey 다이어그램 컴퓨팅
https://api.datadoghq.com/api/v2/product-analytics/sankeyhttps://api.us3.datadoghq.com/api/v2/product-analytics/sankeyhttps://api.us5.datadoghq.com/api/v2/product-analytics/sankeyhttps://api.datadoghq.eu/api/v2/product-analytics/sankeyhttps://api.ap1.datadoghq.com/api/v2/product-analytics/sankeyhttps://api.ap2.datadoghq.com/api/v2/product-analytics/sankeyhttps://api.uk1.datadoghq.com/api/v2/product-analytics/sankeyhttps://api.ddog-gov.com/api/v2/product-analytics/sankeyhttps://api.us2.ddog-gov.com/api/v2/product-analytics/sankey개요
두 패싯의 값 사이에서 세션이 어떻게 흐르는지 보여주는 Sankey 다이어그램을 계산하여, 각 단계에서 사용자가 계속 유지되는 지점과 이탈하는 지점을 보여줍니다.
요청
Body Data (required)
Sankey 다이어그램 쿼리입니다.
data [required]Sankey 다이어그램 쿼리에 대한 요청 본문입니다.
attributes [required]Attributes of a Sankey request.
definition [required]The shape of the Sankey diagram, expressed as the facets to flow between and how many steps to show.
entries_per_stepMaximum number of nodes to keep in each column. Remaining values are rolled up into an
aggregated node. Omit it, or send 0, to use the default of 5.
number_of_stepsNumber of intermediate columns between the source and the target.
Omit it, or send 0, to use the default of 5.
source [required]Facet forming the first column of the diagram.
target [required]Facet forming the last column of the diagram.
search [required]Selects the sessions a Sankey diagram is built from.
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.
join_keysIdentity join keys used to stitch events belonging to the same user or session.
primaryPrimary identity join key. Defaults to @session.id.
secondaryAdditional identity join keys.
queryDatadog search query restricting the events considered.
time [required]The time window a Sankey query covers.
from [required]Start of the query window, in epoch milliseconds.
to [required]End of the query window, in epoch milliseconds.
type [required]The resource type identifier for a Sankey request.
sankey_request{
"data": {
"attributes": {
"definition": {
"entries_per_step": 10,
"number_of_steps": 3,
"source": "@view.name",
"target": "@view.name"
},
"search": {
"audience_filters": {
"accounts": [
{
"name": "",
"query": "string"
}
],
"formula": "u",
"segments": [
{
"name": "",
"segment_id": "00000000-0000-0000-0000-000000000000"
}
],
"users": [
{
"name": "u",
"query": "*"
}
]
},
"join_keys": {
"primary": "@session.id",
"secondary": []
},
"query": "@type:view"
},
"time": {
"from": 1756425600000,
"to": 1756857600000
}
},
"type": "sankey_request"
}
}응답
OK
Response for a Sankey diagram query.
data [required]The single JSON:API resource holding a computed Sankey diagram. Its attributes contain the nodes of every column and the links that carry sessions between them.
attributes [required]Attributes of a Sankey response, containing the nodes and the links between them.
linksThe links of the diagram, one per pair of connected nodes.
columnZero-based index of the column the link starts from.
idUnique identifier for the link.
sourceIdentifier of the node the link starts at.
targetIdentifier of the node the link ends at.
valueNumber of sessions flowing along the link.
nodesThe nodes of the diagram, one per facet value and column.
aggregated_nodesThe nodes rolled up into this one, when the node is an aggregate.
idUnique identifier for the node.
incoming_valueNumber of sessions entering the node.
nameThe facet value the node represents.
outgoing_valueNumber of sessions leaving the node.
typeThe resource type identifier for a node rolled up into an aggregated node.
aggregatedvalueNumber of sessions passing through the node.
columnZero-based index of the column the node sits in.
dropoff_valueNumber of sessions that ended at the node.
idUnique identifier for the node.
incoming_valueNumber of sessions entering the node.
nameThe facet value the node represents.
outgoing_valueNumber of sessions leaving the node.
typeThe kind of node. regular is a single facet value, other rolls up the values that did not
fit within entries_per_step, and dropoff collects the sessions that ended at this column.
regular, other, dropoffvalueNumber of sessions passing through the node.
id [required]Unique identifier for this response data object.
type [required]The resource type identifier for a Sankey response.
sankey_response{
"data": {
"attributes": {
"links": [
{
"column": "integer",
"id": "string",
"source": "string",
"target": "string",
"value": "integer"
}
],
"nodes": [
{
"aggregated_nodes": [
{
"id": "string",
"incoming_value": "integer",
"name": "string",
"outgoing_value": "integer",
"type": "string",
"value": "integer"
}
],
"column": "integer",
"dropoff_value": "integer",
"id": "string",
"incoming_value": "integer",
"name": "string",
"outgoing_value": "integer",
"type": "string",
"value": "integer"
}
]
},
"id": "00000000-0000-0000-0000-000000000000",
"type": "sankey_response"
}
}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"
]
}코드 예시
# 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/sankey" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"definition": {
"entries_per_step": 10,
"number_of_steps": 3,
"source": "@view.name",
"target": "@view.name"
},
"search": {
"query": "@type:view"
},
"time": {
"from": 1756425600000,
"to": 1756857600000
}
},
"type": "sankey_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/sankey" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"definition": {
"entries_per_step": 10,
"number_of_steps": 3,
"source": "@view.name",
"target": "@view.name"
},
"search": {
"query": "@type:view"
},
"time": {
"from": 1756425600000,
"to": 1756857600000
}
},
"type": "sankey_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/sankey" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"definition": {
"entries_per_step": 10,
"number_of_steps": 3,
"source": "@view.name",
"target": "@view.name"
},
"search": {
"query": "@type:view"
},
"time": {
"from": 1756425600000,
"to": 1756857600000
}
},
"type": "sankey_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/sankey" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"definition": {
"entries_per_step": 10,
"number_of_steps": 3,
"source": "@view.name",
"target": "@view.name"
},
"search": {
"query": "@type:view"
},
"time": {
"from": 1756425600000,
"to": 1756857600000
}
},
"type": "sankey_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/sankey" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"definition": {
"entries_per_step": 10,
"number_of_steps": 3,
"source": "@view.name",
"target": "@view.name"
},
"search": {
"query": "@type:view"
},
"time": {
"from": 1756425600000,
"to": 1756857600000
}
},
"type": "sankey_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/sankey" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"definition": {
"entries_per_step": 10,
"number_of_steps": 3,
"source": "@view.name",
"target": "@view.name"
},
"search": {
"query": "@type:view"
},
"time": {
"from": 1756425600000,
"to": 1756857600000
}
},
"type": "sankey_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/sankey" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"definition": {
"entries_per_step": 10,
"number_of_steps": 3,
"source": "@view.name",
"target": "@view.name"
},
"search": {
"query": "@type:view"
},
"time": {
"from": 1756425600000,
"to": 1756857600000
}
},
"type": "sankey_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/sankey" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"definition": {
"entries_per_step": 10,
"number_of_steps": 3,
"source": "@view.name",
"target": "@view.name"
},
"search": {
"query": "@type:view"
},
"time": {
"from": 1756425600000,
"to": 1756857600000
}
},
"type": "sankey_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/sankey" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"definition": {
"entries_per_step": 10,
"number_of_steps": 3,
"source": "@view.name",
"target": "@view.name"
},
"search": {
"query": "@type:view"
},
"time": {
"from": 1756425600000,
"to": 1756857600000
}
},
"type": "sankey_request"
}
}
EOF// Compute a Sankey diagram 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"
"github.com/google/uuid"
)
func main() {
body := datadogV2.ProductAnalyticsSankeyRequest{
Data: datadogV2.ProductAnalyticsSankeyRequestData{
Attributes: datadogV2.ProductAnalyticsSankeyRequestAttributes{
Definition: datadogV2.ProductAnalyticsSankeyDefinition{
EntriesPerStep: datadog.PtrInt64(10),
NumberOfSteps: datadog.PtrInt64(3),
Source: "@view.name",
Target: "@view.name",
},
Search: datadogV2.ProductAnalyticsSankeySearch{
AudienceFilters: &datadogV2.ProductAnalyticsAudienceFilters{
Accounts: []datadogV2.ProductAnalyticsAudienceAccountSubquery{
{
Name: "",
},
},
Formula: datadog.PtrString("u"),
Segments: []datadogV2.ProductAnalyticsAudienceSegmentSubquery{
{
Name: "",
SegmentId: uuid.MustParse("00000000-0000-0000-0000-000000000000"),
},
},
Users: []datadogV2.ProductAnalyticsAudienceUserSubquery{
{
Name: "u",
Query: datadog.PtrString("*"),
},
},
},
JoinKeys: &datadogV2.ProductAnalyticsJoinKeys{
Primary: datadog.PtrString("@session.id"),
Secondary: []string{},
},
Query: datadog.PtrString("@type:view"),
},
Time: datadogV2.ProductAnalyticsSankeyTime{
From: 1756425600000,
To: 1756857600000,
},
},
Type: datadogV2.PRODUCTANALYTICSSANKEYREQUESTTYPE_SANKEY_REQUEST,
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
configuration.SetUnstableOperationEnabled("v2.QueryProductAnalyticsSankey", true)
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewProductAnalyticsApi(apiClient)
resp, r, err := api.QueryProductAnalyticsSankey(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `ProductAnalyticsApi.QueryProductAnalyticsSankey`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `ProductAnalyticsApi.QueryProductAnalyticsSankey`:\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 a Sankey diagram 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.ProductAnalyticsAudienceAccountSubquery;
import com.datadog.api.client.v2.model.ProductAnalyticsAudienceFilters;
import com.datadog.api.client.v2.model.ProductAnalyticsAudienceSegmentSubquery;
import com.datadog.api.client.v2.model.ProductAnalyticsAudienceUserSubquery;
import com.datadog.api.client.v2.model.ProductAnalyticsJoinKeys;
import com.datadog.api.client.v2.model.ProductAnalyticsSankeyDefinition;
import com.datadog.api.client.v2.model.ProductAnalyticsSankeyRequest;
import com.datadog.api.client.v2.model.ProductAnalyticsSankeyRequestAttributes;
import com.datadog.api.client.v2.model.ProductAnalyticsSankeyRequestData;
import com.datadog.api.client.v2.model.ProductAnalyticsSankeyRequestType;
import com.datadog.api.client.v2.model.ProductAnalyticsSankeyResponse;
import com.datadog.api.client.v2.model.ProductAnalyticsSankeySearch;
import com.datadog.api.client.v2.model.ProductAnalyticsSankeyTime;
import java.util.Collections;
import java.util.UUID;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
defaultClient.setUnstableOperationEnabled("v2.queryProductAnalyticsSankey", true);
ProductAnalyticsApi apiInstance = new ProductAnalyticsApi(defaultClient);
ProductAnalyticsSankeyRequest body =
new ProductAnalyticsSankeyRequest()
.data(
new ProductAnalyticsSankeyRequestData()
.attributes(
new ProductAnalyticsSankeyRequestAttributes()
.definition(
new ProductAnalyticsSankeyDefinition()
.entriesPerStep(10L)
.numberOfSteps(3L)
.source("@view.name")
.target("@view.name"))
.search(
new ProductAnalyticsSankeySearch()
.audienceFilters(
new ProductAnalyticsAudienceFilters()
.accounts(
Collections.singletonList(
new ProductAnalyticsAudienceAccountSubquery()
.name("")))
.formula("u")
.segments(
Collections.singletonList(
new ProductAnalyticsAudienceSegmentSubquery()
.name("")
.segmentId(
UUID.fromString(
"00000000-0000-0000-0000-000000000000"))))
.users(
Collections.singletonList(
new ProductAnalyticsAudienceUserSubquery()
.name("u")
.query("*"))))
.joinKeys(new ProductAnalyticsJoinKeys().primary("@session.id"))
.query("@type:view"))
.time(
new ProductAnalyticsSankeyTime()
.from(1756425600000L)
.to(1756857600000L)))
.type(ProductAnalyticsSankeyRequestType.SANKEY_REQUEST));
try {
ProductAnalyticsSankeyResponse result = apiInstance.queryProductAnalyticsSankey(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ProductAnalyticsApi#queryProductAnalyticsSankey");
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 a Sankey diagram 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_audience_account_subquery import (
ProductAnalyticsAudienceAccountSubquery,
)
from datadog_api_client.v2.model.product_analytics_audience_filters import ProductAnalyticsAudienceFilters
from datadog_api_client.v2.model.product_analytics_audience_segment_subquery import (
ProductAnalyticsAudienceSegmentSubquery,
)
from datadog_api_client.v2.model.product_analytics_audience_user_subquery import ProductAnalyticsAudienceUserSubquery
from datadog_api_client.v2.model.product_analytics_join_keys import ProductAnalyticsJoinKeys
from datadog_api_client.v2.model.product_analytics_sankey_definition import ProductAnalyticsSankeyDefinition
from datadog_api_client.v2.model.product_analytics_sankey_request import ProductAnalyticsSankeyRequest
from datadog_api_client.v2.model.product_analytics_sankey_request_attributes import (
ProductAnalyticsSankeyRequestAttributes,
)
from datadog_api_client.v2.model.product_analytics_sankey_request_data import ProductAnalyticsSankeyRequestData
from datadog_api_client.v2.model.product_analytics_sankey_request_type import ProductAnalyticsSankeyRequestType
from datadog_api_client.v2.model.product_analytics_sankey_search import ProductAnalyticsSankeySearch
from datadog_api_client.v2.model.product_analytics_sankey_time import ProductAnalyticsSankeyTime
from uuid import UUID
body = ProductAnalyticsSankeyRequest(
data=ProductAnalyticsSankeyRequestData(
attributes=ProductAnalyticsSankeyRequestAttributes(
definition=ProductAnalyticsSankeyDefinition(
entries_per_step=10,
number_of_steps=3,
source="@view.name",
target="@view.name",
),
search=ProductAnalyticsSankeySearch(
audience_filters=ProductAnalyticsAudienceFilters(
accounts=[
ProductAnalyticsAudienceAccountSubquery(
name="",
),
],
formula="u",
segments=[
ProductAnalyticsAudienceSegmentSubquery(
name="",
segment_id=UUID("00000000-0000-0000-0000-000000000000"),
),
],
users=[
ProductAnalyticsAudienceUserSubquery(
name="u",
query="*",
),
],
),
join_keys=ProductAnalyticsJoinKeys(
primary="@session.id",
secondary=[],
),
query="@type:view",
),
time=ProductAnalyticsSankeyTime(
_from=1756425600000,
to=1756857600000,
),
),
type=ProductAnalyticsSankeyRequestType.SANKEY_REQUEST,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["query_product_analytics_sankey"] = True
with ApiClient(configuration) as api_client:
api_instance = ProductAnalyticsApi(api_client)
response = api_instance.query_product_analytics_sankey(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 a Sankey diagram returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
config.unstable_operations["v2.query_product_analytics_sankey".to_sym] = true
end
api_instance = DatadogAPIClient::V2::ProductAnalyticsAPI.new
body = DatadogAPIClient::V2::ProductAnalyticsSankeyRequest.new({
data: DatadogAPIClient::V2::ProductAnalyticsSankeyRequestData.new({
attributes: DatadogAPIClient::V2::ProductAnalyticsSankeyRequestAttributes.new({
definition: DatadogAPIClient::V2::ProductAnalyticsSankeyDefinition.new({
entries_per_step: 10,
number_of_steps: 3,
source: "@view.name",
target: "@view.name",
}),
search: DatadogAPIClient::V2::ProductAnalyticsSankeySearch.new({
audience_filters: DatadogAPIClient::V2::ProductAnalyticsAudienceFilters.new({
accounts: [
DatadogAPIClient::V2::ProductAnalyticsAudienceAccountSubquery.new({
name: "",
}),
],
formula: "u",
segments: [
DatadogAPIClient::V2::ProductAnalyticsAudienceSegmentSubquery.new({
name: "",
segment_id: "00000000-0000-0000-0000-000000000000",
}),
],
users: [
DatadogAPIClient::V2::ProductAnalyticsAudienceUserSubquery.new({
name: "u",
query: "*",
}),
],
}),
join_keys: DatadogAPIClient::V2::ProductAnalyticsJoinKeys.new({
primary: "@session.id",
secondary: [],
}),
query: "@type:view",
}),
time: DatadogAPIClient::V2::ProductAnalyticsSankeyTime.new({
from: 1756425600000,
to: 1756857600000,
}),
}),
type: DatadogAPIClient::V2::ProductAnalyticsSankeyRequestType::SANKEY_REQUEST,
}),
})
p api_instance.query_product_analytics_sankey(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 a Sankey diagram returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_product_analytics::ProductAnalyticsAPI;
use datadog_api_client::datadogV2::model::ProductAnalyticsAudienceAccountSubquery;
use datadog_api_client::datadogV2::model::ProductAnalyticsAudienceFilters;
use datadog_api_client::datadogV2::model::ProductAnalyticsAudienceSegmentSubquery;
use datadog_api_client::datadogV2::model::ProductAnalyticsAudienceUserSubquery;
use datadog_api_client::datadogV2::model::ProductAnalyticsJoinKeys;
use datadog_api_client::datadogV2::model::ProductAnalyticsSankeyDefinition;
use datadog_api_client::datadogV2::model::ProductAnalyticsSankeyRequest;
use datadog_api_client::datadogV2::model::ProductAnalyticsSankeyRequestAttributes;
use datadog_api_client::datadogV2::model::ProductAnalyticsSankeyRequestData;
use datadog_api_client::datadogV2::model::ProductAnalyticsSankeyRequestType;
use datadog_api_client::datadogV2::model::ProductAnalyticsSankeySearch;
use datadog_api_client::datadogV2::model::ProductAnalyticsSankeyTime;
use uuid::Uuid;
#[tokio::main]
async fn main() {
let body = ProductAnalyticsSankeyRequest::new(ProductAnalyticsSankeyRequestData::new(
ProductAnalyticsSankeyRequestAttributes::new(
ProductAnalyticsSankeyDefinition::new(
"@view.name".to_string(),
"@view.name".to_string(),
)
.entries_per_step(10)
.number_of_steps(3),
ProductAnalyticsSankeySearch::new()
.audience_filters(
ProductAnalyticsAudienceFilters::new()
.accounts(vec![ProductAnalyticsAudienceAccountSubquery::new(
"".to_string(),
)])
.formula("u".to_string())
.segments(vec![ProductAnalyticsAudienceSegmentSubquery::new(
"".to_string(),
Uuid::parse_str("00000000-0000-0000-0000-000000000000")
.expect("invalid UUID"),
)])
.users(vec![ProductAnalyticsAudienceUserSubquery::new(
"u".to_string(),
)
.query("*".to_string())]),
)
.join_keys(
ProductAnalyticsJoinKeys::new()
.primary("@session.id".to_string())
.secondary(vec![]),
)
.query("@type:view".to_string()),
ProductAnalyticsSankeyTime::new(1756425600000, 1756857600000),
),
ProductAnalyticsSankeyRequestType::SANKEY_REQUEST,
));
let mut configuration = datadog::Configuration::new();
configuration.set_unstable_operation_enabled("v2.query_product_analytics_sankey", true);
let api = ProductAnalyticsAPI::with_config(configuration);
let resp = api.query_product_analytics_sankey(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 a Sankey diagram 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,
},
},
});
configuration.unstableOperations["v2.queryProductAnalyticsSankey"] = true;
const apiInstance = new v2.ProductAnalyticsApi(configuration);
const params: v2.ProductAnalyticsApiQueryProductAnalyticsSankeyRequest = {
body: {
data: {
attributes: {
definition: {
entriesPerStep: 10,
numberOfSteps: 3,
source: "@view.name",
target: "@view.name",
},
search: {
audienceFilters: {
accounts: [
{
name: "",
},
],
formula: "u",
segments: [
{
name: "",
segmentId: "00000000-0000-0000-0000-000000000000",
},
],
users: [
{
name: "u",
query: "*",
},
],
},
joinKeys: {
primary: "@session.id",
secondary: [],
},
query: "@type:view",
},
time: {
from: 1756425600000,
to: 1756857600000,
},
},
type: "sankey_request",
},
},
};
apiInstance
.queryProductAnalyticsSankey(params)
.then((data: v2.ProductAnalyticsSankeyResponse) => {
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"