%3CLINGO-SUB%20id%3D%22lingo-sub-1416287%22%20slang%3D%22en-US%22%3EAzure%20Log%20Analytics%20-%20Data%20Retention%20By%20Type%20in%20Real%20Life%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1416287%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20everybody%2C%20Bruno%20here%20again%20together%20with%20my%20Azure%20Sentinel%20colleague%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F482040%22%20target%3D%22_blank%22%3E%40sifriger%3C%2FA%3E%26nbsp%3B(credits%20to%20you%20mate%20to%20have%20brought%20what%20we%E2%80%99re%20going%20to%20present%20to%20my%20attention).%3C%2FP%3E%0A%3CP%3EToday%2C%20I%E2%80%99ll%20walk%20you%20through%20the%20setting%20of%20different%20retention%20for%20a%20Azure%20Log%20Analytics%20workspace%20based%20on%20data%20types.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFirst%20of%20all%2C%20let%20me%20refresh%20a%20little%20bit%20what%20a%20data%20type%20is%20in%20the%20Azure%20Log%20Analytics%20context%3A%20a%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-explorer%2Fkusto%2Fquery%2Fscalar-data-types%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Edata%20type%3C%2FA%3E%20is%20either%20a%20%3CSTRONG%3Escalar%20data%20type%3C%2FSTRONG%3E%20(one%20of%20the%20built-in%20predefined%20types%20listed%20below)%2C%20or%20a%20%3CSTRONG%3Euser-defined%20record%3C%2FSTRONG%3E%20(an%20ordered%20sequence%20of%20name%2Fscalar-data-type%20pairs%2C%20such%20as%20the%20data%20type%20of%20a%20row%20of%20a%20table).%3C%2FP%3E%0A%3CP%3ELet%E2%80%99s%20also%20refresh%20the%20data%20retention%20definition%3A%20the%20retention%20represents%20how%20long%20(the%20amount%20of%20time%20in%20days%20)%20data%20is%20kept%20inside%20an%20Azure%20Log%20Analytics%20workspace%20(see%20%3CEM%3EChange%20the%20data%20retention%20period%3C%2FEM%3E%20paragraph%20in%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Fplatform%2Fmanage-cost-storage%23change-the-data-retention-period%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EManage%20usage%20and%20costs%20with%20Azure%20Monitor%20Logs%3C%2FA%3E%20article).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20that%20we%20have%20both%20concepts%20refreshed%20and%20clear%20in%20mind%2C%20we%20can%20get%20to%20the%20point.%20As%20you%20have%20heard%20for%20sure%2C%20on%20%3CEM%3E%3CU%3EOctober%2008%2C%202019%3C%2FU%3E%3C%2FEM%3E%20a%20feature%20that%20allows%20you%20to%20set%20the%20retention%20by%20single%20data%20type%20(also%20referred%20as%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-explorer%2Fkusto%2Fquery%2Fschema-entities%2Ftables%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Etable%3C%2FA%3E)%20overriding%20the%20general%20workspace%20setting%20was%20announced%20through%20this%20official%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fupdates%2Fretention-by-type%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Epost%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3EWhat%20could%20be%20the%20reason%20why%20you%20might%20want%20to%20change%20the%20retention%20on%20a%20single%20table%3F%20There%20could%20be%20several%20and%20all%20could%20be%20valid.%20For%20instance%2C%20we%20could%20have%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EUsage%20and%20costs%20control%3A%20as%20per%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Fplatform%2Fmanage-cost-storage%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EManage%20usage%20and%20costs%20with%20Azure%20Monitor%20Logs%3C%2FA%3E%20article%2C%20by%20operating%20on%20the%20data%20retention%20you%20proactively%20monitor%20ingested%20data%20volume%20and%20storage%20growth%2C%20and%20define%20limits%20to%20control%20those%20associated%20costs.%3C%2FLI%3E%0A%3CLI%3ELimit%20performance%20data%20retention%20on%20an%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsentinel%2Foverview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Sentinel%3C%2FA%3E%20%3CEM%3Econnected%3C%2FEM%3E%20workspace%3A%20This%20one%20is%20pretty%20common.%20Performance%20data%20is%20normally%20considered%20stale%20after%20a%20couple%20of%20days%20or%20even%20earlier%20unless%20you%20want%20to%20store%20it%20for%20data%20warehouse%20purpose%20(i.e.%20baseline%20or%20troubleshooting).%20Moreover%2C%20%3CU%3Enatively%3C%2FU%3E%2C%20Azure%20Sentinel%20does%20not%20have%20any%20query%20which%20runs%20against%20or%20correlate%20with%20the%20Perf%20table%2C%20hence%20there%20could%20be%20no%20need%20to%20keep%20this%20data%20over%20the%20default%20retention%20(which%2030%20days%20for%20normal%20Log%20Analytics%20workspace%20or%2090%20days%20for%20Azure%20Sentinel%20connected%20ones).%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EBear%20also%20in%20mind%20that%20there%20are%20also%20some%20important%20elements%20to%20be%20considered%20when%20dealing%20with%20data%20retention%20and%20before%20making%20the%20decision%20of%20changing%20it.%20As%20an%20example%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ECorrelation%20among%20tables%20could%20be%20impacted%20by%20different%20retention%3C%2FLI%3E%0A%3CLI%3EChanging%20the%20retention%20at%20the%20workspace%20level%20will%20change%20the%20table%20retention%20any%20longer%20on%20the%20one%20previously%20modified%3C%2FLI%3E%0A%3CLI%3EShould%20you%20need%20to%20align%20back%20to%20workspace%20retention%2C%20you%20need%20to%20reset%20what%20has%20been%20configured%20using%20the%20same%20method%20used%20to%20set%20it%2C%20hence%20you%20will%20get%20through%20the%20same%20steps%20and%20level%20of%20complexity.%3C%2FLI%3E%0A%3CLI%3EFor%20data%20collected%20earlier%20than%20October%202019%20(when%20this%20feature%20was%20released)%2C%20setting%20a%20lower%20retention%20for%20an%20individual%20type%20won%E2%80%99t%20affect%20your%20retention%20costs.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EWith%20all%20that%20said%2C%20should%20you%20need%20to%20set%20different%20retention%20per%20table%2C%20continue%20reading%20this%20post.%3C%2FP%3E%0A%3CP%3ESetting%20data%20retention%20by%20type%20is%20not%20a%20feature%20offered%20at%20the%20portal%20interface%20level.%20In%20the%20Azure%20portal%20you%20can%20only%20set%20the%20retention%20for%20the%20entire%20workspace.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorBruno%20Gabrielli_0%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22DataRetention.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F194277iA1B2EBAA206F1788%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22DataRetention.png%22%20alt%3D%22DataRetention.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20means%20that%20you%E2%80%99ll%20need%20to%20use%20some%20simple%20ARM%20command.%3C%2FP%3E%0A%3CP%3ESo%2C%20moving%20on%2C%20is%20there%20anything%20else%20you%20need%20to%20know%20or%20have%20before%20moving%20ahead%3F%3C%2FP%3E%0A%3CP%3EEasy%20answer%3A%20you%20need%20to%20know%20the%20resource%20id%20and%20have%20an%20ARM%20client%20to%20execute%20the%20command.%3C%2FP%3E%0A%3CP%3EAs%20far%20as%20the%20resource%20id%20goes%2C%20you%20first%20need%20to%20retrieve%20the%20Log%20Analytics%20workspace%20resource%20id.%20You%20can%20do%20that%2C%20thanks%20to%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-resource-manager%2Fmanagement%2Foverview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Resource%20Manager%3C%2FA%3E%2C%20directly%20from%20the%20Azure%20portal%20by%20using%20Resource%20Explorer%3A%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorBruno%20Gabrielli_1%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ResourceExplorer.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F194276iE585E884185F8CE2%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22ResourceExplorer.png%22%20alt%3D%22ResourceExplorer.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20you%20get%20to%20the%20%3CSTRONG%3E%3CEM%3EResource%20Explorer%3C%2FEM%3E%3C%2FSTRONG%3E%20page%2C%20expand%20%3CSTRONG%3E%3CEM%3ESubscriptions%3C%2FEM%3E%3C%2FSTRONG%3E%20and%20navigate%20all%20the%20resources%20till%20the%20one%20you%20want%20to%20operate%20on%20(in%20this%20case%20the%20Log%20Analytics%20workspace)%3A%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorBruno%20Gabrielli_2%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Resource.png%22%20style%3D%22width%3A%20460px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F194275iE99D1D828B66EC85%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22Resource.png%22%20alt%3D%22Resource.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20you%20get%20to%20it%2C%20in%20the%20right%20part%20you%20will%20get%20the%20JSON%20template%20of%20the%20given%20resource.%20Inside%20the%20template%20you%20have%20several%20key%2Fvalue%20pairs%20and%20objects%2C%20among%20which%20there%20is%20the%20%3CSTRONG%3E%3CEM%3Eid%3C%2FEM%3E%3C%2FSTRONG%3E%20that%20represents%20exactly%20the%20%3CSTRONG%3E%3CEM%3Eresourceid%3C%2FEM%3E%3C%2FSTRONG%3E%20of%20the%20workspace%20for%20which%20you%20want%20to%20change%20the%20retention%20on%20a%20given%20table%3A%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorBruno%20Gabrielli_3%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ResourceId.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F194278i09E71BBF96E20587%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22ResourceId.png%22%20alt%3D%22ResourceId.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20that%20you%20have%20the%20workspace%20%3CSTRONG%3E%3CEM%3Eresourceid%3C%2FEM%3E%3C%2FSTRONG%3E%2C%20since%20tables%20do%20not%20appear%20as%20resource%20entries%2C%20you%20need%20an%20additional%20easy%20step.%20You%20need%20to%20add%20the%20table%20name%20and%20API%20information%20to%20execute%20the%20necessary%20command.%3C%2FP%3E%0A%3CP%3EYou%20can%20achieve%20that%20by%20adding%20the%20following%20string%20right%20after%20the%20resource%20id%20value%20just%20retrieved%20by%20paying%20attention%20to%20the%20table%20name%20(I%20intentionally%20put%20a%20placeholder%20here)%3C%2FP%3E%0A%3CP%3E%2FTables%2F%3CSTRONG%3E%3CMARK%3EMYTABLENAME%3C%2FMARK%3E%3C%2FSTRONG%3E%3Fapi-version%3D2017-04-26-preview%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%20background%3A%20%23e2daf1%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%20background%3A%20%23e2daf1%3B%22%3E%3CSTRONG%3E%3CEM%3ENOTE%3A%20%3C%2FEM%3E%3C%2FSTRONG%3E%3CEM%3Ethe%20API%20version%20could%20be%20different%20depending%20on%20the%20latest%20and%20newest%20releases.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%20background%3A%20%23e2daf1%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERegarding%20the%20ARM%20client%20you%20can%20get%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fprojectkudu%2FARMClient%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EARMClient%3C%2FA%3E%20from%20GitHub.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorBruno%20Gabrielli_4%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Armclient.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F194274i088A2AFE0A4737BA%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22Armclient.png%22%20alt%3D%22Armclient.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWith%20all%20the%20necessary%20pieces%20in%20place%2C%20you%20can%20carry%20on%20the%20necessary%20operation%20and%20assemble%20the%20related%20command%20to%20fulfill%20your%20needs.%3C%2FP%3E%0A%3CP%3EBut%20what%20are%20the%20operation%20type%20that%20you%20can%20you%20accomplish%20as%20far%20as%20the%20data%20retention%20goes%3F%3C%2FP%3E%0A%3CP%3EThey%20can%20be%20basically%20summarized%20into%203%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EQuery%20data%20retention%20for%20either%20a%20specific%20table%20or%20the%20entire%20workspace.%20This%20can%20be%20helpful%20when%20you%20do%20not%20know%20if%20the%20customer%20set%20something%20up%20previously%3C%2FLI%3E%0A%3CLI%3ESet%2Fupdate%20data%20retention%3C%2FLI%3E%0A%3CLI%3EReset%20data%20retention%20back%20to%20the%20workspace%20general%20setting%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EBefore%20making%20any%20change%2C%20you%20need%20to%20make%20sure%20about%20which%20retention%20your%20resource%20is%20configured%20with.%20Simple%20one%3A%20just%20query%20the%20data%20retention%20by%20running%20the%20%3CSTRONG%3E%3CEM%3EGET%3C%2FEM%3E%3C%2FSTRONG%3E%20command%20through%20ARMClient%2C%20passing%20the%20full%20resource%20id.%3C%2FP%3E%0A%3CP%3EFor%20the%20entire%20post%20I%20will%20use%20my%20custom%20log%20table%20named%20%3CSTRONG%3E%3CEM%3EmyApplicationLog_CL%3C%2FEM%3E%3C%2FSTRONG%3E%20(it%20doesn%E2%80%99t%20make%20any%20difference%20whether%20it%20is%20a%20custom%20log%20or%20not)%2C%20hence%20the%20command%20will%20be%20as%20below%20(my%20subscription%20was%20intentionally%20masked%26nbsp%3B%3CIMG%20class%3D%22lia-deferred-image%20lia-image-emoji%22%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Fhtml%2Fimages%2Femoticons%2Fxd_40x40.gif%22%20alt%3D%22%3Axd%3A%22%20title%3D%22%3Axd%3A%22%20%2F%3E)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%20background%3A%20%23D9D9D9%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%20background%3A%20%23D9D9D9%3B%22%3E%3CEM%3EARMClient.exe%20get%20%22%2Fsubscriptions%2F********-****-****-****-************%2FresourceGroups%2Frg-dataretentionbytype%2Fproviders%2FMicrosoft.OperationalInsights%2Fworkspaces%2Fla-DataRetentionByType%3CMARK%3E%2FTables%2FmyApplicationLog_CL%3Fapi-version%3D2017-04-26-preview%22%3C%2FMARK%3E%3C%2FEM%3E%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%20background%3A%20%23D9D9D9%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%20background%3A%20%23d2f9d2%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%20background%3A%20%23d2f9d2%3B%22%3E%3CSTRONG%3E%3CEM%3ETip%3C%2FEM%3E%3C%2FSTRONG%3E%26nbsp%3B%3CEM%3EShould%20you%20want%20to%20retrieve%20retention%20for%20each%20and%20every%20table%20in%20the%20workspace%2C%20just%20remove%20the%20table%20name%20from%20the%20above%20command%2C%20making%20it%20like%20this%20one%20below%3A%3C%2FEM%3E%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%20background%3A%20%23d2f9d2%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%20background%3A%20%23d2f9d2%3B%22%3E%3CEM%3EARMClient.exe%20get%20%22%2Fsubscriptions%2F********-****-****-****-************%2FresourceGroups%2Frg-dataretentionbytype%2Fproviders%2FMicrosoft.OperationalInsights%2Fworkspaces%2Fla-DataRetentionByType%3CMARK%3E%2FTables%3Fapi-version%3D2017-04-26-preview%22%3C%2FMARK%3E%3C%2FEM%3E%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%20background%3A%20%23d2f9d2%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20you%20can%20see%20from%20the%20image%20there%E2%80%99s%20nothing%20about%20a%20specific%20retention.%20This%20means%20that%20the%20%3CSTRONG%3E%3CEM%3EmyApplicationLog_CL%3C%2FEM%3E%3C%2FSTRONG%3E%20table%20%3CU%3Eis%20inheriting%3C%2FU%3E%20the%20workspace%20setting%20whatever%20it%20is.%3C%2FP%3E%0A%3CP%3ENow%20let%E2%80%99s%20say%20that%20I%20want%20to%20set%20the%20retention%20for%20my%20custom%20log%20to%20%3CSTRONG%3E%3CEM%3E55%3C%2FEM%3E%3C%2FSTRONG%3E%20days.%3C%2FP%3E%0A%3CP%3ETo%20be%20able%20to%20set%20or%20update%20the%20given%20property%2C%20you%20need%20to%20specify%20its%20name%20and%20value%20after%20the%20resource%20id%20as%20part%20of%20the%20command%20in%20JSON%20format.%20In%20our%20case%20the%20property%20name%20is%20called%20%3CSTRONG%3E%3CEM%3EretentionInDays%2C%3C%2FEM%3E%3C%2FSTRONG%3E%20the%20value%20will%20be%20%3CSTRONG%3E%3CEM%3E55%3C%2FEM%3E%3C%2FSTRONG%3E%20and%20the%20format%20is%20the%20one%20used%20in%20the%20command%20below%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%20background%3A%20%23D9D9D9%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%20background%3A%20%23D9D9D9%3B%22%3E%3CEM%3EARMClient.exe%20put%20%22%2Fsubscriptions%2F********-****-****-****-************%2FresourceGroups%2Frg-dataretentionbytype%2Fproviders%2FMicrosoft.OperationalInsights%2Fworkspaces%2Fla-DataRetentionByType%2FTables%2FmyApplicationLog_CL%3Fapi-version%3D2017-04-26-preview%22%3CMARK%3E%22%7B'properties'%3A%7B'retentionInDays'%3A55%7D%7D%22%3C%2FMARK%3E%3C%2FEM%3E%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%20background%3A%20%23D9D9D9%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorBruno%20Gabrielli_6%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ARMClientPut.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F194269i0A0CD54458E029A7%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22ARMClientPut.png%22%20alt%3D%22ARMClientPut.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20I%20already%20anticipated%2C%20the%20retention%20set%20at%20the%20workspace%20level%20will%20not%20impact%20this%20table%20anymore.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBut%20what%20if%20I%20would%20to%20set%20it%20back%3F%26nbsp%3BWhat%20if%20I%20want%20to%20reset%20or%20revert%20any%20configuration%20that%20I%20could%20have%20made%20by%20mistake%3F%3C%2FP%3E%0A%3CP%3ELuckily%2C%20there%E2%80%99s%20the%20possibility%20to%20set%20the%20property%20to%20a%20null%20value.%3C%2FP%3E%0A%3CP%3EThis%20turns%20out%20to%20reset%20the%20configuration%20back%20to%20its%20default%20which%20is%20the%20workspace%20setting%20(whatever%20retention%20it%20has%20been%20configured%20with).%20Similarly%2C%20to%20previous%20command%2C%20you%20need%20to%20set%20the%20property%20value%2C%20this%20time%2C%20to%20%3CSTRONG%3E%3CEM%3Enull%3C%2FEM%3E%3C%2FSTRONG%3E%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%20background%3A%20%23D9D9D9%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%20background%3A%20%23D9D9D9%3B%22%3E%3CEM%3EARMClient.exe%20put%20%22%2Fsubscriptions%2F********-****-****-****-************%2FresourceGroups%2Frg-dataretentionbytype%2Fproviders%2FMicrosoft.OperationalInsights%2Fworkspaces%2Fla-DataRetentionByType%2FTables%2FmyApplicationLog_CL%3Fapi-version%3D2017-04-26-preview%22%3CMARK%3E%22%7B'properties'%3A%7B'retentionInDays'%3Anull%7D%7D%22%3C%2FMARK%3E%3C%2FEM%3E%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%20background%3A%20%23D9D9D9%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorBruno%20Gabrielli_7%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ARMClientPut_2.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F194273i48469B48C4139643%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22ARMClientPut_2.png%22%20alt%3D%22ARMClientPut_2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFrom%20now%20on%20data%20in%20my%20custom%20log%20table%20will%20be%20kept%20according%20to%20the%20workspace%20setting.%3C%2FP%3E%0A%3CP%3EI%20also%20want%20to%20mention%20something%20about%20the%20%E2%80%9Cdelete%20operation%20task%E2%80%9D.%3C%2FP%3E%0A%3CP%3ENowadays%20the%20%3CSTRONG%3E%3CU%3Etable%20deletion%20is%20not%20supported%3C%2FU%3E%3C%2FSTRONG%3E%20hence%20you%20can%20only%20delete%20the%20content.%3C%2FP%3E%0A%3CP%3EFor%20more%20information%20about%20data%20deletion%2C%20see%20the%20documentation%20at%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Fplatform%2Fpersonal-data-mgmt%23how-to-export-and-delete-private-data%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Fplatform%2Fpersonal-data-mgmt%23how-to-export-and-delete-private-data%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%20background%3A%20%23e2daf1%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%20background%3A%20%23e2daf1%3B%22%3E%3CSTRONG%3E%3CEM%3EIMPORTANT%3A%20%3C%2FEM%3E%3C%2FSTRONG%3E%26nbsp%3B%3CEM%3EDeletes%20in%20Log%20Analytics%20are%20destructive%20and%20non-reversible!%20Please%20use%20extreme%20caution%20in%20their%20execution%20and%20read%20carefully%20the%20above-mentioned%20documentation.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%20background%3A%20%23e2daf1%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20hope%20I%20gave%20you%20all%20the%20necessary%20elements%20to%20make%20the%20decision%20of%20changing%20or%20not%20the%20data%20retention%20as%20well%20as%20the%20important%20points%20to%20consider%20before%20making%20any%20decision.%3C%2FP%3E%0A%3CP%3EI%20also%20hope%20my%20technical%20guide%20on%20how%20to%20make%20the%20change%20is%20clear%20enough%20and%20helps%20you%20achieving%20the%20goal%20easily%20and%20quickly.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks%20to%20have%20gone%20through%20this%20long%20post%20and%20good%20luck%20with%20data%20retention%20by%20type%26nbsp%3B%3CIMG%20class%3D%22lia-deferred-image%20lia-image-emoji%22%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Fhtml%2Fimages%2Femoticons%2Fsmile_40x40.gif%22%20alt%3D%22%3Asmile%3A%22%20title%3D%22%3Asmile%3A%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBruno%20%26amp%3B%20Simone.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CFONT%20size%3D%222%22%3E%3CEM%3E%3CSTRONG%3EDisclaimer%3C%2FSTRONG%3E%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%3E%3C%2FFONT%3E%3C%2FSTRONG%3E%3CFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%3EThe%20sample%20scripts%20are%20not%20supported%20under%20any%20Microsoft%20standard%20support%20program%20or%20service.%20The%20sample%20scripts%20are%20provided%20AS%20IS%20without%20warranty%20of%20any%20kind.%20Microsoft%20further%20disclaims%20all%20implied%20warranties%20including%2C%20without%20limitation%2C%20any%20implied%20warranties%20of%20merchantability%20or%20of%20fitness%20for%20a%20particular%20purpose.%20The%20entire%20risk%20arising%20out%20of%20the%20use%20or%20performance%20of%20the%20sample%20scripts%20and%20documentation%20remains%20with%20you.%20In%20no%20event%20shall%20Microsoft%2C%20its%20authors%2C%20or%20anyone%20else%20involved%20in%20the%20creation%2C%20production%2C%20or%20delivery%20of%20the%20scripts%20be%20liable%20for%20any%20damages%20whatsoever%20(including%2C%20without%20limitation%2C%20damages%20for%20loss%20of%20business%20profits%2C%20business%20interruption%2C%20loss%20of%20business%20information%2C%20or%20other%20pecuniary%20loss)%20arising%20out%20of%20the%20use%20of%20or%20inability%20to%20use%20the%20sample%20scripts%20or%20documentation%2C%20even%20if%20Microsoft%20has%20been%20advised%20of%20the%20possibility%20of%20such%20damages.%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1416287%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20everybody%2C%20Bruno%20here%20again%20together%20with%20my%20Azure%20Sentinel%20colleague%26nbsp%3B-ERR%3AREF-NOT-FOUND-%40sifriger%26nbsp%3B(credits%20to%20you%20mate%20to%20have%20brought%20what%20we%E2%80%99re%20going%20to%20present%20to%20my%20attention).%3C%2FP%3E%0A%3CP%3EToday%2C%20I%E2%80%99ll%20walk%20you%20through%20the%20setting%20of%20different%20retention%20for%20a%20Azure%20Log%20Analytics%20workspace%20based%20on%20data%20types.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1416287%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EBrunoGabrielli%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1451972%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20Log%20Analytics%20-%20Data%20Retention%20By%20Type%20in%20Real%20Life%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1451972%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fswiftsolves-msft%2FPowerShell-Scripts%2Fblob%2Fmaster%2FTableRetentionReport.ps1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fswiftsolves-msft%2FPowerShell-Scripts%2Fblob%2Fmaster%2FTableRetentionReport.ps1%3C%2FA%3E%26nbsp%3B%7C%20%26lt%3B%26lt%3B%20This%20reports%20existing%20retention%20settings%20per%20table%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1467208%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20Log%20Analytics%20-%20Data%20Retention%20By%20Type%20in%20Real%20Life%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1467208%22%20slang%3D%22en-US%22%3E%3CP%3EGrateful%20for%20the%20post.%3CBR%20%2F%3EWhat%20about%20backup%20a%20Log%20analytics%20Workspace%3F%20It%20seems%20to%20me%20anything%20necessary%20to%20some%20legal%20compliances.%3CBR%20%2F%3EI%20undertstand%20that%20platform%20logs%20are%20cover%20but%20what%20about%20custom%20logs%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

