During Public Preview you can use the Team plan for free, and get an early-adopter discount at GA. Sign in
Deploying a Log Analytics Workspace
This guide shows you how to deploy a Log Analytics Workspace against Locally. As with the other guides we're going to use the Azure CLI, but the same resources can be provisioned with HashiCorp Terraform, Pulumi or Bicep too.
Before you start
- The Azure CLI (
az) installed. - Locally installed, with Locally Setup completed.
1. Start Locally
Firstly, we need to launch Locally which we can do from a terminal by running:
$
locally build
Once Locally has started, the Locally Dashboard will open automatically:
2. Create a Resource Group
Next we can create the Resource Group:
$
locally run az group create -n sample-resources -l berlin
There's two things to note here:
- The Azure CLI supports Automatic Configuration, meaning that it can automatically be configured to work against Locally just by prefixing commands with
locally run. - Locally intentionally uses a different set of locations to Azure as a safety precaution, so that you can be confident you're deploying against Locally rather than regular Azure. You can also configure Locally to use the Azure locations too, but you'll want to be extra sure that you're prefixing commands with
locally runwhen you do.
3. Create the Workspace
With the Resource Group in place, we can create the workspace:
$
locally run az monitor log-analytics workspace create -g sample-resources -n sample-logs -l berlin
{
"customerId": "92f28e2b-01b6-44ba-9468-c82cedeabb96",
"name": "sample-logs",
"retention": 30,
"sku": "PerGB2018"
}
Two things worth knowing about that response:
customerIdis the workspace ID - the value agents and diagnostic settings use to identify where to send data. It's generated for you, so it's the thing to capture if you're wiring something up.retentionandskucome back with the same defaults Azure applies - 30 days onPerGB2018- rather than being blank.
We can read the workspace ID back at any point:
$
locally run az monitor log-analytics workspace show -g sample-resources -n sample-logs --query customerId -o tsv
And list the workspaces in the Resource Group:
$
locally run az monitor log-analytics workspace list -g sample-resources --query "[].{Name:name, Sku:sku.name, Retention:retentionInDays}" -o table
Note
We can see the Log Analytics workspace in the Locally Dashboard too:
4. Tidy up
Finally, we can tidy up. To remove the Resource Group and everything within it:
$
locally run az group delete -n sample-resources --yes
There's nothing billable to clean up, since everything ran on your machine, but it's still worth checking your teardown scripts work here before you run them against Azure.
Doing this with other tooling
Whilst this guide used the Azure CLI, Log Analytics works the same way through any of the tooling that Locally supports - a Microsoft.OperationalInsights/workspaces resource in HashiCorp Terraform or OpenTofu, Pulumi, Bicep or an ARM Template all provision against Locally in the same way, with only the location changed.
Next steps
To send logs to the workspace and query them, see the Log Analytics Emulator. Diagnostic Settings shows how to route a resource's logs into a workspace like this one.
Should you encounter any issues, please take a look at the troubleshooting section, reach out in our Discord or open an issue and we'll take a look.
Resource types this guide uses
These are the Azure resource types this guide creates in Locally:
During Public Preview you can use the Team plan for free, and get an early-adopter discount at GA. Sign in