azure application insights logs on the command line
So I’m working with azure now and naturally wants to access logs on the command line
and this is the story about how to do that. Including setting up the azure cli tool
called az
.
To start with we need to install az
. Microsoft got their own keys so we need to add that.
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
Install with dnf
.
sudo dnf install azure-cli
And then verify the installation.
az login
This will get you redirected to do some oauth in your brower. The browser is very silent
but hopefully it just works. To start exploting all the endless possibilities in this cloud
just run az help
to see all the available options. Also not the these can be nested.
Application insights lives inside the monitor are for example.
Now you may want to run az monitor app-insights
but this will cause installation of
extensions. For me this failed. On fedora it turns out - deep down in the debug messages - that pip is missing.
sudo dnf install pip
Then you would probably need to set the correct subscription (depending on your azure setup obvsly)
az account set --subscription <subscription-id>
You can find subscription-id in the UI or use az account list
to see subscriptions availabe to you. Here it is the actual id you will need to use. Looks like a SHA.
Finally time to get some logs.
az monitor app-insights events show --app <app-id> --type traces
This gives us json - not very eye friendly. So my next step in this world is to pass the output to jq and probably write some convenience aliases for this. Over and out.
written by fredrik at 2024-06-14