Skip to content

Instantly share code, notes, and snippets.

View hfleitas's full-sized avatar
👔
working

Hiram Fleitas hfleitas

👔
working
View GitHub Profile
@hfleitas
hfleitas / ML_Models.kql
Last active February 15, 2024 01:40
ML_Models.kql
.set-or-replace OccupancyDetection <| cluster('help').database('Samples').OccupancyDetection
.drop table ML_Models ifexists ;
.set ML_Models <| datatable(name:string, timestamp:datetime, model:string) [
'Occupancy', datetime(now), '800363736b6c6561726e2e6c696e6561725f6d6f64656c2e6c6f6769737469630a4c6f67697374696352656772657373696f6e0a7100298171017d710228580700000070656e616c7479710358020000006c32710458040000006475616c7105895803000000746f6c7106473f1a36e2eb1c432d5801000000437107473ff0000000000000580d0000006669745f696e746572636570747108885811000000696e746572636570745f7363616c696e6771094b01580c000000636c6173735f776569676874710a4e580c00000072616e646f6d5f7374617465710b4e5806000000736f6c766572710c58090000006c69626c696e656172710d58080000006d61785f69746572710e4b64580b0000006d756c74695f636c617373710f58030000006f767271105807000000766572626f736571114b00580a0000007761726d5f737461727471128958060000006e5f6a6f627371134b015808000000636c61737365735f7114636e756d70792e636f72652e6d756c746961727261790a5f7265636f6e7374727563740a71
@hfleitas
hfleitas / has_any.kql
Last active February 15, 2024 01:36
has_any.kql
//has_any
#connect @help/Samples
// let _state=StormEvents | distinct (State);
let _state="";
StormEvents
| where State has_any (_state)
| count
@hfleitas
hfleitas / Geospatial.kql
Last active February 15, 2024 01:33
Geospatial.kql
#connect cluster('trd-rjwm9jc98jph5mdjqy.z6.kusto.data.microsoft.com').database('RTAFlightStreamer')
// https://www.youtube.com/watch?v=ABJ1gjXAK54
// https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/geospatial-grid-systems
#connect @help/Samples
StormEvents
| take 100
| project BeginLon, BeginLat
@hfleitas
hfleitas / Cross-Cluster.kql
Created January 19, 2024 22:34
Cross-Cluster.kql
// Ingest from Query
//cross cluster query-ingest
.set-or-replace dxpooltable1 <| cluster('help').database('Samples').demo_make_series1
@hfleitas
hfleitas / CDN_Demo.kql
Created January 19, 2024 22:36
CDN_Demo.kql
#connect cluster("demo12.westus").database("CDN")
//Sample records
cdn_logs
| sample 10
//simple aggregation by various dimenssions
cdn_logs
| summarize count() by ClientCountryCode//, ChannelId, EdgeServerDatacenter
| top 5 by count_
@hfleitas
hfleitas / April2017_PowerBI.kql
Created January 19, 2024 22:38
April2017_PowerBI.kql
#connect cluster('demo12.westus.kusto.windows.net').database('sqlbi')
.show tables details
| where TableName startswith "BIAzure"
| summarize sum(TotalOriginalSize), sum(TotalExtentSize) by TableName
| extend CompressionRatio = sum_TotalOriginalSize/sum_TotalExtentSize
// ~30TB of data in 3 different tables (traces and perormance counters)
// Data is compressed and indexed (x10.2 for traces, x21-34 for performance counters)
// Compressed data and index are persisted to blob and cached on SSD
@hfleitas
hfleitas / 2Ready2019GitHub.kql
Last active February 13, 2024 13:37
2Ready2019GitHub.kql
#connect cluster('demo12.westus.kusto.windows.net').database('GitHub')
// Basics
// 1.2 Billions records
GithubEvent
| count
// Sample
GithubEvent
| take 10
@hfleitas
hfleitas / 1PBIReady2019.kql
Created January 19, 2024 22:39
1PBIReady2019.kql
//txt on svrs, common dbo gen log, atlasbridge, bogaboo proc info,
#connect cluster('demo12.westus.kusto.windows.net').database('sqlbi')
print ("Welcome")
print now()
// 8 machines in Azure
.show cluster
@hfleitas
hfleitas / 1brc.kql
Last active March 12, 2024 13:25
1brc.kql
// 1️⃣🐝🏎️🤿 (1BRC in Kusto 🏁 10.38ms)
// ref: https://github.com/gunnarmorling/1brc
.execute database script <|
.create-merge table 1brc (station:string, measurement:real)
.create-or-alter table 1brc ingestion csv mapping '1brc_mapping' '[{"column":"station", "Properties":{"Ordinal":"0"}},{"column":"measurement", "Properties":{"Ordinal":"1"}}]'
.ingest async into table 1brc (@'https://iotmonitoringsa26915.blob.core.windows.net/1brc/splits/measurements_split_aa') with (format='scsv',ignoreSizeLimit=true,ingestionMappingReference='1brc_mapping',ingestionMappingType='csv')
.ingest async into table 1brc (@'https://iotmonitoringsa26915.blob.core.windows.net/1brc/splits/measurements_split_ab') with (format='scsv',ignoreSizeLimit=true,ingestionMappingReference='1brc_mapping',ingestionMappingType='csv')
.ingest async into table 1brc (@'https://iotmonitoringsa26915.blob.core.windows.net/1brc/splits/measurements_split_ac') with (format='scsv',ignoreSizeLimit=true,ingestionMappingReference='1brc_mapping',ingestionMappin
@hfleitas
hfleitas / M01-Demo1-Intro.kql
Created February 13, 2024 13:55
M01-Demo1-Intro
#connect cluster('help').database('Samples')
// 👈 We have automatically added the "Samples" database to your connection pane.
// It contains sample data sets that you can use to run KQL queries and get a "feel" for the language.
// 🏃‍♂️ You can run a query by placing the cursor anywhere on the query text and clicking the run button (or Shift + Enter).
// 📄 KQL overview https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/
// 📃 Quick KQL reference guide can be found here https://docs.microsoft.com/en-us/azure/data-explorer/kql-quick-reference
// Start by browsing data in the StormEvents table, and view a small sample of records
// - Most queries start with a table name (in this case StormEvents that contains U.S weather data).