Hello everybody, Bruno here again together with my Azure Sentinel colleague @sifriger (credits to you mate to have brought what we’re going to present to my attention).

Today, I’ll walk you through the setting of different retention for a Azure Log Analytics workspace based on data types.

 

First of all, let me refresh a little bit what a data type is in the Azure Log Analytics context: a data type is either a scalar data type (one of the built-in predefined types listed below), or a user-defined record (an ordered sequence of name/scalar-data-type pairs, such as the data type of a row of a table).

Let’s also refresh the data retention definition: the retention represents how long (the amount of time in days ) data is kept inside an Azure Log Analytics workspace (see Change the data retention period paragraph in the Manage usage and costs with Azure Monitor Logs article).

 

Now that we have both concepts refreshed and clear in mind, we can get to the point. As you have heard for sure, on October 08, 2019 a feature that allows you to set the retention by single data type (also referred as table) overriding the general workspace setting was announced through this official post.

What could be the reason why you might want to change the retention on a single table? There could be several and all could be valid. For instance, we could have:

  • Usage and costs control: as per Manage usage and costs with Azure Monitor Logs article, by operating on the data retention you proactively monitor ingested data volume and storage growth, and define limits to control those associated costs.
  • Limit performance data retention on an Azure Sentinel connected workspace: This one is pretty common. Performance data is normally considered stale after a couple of days or even earlier unless you want to store it for data warehouse purpose (i.e. baseline or troubleshooting). Moreover, natively, Azure Sentinel does not have any query which runs against or correlate with the Perf table, hence there could be no need to keep this data over the default retention (which 30 days for normal Log Analytics workspace or 90 days for Azure Sentinel connected ones).

