querying data in azure data explorer
play

Querying Data in Azure Data Explorer Xavier Morera HELPING - PowerPoint PPT Presentation

Querying Data in Azure Data Explorer Xavier Morera HELPING DEVELOPERS UNDERSTAND SEARCH & BIG DATA @xmorera www.xaviermorera.com A Query Query Results Executing Queries Kusto Web UI Integration with Kusto Explorer other products


  1. Querying Data in Azure Data Explorer Xavier Morera HELPING DEVELOPERS UNDERSTAND SEARCH & BIG DATA @xmorera www.xaviermorera.com

  2. A Query

  3. Query Results

  4. Executing Queries Kusto Web UI Integration with Kusto Explorer other products

  5. Getting to Know the Kusto Query Language

  6. A Kusto query is a read-only request to process data and return results

  7. A Kusto query is a read-only request to process data and return results

  8. StormEvents | where StartTime > datetime(2007-02-01) | where EventType == 'Flood' and State == 'CALIFORNIA’ | project StartTime, EndTime , State , EventType | take 10; A Kusto Query Plain text statement Data-flow model - Designed to make the syntax easy to read, author, and automate

  9. s h s Kusto query - Uses schema entities - Organized in a hierarchy • Similar to SQL’s databases, tables, and columns Functions are supported - Stored, query-defined, and built-in

  10. StormEvents | where StartTime > datetime(2007-02-01) | where EventType == 'Flood' and State == 'CALIFORNIA’ | project StartTime, EndTime , State , EventType | take 10; A Kusto Query

  11. StormEvents | where StartTime > datetime(2007-02-01) | where EventType == 'Flood' and State == 'CALIFORNIA’ | project StartTime, EndTime , State , EventType | take 10; A Kusto Query Sequence of query statements

  12. StormEvents | where StartTime > datetime(2007-02-01) | where EventType == 'Flood' and State == 'CALIFORNIA’ | project StartTime, EndTime , State , EventType | take 10; A Kusto Query Sequence of query statements - Delimited by a semicolon (;)

  13. StormEvents | where StartTime > datetime(2007-02-01) | where EventType == 'Flood' and State == 'CALIFORNIA’ | project StartTime, EndTime , State , EventType | take 10; A Kusto Query Sequence of query statements - Delimited by a semicolon (;) At least one statement being a tabular expression statement

  14. StormEvents | where StartTime > datetime(2007-02-01) | where EventType == 'Flood' and State == 'CALIFORNIA’ | project StartTime, EndTime , State , EventType | take 10; Tabular Expression Statement Structure of a tabular expression statement

  15. StormEvents | where StartTime > datetime(2007-02-01) | where EventType == 'Flood' and State == 'CALIFORNIA’ | project StartTime, EndTime , State , EventType | take 10; Tabular Expression Statement Structure of a tabular expression statement - Tabular data sources - Database is implicit • Part of the connection information

  16. StormEvents | where StartTime > datetime(2007-02-01) | where EventType == 'Flood' and State == 'CALIFORNIA’ | project StartTime, EndTime , State , EventType | take 10; Statement Syntax Data flow from one tabular query operator to another Through a set of data transformation operators - Optionally, a render instruction as the last statement Bound together by a pipe (|) delimiter

  17. Kusto Query source1 | operator1 | operator2 | [renderInstruction]

  18. KQL & SQL

  19. KQL SQL StormEvents Select * FROM StormEvents StormEvents SELECT EpisodeId, State | where notnull(State) FROM StormEvents | project EpisodeId, State, WHERE State IS NOT NULL StormEvents SELECT TOP 100 State, | summarize Count=count() by COUNT(*) as Count State FROM StormEvents | project State, Count GROUP BY State | sort by Count desc ORDER BY Count DESC | take int(100),

  20. t h s Demo SQL to Kusto query translation Using EXPLAIN

  21. Querying Azure Data Explorer, the help Cluster, and the Sample Database

  22. The help Cluster and Sample Database Data Explorer provides a help cluster - Created to aid learning Contains sample data - StormEvents - Other databases - External tables - Functions No need for you to spin up a cluster to test

  23. t h s Demo The help Cluster and Sample Databases

  24. https://help.kusto.windows.net/

  25. Control Commands

  26. Control Commands Retrieve data not in the database tables Requests to modify the state Three mechanisms to tell apart from queries - Language level • Start with a dot (.) - Protocol level • Different endpoint - API level • Different functions

  27. .show cluster A Control Command Control command to show cluster information

  28. .show cluster | count A Control Command Control command to show cluster information Command can be combined with a query - Must start with the command - Query cannot contain a command

  29. .show cluster capacity databases commands tables table schema queries

  30. .create table .create-merge table .rename table .drop table Table Management Create a table in the current database - Or extend an existing table Rename And drop

  31. t h s Demo Control commands

  32. The Kusto Query Language (KQL)

  33. Types of Commands Filter Date / Time Sort / Aggregate Column Related Format Data

  34. Filter Commands [T [T] | ] | s search ch [ki [kind=Ca CaseSens nsitivi vity] ] T | where Predicate T [i [in ( (Ta TableSources)] )] Se SearchPredic icate where search

  35. where search Filters on a predicate Searches all columns - In the specified table Similar to SQL • Or all tables - For the value StormEvents StormEvents | where DamageCrops > 0 | search "heavy rain"

  36. Predicates and, or, ==, !=, =~, !~, <, >... has, !has, contains, !contains, startswith, endswith, matches... between, not-between, distinct in, !in case

  37. has contains Looks for a specific word Looks for any substring match Better performance StormEvents StormEvents | where EventType | where EventType has "Storm" contains "Storm"

  38. Date and Time now ago totimespan datetime_add, datetime_diff... dayofyear, dayofmonth, dayofweek...

  39. Sort and Aggregate sort by summarize top order by make-series count join dcount range union dcountif

  40. Columns project project-away extend

  41. Format Data Commands format_datetime lookup format_timespan mv-expand parse

  42. t h s Demo The Basics of KQL

  43. https://docs.microsoft.com /en-us/azure/data- explorer/kql-quick- reference

  44. More KQL Operators

  45. t h s Demo More KQL Operators

  46. s h s Bind names to expressions Name can be used - To refer to its bound value - Within current scope let When previously defined - Innermost let state binding used Improve modularity - Break complex expressions

  47. let Bind names to expressions let Name = ScalarExpression

  48. let Bind names to expressions let Name = TabularExpression

  49. let Bind names to expressions let Name = FunctionDefinitionExpression

  50. let Bind names to expressions let f=(a:int, b:string) { strcat(b, ":", a) }

  51. Advanced KQL

  52. Advanced KQL Time series analysis Machine learning

  53. Time Series Analysis Analyze time series - Discover deviations - Compared to a baseline Native support - Creation, manipulation, and analysis - Of time-series data Enables near real-time monitoring

  54. Time Series Analysis Native series support let min_t = toscalar(TABLE| summarize min(TIMESTAMP)); let max_t = toscalar(TABLE| summarize max(TIMESTAMP)); let dt = 1h; TABLE | make-series num=count() default=0 on TIMESTAMP in range(min_t, max_t, dt) by COLUMN | render timechart

  55. Time Series Anomaly Detection Step by step let min_t = datetime(2017-01-05); let max_t = datetime(2017-02-03 22:00); let dt = 2h; demo_make_series2 | make-series num=avg(num) on TimeStamp from min_t to max_t step dt by sid | where sid == 'TS1’ | extend (anomalies, score, baseline) = series_decompose_anomalies(num, 1.5, -1, 'linefit’) | render anomalychart with(anomalycolumns=anomalies, title='Web app. traffic of a month, anomalies')

  56. Time Analysis Complex Functions series_fir series_fit_2lines series_fit_line series_iir series_periods_detect series_periods_validate

  57. Machine Learning Perform Root Cause Analysis - Complex and lengthy process Three Machine Learning plugins - Autocluster - Basket - Diffpatterns

  58. t h s Demo Advanced KQL

  59. Querying External Tables

  60. Querying External Tables Query data stored outside a Kusto cluster External tables - Recognized as database entities - Just like regular Kusto tables Create external table - Data lake - Different formats supported

  61. t h s Demo Querying External Tables

  62. Data All data

  63. Partitioned Data 2020 2019 2018

  64. Create External Table with Partition (.create | .alter) external table TableName ( Schema ) kind = (blob | adl) [partition by ( Partitions ) [pathformat = ( PathFormat )]] dataformat = Format ( StorageConnectionString [, ...] ) [with (PropertyName = Value , ... )]

  65. Querying Data in Azure Monitor and Using the Flow Kusto Connector

  66. Query Data in Azure Monitor Proxy Cluster (ADX Proxy) - Enables cross product queries Data Explorer - The Azure Monitor Service • Application Insights (AI) • Log Analytics (LA) Create a connection from ADX Web UI - To Application Insights/Log Analytics - Using virtual cluster

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend