Azure / azure-cli-extensions

Public Repository for Extensions of Azure CLI.
https://docs.microsoft.com/en-us/cli/azure
MIT License
384 stars 1.24k forks source link

[Monitor] log-analytics query workspace failing with 'PathNotFoundError', blocking queries #3914

Open paulyuk opened 3 years ago

paulyuk commented 3 years ago

Extension name (the extension in question)

log-analytics

Description of issue (in as much detail as possible)

I'm trying to use the workspace query feature. This morning it appears to be broken on all my machines, and maybe it is something on the server?

I try to:

az monitor log-analytics query -w workerappslogs --analytics-query "AzureActivity | summarize count() by bin(timestamp, 1h)" -t P3DT12H --debug

And receive this error:

az_command_data_logger: PathNotFoundError: The requested path does not exist

With --debug I see this specific error which looks like something coming back unexpected from server side:

msrest.exceptions: (PathNotFoundError) The requested path does not exist cli.azure.cli.core.util: azure.cli.core.util.handle_exception is called with an exception: cli.azure.cli.core.util: Traceback (most recent call last): File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 231, in invoke cmd_result = self.invocation.execute(args) File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 657, in execute raise ex File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 720, in _run_jobs_serially results.append(self._run_job(expanded_arg, cmd_copy)) File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 691, in _run_job result = cmd_copy(params) File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 328, in __call__ return self.handler(*args, **kwargs) File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler return op(**command_args) File "/home/pyadmin/.azure/cliextensions/log-analytics/azext_loganalytics/custom.py", line 14, in execute_query return client.query(workspace, QueryBody(query=analytics_query, timespan=timespan, workspaces=workspaces)) File "/home/pyadmin/.azure/cliextensions/log-analytics/azext_loganalytics/vendored_sdks/loganalytics/log_analytics_data_client.py", line 120, in query


danhadari74 commented 3 years ago

you should be using your workspace id and not the workspace name

yonzhan commented 3 years ago

Monitor

paulyuk commented 3 years ago

Thank you @danhadari you are right I needed workspace ID* rather than name in query! Could we make that error message better? not sure why that yields "path not found".

Next, I took this query straight from the docs and it is invalid due to timestamp field: https://docs.microsoft.com/en-us/cli/azure/monitor/log-analytics?view=azure-cli-latest#az_monitor_log_analytics_query az monitor log-analytics query -w workspace-customId --analytics-query "AzureActivity | summarize count() by bin(timestamp, 1h)" -t P3DT12H

I suppose this issue is more about improving error messages and docs. Cheers, Paul