Bear also in mind that there are also some important elements to be considered when dealing with data retention and before making the decision of changing it. As an example:

  • Correlation among tables could be impacted by different retention
  • Changing the retention at the workspace level will change the table retention any longer on the one previously modified
  • Should you need to align back to workspace retention, you need to reset what has been configured using the same method used to set it, hence you will get through the same steps and level of complexity.
  • For data collected earlier than October 2019 (when this feature was released), setting a lower retention for an individual type won’t affect your retention costs.

With all that said, should you need to set different retention per table, continue reading this post.

Setting data retention by type is not a feature offered at the portal interface level. In the Azure portal you can only set the retention for the entire workspace.

 

DataRetention.png

 

This means that you’ll need to use some simple ARM command.

So, moving on, is there anything else you need to know or have before moving ahead?

Easy answer: you need to know the resource id and have an ARM client to execute the command.

As far as the resource id goes, you first need to retrieve the Log Analytics workspace resource id. You can do that, thanks to Azure Resource Manager, directly from the Azure portal by using Resource Explorer:

 

ResourceExplorer.png

 

Once you get to the Resource Explorer page, expand Subscriptions and navigate all the resources till the one you want to operate on (in this case the Log Analytics workspace):

 

Resource.png

 

Once you get to it, in the right part you will get the JSON template of the given resource. Inside the template you have several key/value pairs and objects, among which there is the id that represents exactly the resourceid of the workspace for which you want to change the retention on a given table:

 

