Azure / Azure/azure-cli

az grafana dashboard fails when using input paramaters

Open
#29,449 1 comment 0 reactions 0 assignees View on GitHub
amg bug Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### Describe the bug

az grafana dashboard import fails when using inputs with error:
"missing dashboard input variable "

I can import the same json manually without any issue on Azure Managed Grafana dashboard, but I want to automate this process.

See attached sample:
[aio-health-1701881753512.json](https://github.com/user-attachments/files/16352138/aio-health-1701881753512.json)

### Related command

az grafana dashboard import --definition $SAMPLE_DASHBOARD_PATH --name $GRAFANA_NAME --resource-group $RESOURCE_GROUP --verbose

### Errors

image

Adjust input by adding 'dashboard' field
b'{"message":"dashboard import failed: missing dashboard input variable VAR_AIO_DP_SELF_TEST_PIPELINE","traceID":"483b1f95f198ceaf5ca9c67a4cf00633"}'
400 Client Error: Bad Request for url: https://aio-obs-36p-grafana-f4hke5fccwbqdmdj.eus2.grafana.azure.com/api/dashboards/import

### Issue script & Debug output

az grafana dashboard import --definition $SAMPLE_DASHBOARD_PATH --name $GRAFANA_NAME --resource-group $RESOURCE_GROUP --verbose --debug

cli.knack.cli: Command arguments: ['grafana', 'dashboard', 'import', '--definition', '/workspaces/MyFolder/infra/observability/grafana-aio-dashboards/aio-health-1701881753512.json', '--name', 'xxxxx-grafana', '--resource-group', 'xxxxxxx', '--verbose', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [, , ]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'grafana': ['azext_amg']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: Total (0) 0.000 0 0
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name Load Time Groups Commands Directory
cli.azure.cli.core: amg 0.171 9 45 /home/vscode/.azure/cliextensions/amg
cli.azure.cli.core: Total (1) 0.171 9 45
cli.azure.cli.core: Loaded 9 groups, 45 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : grafana dashboard import
cli.azure.cli.core: Command table: grafana dashboard import
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate []
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/vscode/.azure/commands/2024-07-23.17-02-40.grafana_dashboard_import.27686.log'.
az_command_data_logger: command args: grafana dashboard import --definition {} --name {} --resource-group {} --verbose --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [.add_subscription_parameter at 0x7fcf9afe2ca0>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [.add_ids_arguments at 0x7fcf9afe2d40>, .add_cache_arguments at 0x7fcf9afe2e80>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [, , .parse_ids_arguments at 0x7fcf9afe2de0>]
az_command_data_logger: extension name: amg
az_command_data_logger: extension version: 1.3.5
cli.azure.cli.core.util: attempting to read file /workspaces/MS-EXT-FOFEnterpriseEngagement/infra/observability/grafana-aio-dashboards/aio-health-1701881753512.json as utf-8-sig
cli.azext_amg.custom: Adjust input by adding 'dashboard' field
cli.azure.cli.core.commands.client_factory: Getting management service client client_type=DashboardManagementClient
......
urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
.....
...
cli.azure.cli.core.sdk.policies: Request method: 'GET'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies: 'Accept': 'application/json'
cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': '5ea5af7a-4915-11ef-a791-0242ac110002'
cli.azure.cli.core.sdk.policies: 'CommandName': 'grafana dashboard import'
cli.azure.cli.core.sdk.policies: 'ParameterSetName': '--definition --name --resource-group --verbose --debug'
cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.62.0 (DEB) azsdk-python-core/1.28.0 Python/3.11.8 (Linux-5.15.146.1-microsoft-standard-WSL2-x86_64-with-glibc2.31)'
cli.azure.cli.core.sdk.policies: 'Authorization': '*****'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: This request has no body
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "GET /subscriptions/.../xxxxxxxxx-grafana?api-version=2023-09-01 HTTP/1.1" 200 1305
cli.azure.cli.core.sdk.policies: Response status: 200

cli.azure.cli.core.sdk.policies: 'Date': 'Tue, 23 Jul 2024 17:02:40 GMT'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: {"id":"/subscriptions/xxxxxxxxxxxx/resourceGroups/xxxxxxxx/providers/Microsoft.Dashboard/grafana/xxxxxxxxx","name":"xxxxxxxxx","type":"microsoft.dashboard/grafana","sku":{"name":"Standard"},"location":"eastus2","tags":{},"systemData":{"createdBy":"xxxxxxxxxxxxxxxxxx","createdByType":"User","createdAt":"2024-07-22T19:16:33.2578497Z","lastModifiedBy":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","lastModifiedByType":"User","lastModifiedAt":"2024-07-22T19:16:33.2578497Z"},"identity":{"principalId":"xxxxxxxxxxxxxxxxxxxx","tenantId":"xxxxxxxxxxxxxxxxx","type":"SystemAssigned"},"properties":{"provisioningState":"Succeeded","grafanaVersion":"10.4.3","endpoint":"https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.grafana.azure.com","zoneRedundancy":"Disabled","publicNetworkAccess":"Enabled","autoGeneratedDomainNameLabelScope":"TenantReuse","apiKey":"Disabled","deterministicOutboundIP":"Disabled","grafanaIntegrations":{"azureMonitorWorkspaceIntegrations":[{"azureMonitorWorkspaceResourceId":"xxxxxxxxxxxxxxx"}]},"grafanaConfigurations":{"smtp":{"enabled":false}},"grafanaMajorVersion":"10"}}
urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
msal.authority: Initializing with Entra authority:
.......................
urllib3.connectionpool: Starting new HTTPS connection (1): xxxxxxxxxxxx
urllib3.connectionpool: xxxxxxxxxxxxxxxx 3 "GET /api/datasources HTTP/1.1" 200 914
urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
msal.authority: Initializing with Entra authority: xxxxxxxxxxxxxxxxxxxxxx
msal.application: Broker enabled? None
cli.azure.cli.core.auth.msal_authentication:xxxxxxxxxxxxxx
msal.application: Cache hit an AT
msal.telemetry: Generate or reuse correlation_id: a72b9ee4-2cf1-4003-9a3e-02d3c91fdf1f
urllib3.connectionpool: Starting new HTTPS connection (1): xxxxxxxxxxxxxxx.grafana.azure.com:443
urllib3.connectionpool: xxxxxxxxxxxxxxxxxx "POST /api/dashboards/import HTTP/1.1" 400 153
cli.azext_amg.custom: b'{"message":"dashboard import failed: missing dashboard input variable VAR_AIO_DP_SELF_TEST_PIPELINE","traceID":"2e4c29aa07e0c4741feb776a33682722"}'
cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "/opt/az/lib/python3.11/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 664, in execute
raise ex
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 731, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 701, in _run_job
result = cmd_copy(params)
^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 334, in __call__
return self.handler(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(**command_args)
^^^^^^^^^^^^^^^^^^
File "/home/vscode/.azure/cliextensions/amg/azext_amg/custom.py", line 411, in import_dashboard
response = _send_request(cmd, resource_group_name, grafana_name, "post", "/api/dashboards/import",
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.azure/cliextensions/amg/azext_amg/custom.py", line 905, in _send_request
response.raise_for_status()
File "/opt/az/lib/python3.11/site-packages/requests/models.py", line 1024, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://aio-obs-36p-grafana-f4hke5fccwbqdmdj.eus2.grafana.azure.com/api/dashboards/import

cli.azure.cli.core.azclierror: 400 Client Error: Bad Request for url: https://aio-obs-36p-grafana-f4hke5fccwbqdmdj.eus2.grafana.azure.com/api/dashboards/import
az_command_data_logger: 400 Client Error: Bad Request for url: https://aio-obs-36p-grafana-f4hke5fccwbqdmdj.eus2.grafana.azure.com/api/dashboards/import
cli.knack.cli: Event: Cli.PostExecute []
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 1.874 seconds (init: 0.220, invoke: 1.654)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.client: Accumulated 0 events. Flush the clients.
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 4088 in cache
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "/opt/az/bin/python3 /opt/az/lib/python3.11/site-packages/azure/cli/telemetry/__init__.py /home/vscode/.azure"
telemetry.process: Return from creating process
telemetry.main: Finish creating telemetry upload process.

### Expected behavior

The json files that I can import manually to Azure Managed Grafana can also be imported using `az grafana dashboard import`

### Environment Summary

azure-cli 2.62.0

core 2.62.0
telemetry 1.1.0

Extensions:
amg 1.3.5
azure-iot-ops 0.5.1b1
connectedk8s 1.7.3
customlocation 0.1.3
eventgrid 1.0.0b1
k8s-extension 1.6.1

Dependencies:
msal 1.28.1
azure-mgmt-resource 23.1.1

Python location '/opt/az/bin/python3'
Extensions directory '/home/vscode/.azure/cliextensions'

Python (Linux) 3.11.8 (main, Jul 4 2024, 02:23:43) [GCC 10.2.1 20210110]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.