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 / Sans2023.kql
Created February 15, 2024 03:27
Sans2023.kql
// https://detective.kusto.io/sans2023
////////////////////
// CASE 1 - Alert //
////////////////////
// the alerts says the user clicked the malicious link
// 'http://madelvesnorthpole.org/published/search/MonthlyInvoiceForReindeerFood.docx'
// Email of receipient?
Email
@hfleitas
hfleitas / RLS.kql
Created February 15, 2024 03:25
RLS.kql
ingestionLogs
| where Timestamp between (datetime(2014-03-08T00:00:00) .. datetime(2014-03-08T10:00:00))
| summarize count() by Level
| render piechart
//my RLS query
let IsManager = false; //let IsManager=current_principal_is_member_of("aadgroup=managers@company.com");
let OnlyErrors = ingestionLogs | where Level == "Error" and not(IsManager);
let allData = ingestionLogs | where IsManager;
union OnlyErrors,allData
@hfleitas
hfleitas / ADXinaDay-Labs.kql
Created February 15, 2024 03:21
ADXinaDay-Labs.kql
.create table logsRaw(
Timestamp:datetime,
Source:string,
Node:string,
Level:string,
Component:string,
ClientRequestId:string,
Message:string,
Properties:dynamic
)
@hfleitas
hfleitas / Partitioning1.kql
Created February 15, 2024 03:12
Partitioning1.kql
.show tables details
.show database extents partitioning statistics
.show table BIAzureAdditionalRawCounterFiveMinuteMsitScus_partitioned policy partitioning
{
"PartitionKeys": [
{
"ColumnName": "CounterName",
@hfleitas
hfleitas / telemetry-unixtime.kql
Created February 15, 2024 03:11
telemetry-unixtime.kql
.create table telemetryraw (TimeseriesId:string, TimeseriesName:string, ServerTimeStamp:long)
// TimeseriesId == '1d4037bc-xxxx-xxxx-xxxx-xxxxxxxxx'
.create table telemetry (TimeseriesId:guid, TimeseriesName:string, ServerTimeStamp:datetime)
.create-or-alter function transformtelemetryraw() {
telemetryraw
| project TimeseriesId=toguid(TimeseriesId), TimeseriesName, ServerTimeStamp=unixtime_seconds_todatetime(ServerTimeStamp)
}
@hfleitas
hfleitas / tsi2adx-kql-func.kql
Created February 15, 2024 02:54
tsi2adx-kql-func.kql
datatable(id:datetime, Event:string, counter:string, MoreData:dynamic) [
datetime(1910-06-11), "Born", '', dynamic({"key1":"value1", "key2":"value2"}),
datetime(1930-01-01), '',"Enters Ecole Navale", dynamic({"key1":"value3", "key2":"value4"}),
datetime(1953-01-01), "Published first book",'' ,dynamic({"key1":"value5", "key2":"value6"}),
datetime(1997-06-25), '', "Died", dynamic({"key1":"value7", "key2":"value8"})
]
| extend Event1 = iff((isnotempty(counter) == true), counter, Event)
@hfleitas
hfleitas / Partitioning.kql
Last active February 15, 2024 02:51
Partitioning.kql
.show tables details
.show database extents partitioning statistics
//note, it takes the DM 45mins - 1hr to start the partitioning process + however long to generate the heterougenious extents.
//so partitioning can take a while to finish creating the extents.
//alert if the partitioning percentage drops:
.show diagnostics | project TableWithMinPartitioningPercentage, MinPartitioningPercentageInSingleTable
//get more partitioning info on the extent level:
@hfleitas
hfleitas / Lab1-2.kql
Last active February 15, 2024 02:41
Lab1-2.kql
// https://aka.ms/adxinaday
.create table logsRaw(
Timestamp:datetime,
Source:string,
Node:string,
Level:string,
Component:string,
ClientRequestId:string,
Message:string,
@hfleitas
hfleitas / iPhoneRaw.kql
Created February 15, 2024 02:34
iPhoneRaw.kql
iphone_raw
| take 10
iphone_raw
| summarize count() by component, messageSource
iphone_raw
| where isempty(component)
iphone_raw
@hfleitas
hfleitas / Adx Tour.kql
Created February 15, 2024 02:32
Adx Tour.kql
let _startTime = datetime(2016-01-01T17:38:00Z);
let _endTime = datetime(2023-09-19T18:38:00Z);
// baseQuery results
let results = () {
demo_make_series1
| where TimeStamp between (['_startTime'] .. ['_endTime'])
};
results
| make-series Cardinality=count() on TimeStamp step 1h by OsVer
| extend (anomalies, score, baseline) = series_decompose_anomalies(Cardinality, 2.0)