ResourceId.png

 

Now that you have the workspace resourceid, since tables do not appear as resource entries, you need an additional easy step. You need to add the table name and API information to execute the necessary command.

You can achieve that by adding the following string right after the resource id value just retrieved by paying attention to the table name (I intentionally put a placeholder here)

/Tables/MYTABLENAME?api-version=2017-04-26-preview

 

 

NOTE: the API version could be different depending on the latest and newest releases.

 

 

Regarding the ARM client you can get ARMClient from GitHub.

 

Armclient.png

 

With all the necessary pieces in place, you can carry on the necessary operation and assemble the related command to fulfill your needs.

But what are the operation type that you can you accomplish as far as the data retention goes?

They can be basically summarized into 3:

  • Query data retention for either a specific table or the entire workspace. This can be helpful when you do not know if the customer set something up previously
  • Set/update data retention
  • Reset data retention back to the workspace general setting

Before making any change, you need to make sure about which retention your resource is configured with. Simple one: just query the data retention by running the GET command through ARMClient, passing the full resource id.

For the entire post I will use my custom log table named myApplicationLog_CL (it doesn’t make any difference whether it is a custom log or not), hence the command will be as below (my subscription was intentionally masked :xd:)

 

 

ARMClient.exe get "/subscriptions/********-****-****-****-************/resourceGroups/rg-dataretentionbytype/providers/Microsoft.OperationalInsights/workspaces/la-DataRetentionByType/Tables/myApplicationLog_CL?api-version=2017-04-26-preview"

 

 

 

