Skip to content

Instantly share code, notes, and snippets.

@hfleitas
Created February 15, 2024 03:25
Show Gist options
  • Save hfleitas/26b64e2a244c548bb8e846c7e2a6f15c to your computer and use it in GitHub Desktop.
Save hfleitas/26b64e2a244c548bb8e846c7e2a6f15c to your computer and use it in GitHub Desktop.
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
//create RLS function using my query
.create-or-alter function RLSFunction() {
let IsManager = false;
let OnlyErrors = ingestionLogs | where Level == "Error" and not(IsManager);
let allData = ingestionLogs | where IsManager;
union OnlyErrors,allData
}
//enable it
.alter table ingestionLogs policy row_level_security disable 'RLSFunction()'
//test
ingestionLogs
| where Timestamp between (datetime(2014-03-08T00:00:00) .. datetime(2014-03-08T10:00:00))
| summarize count() by Level
| render piechart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment