cluster()

Applies to: ✅ Azure Data Explorer

Changes the reference of the query to a remote cluster. To access a database within the same cluster, use the database() function. For more information, see cross-database and cross-cluster queries.

Syntax

cluster(name)

Learn more about syntax conventions.

Parameters

Name Type Required Description
name string ✔️ The name of the cluster to reference. The value can be specified as a fully qualified domain name, or the name of the cluster without the .kusto.chinacloudapi.cn suffix. The cluster name is treated as case-insenstive and the recommendation is to provide it lower-case. The value can't be the result of subquery evaluation.

Examples

Use cluster() to access remote cluster

The following query can be run on any cluster.

cluster('help').database('Samples').StormEvents | count

cluster('help.chinaeast2.kusto.chinacloudapi.cn').database('Samples').StormEvents | count

Output

Count
59066

Use cluster() inside let statements

The previous query can be rewritten to use a query-defined function (let statement) that takes a parameter called clusterName and passes it to the cluster() function.

let foo = (clusterName:string)
{
    cluster(clusterName).database('Samples').StormEvents | count
};
foo('help')

Output

Count
59066

Use cluster() inside Functions

The same query as above can be rewritten to be used in a function that receives a parameter clusterName - which is passed into the cluster() function.

.create function foo(clusterName:string)
{
    cluster(clusterName).database('Samples').StormEvents | count
};

Note

Stored functions using the cluster() function can't be used in cross-cluster queries.