Tip Should you want to retrieve retention for each and every table in the workspace, just remove the table name from the above command, making it like this one below:

 

ARMClient.exe get "/subscriptions/********-****-****-****-************/resourceGroups/rg-dataretentionbytype/providers/Microsoft.OperationalInsights/workspaces/la-DataRetentionByType/Tables?api-version=2017-04-26-preview"

 

 

As you can see from the image there’s nothing about a specific retention. This means that the myApplicationLog_CL table is inheriting the workspace setting whatever it is.

Now let’s say that I want to set the retention for my custom log to 55 days.

To be able to set or update the given property, you need to specify its name and value after the resource id as part of the command in JSON format. In our case the property name is called retentionInDays, the value will be 55 and the format is the one used in the command below:

 

 

ARMClient.exe put "/subscriptions/********-****-****-****-************/resourceGroups/rg-dataretentionbytype/providers/Microsoft.OperationalInsights/workspaces/la-DataRetentionByType/Tables/myApplicationLog_CL?api-version=2017-04-26-preview" "{'properties':{'retentionInDays':55}}"

 

 

ARMClientPut.png

 

As I already anticipated, the retention set at the workspace level will not impact this table anymore.

 

But what if I would to set it back? What if I want to reset or revert any configuration that I could have made by mistake?

