Using the Kusto Query Language
Introduction to KQL Command
Type |
Name |
Description |
Tabular
Operators |
print |
Prints
results of a query. |
|
search |
Searches
for specific data throughout the logs. |
|
where |
Filters
table to a subset of rows that satisfy a comparison. |
|
take/limit |
Returns
up to the specified number of rows. |
|
count(
) |
Returns
the number of records in the input record set. |
|
summarize |
Produces
a table that summarizes the content of the selected columns. |
|
extend |
Creates
calculated columns and appends them to the result set. |
|
project |
Selects
the columns to include. |
|
distinct |
Produces
a table with the distinct combination of the provided columns of the input
table. |
|
sort/order |
Sorts
the rows of the input table into order by one or more columns. |
|
join |
Merges
the rows of two tables to form a new table by matching the values of the
specified column(s) from each table. |
|
union |
Takes
two or more tables and returns the rows of all of them. |
|
render |
Displays
the output in a chart, including pie, bar, and line charts, among others. |
Query
Statements |
let |
Creates
variables. |
Scalar
Functions |
ago
( ) |
Subtracts
the given timespan from the current UTC clock time. |
|
bin
( ) |
Rounds
values down to an integer of a given size. |
String
Operators |
operators
|
Not
a command but a discussion of operators to use with the where command. |
Tabular Operators
It can produce data in a mixture of tables and rows where each tabular operator can pass its results from one command to another with the help of the pipe delimiter.
- The print command
It can easily print the results of a simple query and is useful to determine the way in which commands works and about the expected output.
- The search command
To use this command you have to look at the table in the log which will return all the columns as well as rows of the table to the maximum level of your application's capability.
- The where command
Whenever you only want to search a subset of the rows in a particular table, you can use where operator which can easily filter the rows that are returned according to the situation.
- The take/limit command
If you want a random sample of a data to be returned to get an idea about the data before going for a larger data, you can use take command which will return a specified number of rows, but there is no guarantee about which row will be returned to get a better sampling. limit is just another name for take command and these are very useful to define your queries.
- The count command
If you want to know the number of rows your query will return, you can use this command. It will take less time as compared to a basic search command, however, the time taken to perform a query may vary, but still it will be faster to simply get a count of the number of rows than to look at all the rows.
- The summarize command
Whenever you require the total values for a specific grouping of rows, you can use this command.
- The extend command
This command permits you to create new columns from the existing ones, or other data, like hardcoded values and is very useful to output the information that may exist in multiple columns but you want it to be shown in a single column.
- The project command
This command can specifically determine what columns to show if you don't want to look through all the columns that a query normally shows. It can also be useful for cleaning up the results by removing those columns you don't care about.
- The distinct command
If you want to look for only one among the multiple instances of the same value returned to you, this command can be used which can return only the first instance of a collection of the specified column(s) and ignores all the rest. This command is very helpful in building up of your query.
- The sort/order command
While running a query, by default, the rows will always be returned in the same order that they were previously saved into the table you were querying, but, if you require these values in some particular order like alphabetical or based on time value, you can use this command to sort the output into any order you need.
- The join command
This command can merge the columns from two different tables into one and it will be needed to get information from multiple tables or the same table with the help of different parameters.
- The union command
It can combine two or more tables into one. While join can have all the columns of the matching rows in one row, union can show one row for each row in each of the tables. Hence, if table 1 has 10 rows and table 2 has 12 rows then, then the union table will have 22 rows.
- The render command
This command is used to present your data output in a graphical format instead of a tabular one as sometimes it is much easier to look at a time chart or a bar chart rather than a list of strings and numbers. This command will make it easier to represent your results in a graphical way.
Query Statement
- The let statement
Scalar Functions
- The ago() function
- The bin() function
Comments
Post a Comment