LokqlDx ‐ Settings, Variables and Macros - NeilMacMullen/kusto-loco GitHub Wiki

Many aspects of LokqklDx behaviour are controlled by settings. These can be assigned using the .set command. For example:

.set scottplot.palette amber - change the default color-scheme for charts

Settings can also be assigned for your own use and can then be used in commands by prefixing with a $ sign. For example:

.set age 10d 

mydata 
| where Timestamp > ago($age)

Frequently-used settings can be assigned in the workspace or application startup scripts.

Collections of settings can be invoked together by placing them in a macro...

#defines a macro that sets a common chart style
.define mychart
.set scottplot.palette amber
.set scottplot.legend "upperright horizontal"
.end

#invoke the macro to change style
.macro mychart

Listing settings

The .settings command can be used to display all current settings.

Environment variables

Environment variables are automatically imported as settings and are prefixed with "env.".

Macros

Macros are defined using the .define and .end keywords and are invoked using .macro. Macros can accept arguments. For example:


#define a simple macro to calculate duplicates in a table
.define dups table  column
$table 
| summarize count() by $column
| where count_ > 1
| order by count_
.end

#define some test data
.addtable testdata
A,B
1,x
2,y
3,x

#run the macro
.macro dups testdata B