Luckily, there’s the possibility to set the property to a null value.

This turns out to reset the configuration back to its default which is the workspace setting (whatever retention it has been configured with). Similarly, to previous command, you need to set the property value, this time, to null:

 

 

ARMClient.exe put "/subscriptions/********-****-****-****-************/resourceGroups/rg-dataretentionbytype/providers/Microsoft.OperationalInsights/workspaces/la-DataRetentionByType/Tables/myApplicationLog_CL?api-version=2017-04-26-preview" "{'properties':{'retentionInDays':null}}"

 

 

ARMClientPut_2.png

 

From now on data in my custom log table will be kept according to the workspace setting.

I also want to mention something about the “delete operation task”.

Nowadays the table deletion is not supported hence you can only delete the content.

For more information about data deletion, see the documentation at https://docs.microsoft.com/en-us/azure/azure-monitor/platform/personal-data-mgmt#how-to-export-and-d...

 

 

IMPORTANT:  Deletes in Log Analytics are destructive and non-reversible! Please use extreme caution in their execution and read carefully the above-mentioned documentation.

 

 

I hope I gave you all the necessary elements to make the decision of changing or not the data retention as well as the important points to consider before making any decision.

I also hope my technical guide on how to make the change is clear enough and helps you achieving the goal easily and quickly.

 

Thanks to have gone through this long post and good luck with data retention by type :smile:

 

Bruno & Simone.

 

Disclaimer
The sample scripts are not supported under any Microsoft standard support program or service. The sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.

2 Comments
Microsoft
Occasional Visitor

Grateful for the post.
What about backup a Log analytics Workspace? It seems to me anything necessary to some legal compliances.
I undertstand that platform logs are cover but what about custom logs?