Script Sample - Export All OMS Log Analytics Saved Searches

@20aman    Jul 25, 2018

If you work with OMS Log Analytics then you end up working with lots of queries. To manage the most used queries specific to your environment you save these as Saved Searches. These can be reusable in other projects as well. Therefore, you will want to export these saved searches.

How it works

This is the most simple but very useful script sample. It exports by simply using the below cmdlet. You can use the below cmdlet alone as well instead of using the whole script, if you are already logged into Azure and have the right subscription selected.

(Get-AzureRmOperationalInsightsSavedSearch -ResourceGroupName $ResourceGroupName -WorkspaceName $WorkspaceName).Value.Properties | ConvertTo-Json

Note that it uses "ConvertTo-Json" cmdlet to export the Saved Searches to JSON output. You can later reuse this JSON to import these saved searches into a different environment as well.

Location of the Script

You can find this script in GitHub at this location: Export Log Analytics Saved Searches

Comments powered by Disqus