Share via


az grafana data-source

注意

此參考是 Azure CLI 的 amg 延伸模組的一部分(2.38.0 版或更高版本)。 擴充功能會在您第一次執行 az grafana data-source 命令時自動安裝。 深入了解擴充功能。

管理實例數據源的命令。

命令

名稱 Description 類型 狀態
az grafana data-source create

建立資料來源。

副檔名 GA
az grafana data-source delete

刪除資料來源。

副檔名 GA
az grafana data-source list

列出實例的所有數據源。

副檔名 GA
az grafana data-source query

查詢具有後端實作的數據源。

副檔名 GA
az grafana data-source show

取得數據源的詳細數據。

副檔名 GA
az grafana data-source update

更新數據源。

副檔名 GA

az grafana data-source create

建立資料來源。

az grafana data-source create --definition
                              --name
                              [--api-key]
                              [--resource-group]

範例

使用受控識別建立 Azure 監視器數據源

az grafana data-source create -n MyGrafana --definition '{
  "access": "proxy",
  "jsonData": {
    "azureAuthType": "msi",
    "subscriptionId": "3a7edf7d-1488-4017-a908-111111111111"
  },
  "name": "Azure Monitor-3",
  "type": "grafana-azure-monitor-datasource"
}'

使用應用程式註冊建立 Azure 監視器數據源

az grafana data-source create -n MyGrafana --definition '{
  "name": "Azure Monitor-2",
  "type": "grafana-azure-monitor-datasource",
  "access": "proxy",
  "jsonData": {
    "subscriptionId": "3a7edf7d-1488-4017-a908-111111111111",
    "azureAuthType": "clientsecret",
    "cloudName": "azuremonitor",
    "tenantId": "72f988bf-86f1-41af-91ab-111111111111",
    "clientId": "fb31a2f5-9122-4be9-9705-111111111111"
  },
  "secureJsonData": { "clientSecret": "verySecret" }
}'

使用受控識別建立 Azure 數據總管數據源

az grafana data-source create -n MyGrafana --definition '{
  "name": "Azure Data Explorer Datasource-2",
  "type": "grafana-azure-data-explorer-datasource",
  "access": "proxy",
  "jsonData": {
    "dataConsistency": "strongconsistency",
    "clusterUrl": "https://mykusto.westcentralus.kusto.windows.net"
  }
}'

使用應用程式註冊建立 Azure 數據總管數據源

az grafana data-source create -n MyGrafana --definition '{
  "name": "Azure Data Explorer Datasource-1",
  "type": "grafana-azure-data-explorer-datasource",
  "access": "proxy",
  "jsonData": {
    "clusterUrl": "https://mykusto.westcentralus.kusto.windows.net",
    "azureCredentials": {
      "authType": "clientsecret",
      "azureCloud": "AzureCloud",
      "tenantId": "72f988bf-86f1-41af-91ab-111111111111",
      "clientId": "fb31a2f5-9122-4be9-9705-111111111111"
    }
  },
  "secureJsonData": { "azureClientSecret": "verySecret" }
}'

使用應用程式註冊建立 Azure 受控 Prometheus 數據源

az grafana data-source create -n MyGrafana --definition '{
  "name": "Azure Managed Prometheus-1",
  "type": "prometheus",
  "access": "proxy",
  "url": "https://myprom-abcd.westcentralus.prometheus.monitor.azure.com",
  "jsonData": {
    "httpMethod": "POST",
    "azureCredentials": {
      "authType": "clientsecret",
      "azureCloud": "AzureCloud",
      "tenantId": "72f988bf-86f1-41af-91ab-111111111111",
      "clientId": "fb31a2f5-9122-4be9-9705-111111111111"
    },
    "timeInterval": "30s"
  },
  "secureJsonData": { "azureClientSecret": "verySecret" }
}'

使用受控識別建立 Azure 受控 Prometheus 數據源

az grafana data-source create -n MyGrafana --definition '{
  "name": "Azure Managed Prometheus-1",
  "type": "prometheus",
  "access": "proxy",
  "url": "https://myprom-jryu.westcentralus.prometheus.monitor.azure.com",
  "jsonData": {
    "httpMethod": "POST",
    "azureCredentials": { "authType": "msi" }
  }
}'

建立 Azure SQL 數據源

az grafana data-source create -n MyGrafana --definition '{
  "access": "proxy",
  "database": "testdb",
  "jsonData": {
    "authenticationType": "SQL Server Authentication",
    "encrypt": "false"
  },
  "secureJsonData": {
    "password": "verySecretPassword"
  },
  "name": "Microsoft SQL Server",
  "type": "mssql",
  "url": "testsql.database.windows.net",
  "user": "admin1"
}'

必要參數

--definition

具有數據源定義的 Json 字串,或具有這類內容的檔案路徑。

--name -n

Azure 受控 Grafana 的名稱。

選擇性參數

--api-key --token -t

Api 金鑰或服務帳戶令牌,這是隨機產生的字串,用來與 Grafana 端點互動;如果遺失,CLI 將會使用目前登入用戶的認證。

--resource-group -g

資源群組的名稱。 您可以使用 az configure --defaults group=<name> 來設定預設群組。

全域參數
--debug

增加記錄詳細資訊,以顯示所有偵錯記錄。

--help -h

顯示此說明訊息並結束。

--only-show-errors

只顯示錯誤,隱藏警告。

--output -o

輸出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
預設值: json
--query

JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/

--subscription

訂用帳戶的名稱或識別碼。 您可以使用 來設定預設訂用 az account set -s NAME_OR_ID帳戶。

--verbose

增加記錄詳細資訊。 使用 --debug 來取得完整偵錯記錄。

az grafana data-source delete

刪除資料來源。

az grafana data-source delete --data-source
                              --name
                              [--api-key]
                              [--resource-group]

必要參數

--data-source

名稱、標識碼、UID,可識別數據源。 CLI 會依名稱、標識碼和 uid 的順序搜尋,直到找到相符項目為止。

--name -n

Azure 受控 Grafana 的名稱。

選擇性參數

--api-key --token -t

Api 金鑰或服務帳戶令牌,這是隨機產生的字串,用來與 Grafana 端點互動;如果遺失,CLI 將會使用目前登入用戶的認證。

--resource-group -g

資源群組的名稱。 您可以使用 az configure --defaults group=<name> 來設定預設群組。

全域參數
--debug

增加記錄詳細資訊,以顯示所有偵錯記錄。

--help -h

顯示此說明訊息並結束。

--only-show-errors

只顯示錯誤,隱藏警告。

--output -o

輸出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
預設值: json
--query

JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/

--subscription

訂用帳戶的名稱或識別碼。 您可以使用 來設定預設訂用 az account set -s NAME_OR_ID帳戶。

--verbose

增加記錄詳細資訊。 使用 --debug 來取得完整偵錯記錄。

az grafana data-source list

列出實例的所有數據源。

az grafana data-source list --name
                            [--api-key]
                            [--resource-group]

必要參數

--name -n

Azure 受控 Grafana 的名稱。

選擇性參數

--api-key --token -t

Api 金鑰或服務帳戶令牌,這是隨機產生的字串,用來與 Grafana 端點互動;如果遺失,CLI 將會使用目前登入用戶的認證。

--resource-group -g

資源群組的名稱。 您可以使用 az configure --defaults group=<name> 來設定預設群組。

全域參數
--debug

增加記錄詳細資訊,以顯示所有偵錯記錄。

--help -h

顯示此說明訊息並結束。

--only-show-errors

只顯示錯誤,隱藏警告。

--output -o

輸出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
預設值: json
--query

JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/

--subscription

訂用帳戶的名稱或識別碼。 您可以使用 來設定預設訂用 az account set -s NAME_OR_ID帳戶。

--verbose

增加記錄詳細資訊。 使用 --debug 來取得完整偵錯記錄。

az grafana data-source query

查詢具有後端實作的數據源。

az grafana data-source query --data-source
                             --name
                             [--api-key]
                             [--conditions]
                             [--from]
                             [--internal-ms]
                             [--max-data-points]
                             [--query-format]
                             [--resource-group]
                             [--to]

必要參數

--data-source

名稱、標識碼、UID,可識別數據源。 CLI 會依名稱、標識碼和 uid 的順序搜尋,直到找到相符項目為止。

--name -n

Azure 受控 Grafana 的名稱。

選擇性參數

--api-key --token -t

Api 金鑰或服務帳戶令牌,這是隨機產生的字串,用來與 Grafana 端點互動;如果遺失,CLI 將會使用目前登入用戶的認證。

--conditions

以的格式 <name>=<value>分隔空格條件。

--from

iso 8601 中的開始時間,例如 '2022-01-02T16:15:00'。 默認值:提前 1 小時。

--internal-ms

時間間隔,以毫秒為單位的時間序列。 預設值:1000。

預設值: 1000
--max-data-points

儀錶板面板可以轉譯的數據點數量上限。 預設值:1000。

預設值: 100
--query-format

resule 的格式,例如 table、time_series。

--resource-group -g

資源群組的名稱。 您可以使用 az configure --defaults group=<name> 來設定預設群組。

--to

iso 8601 中的結束時間,例如 '2022-01-02T17:15:00'。 默認值:目前時間。

全域參數
--debug

增加記錄詳細資訊,以顯示所有偵錯記錄。

--help -h

顯示此說明訊息並結束。

--only-show-errors

只顯示錯誤,隱藏警告。

--output -o

輸出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
預設值: json
--query

JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/

--subscription

訂用帳戶的名稱或識別碼。 您可以使用 來設定預設訂用 az account set -s NAME_OR_ID帳戶。

--verbose

增加記錄詳細資訊。 使用 --debug 來取得完整偵錯記錄。

az grafana data-source show

取得數據源的詳細數據。

az grafana data-source show --data-source
                            --name
                            [--api-key]
                            [--resource-group]

必要參數

--data-source

名稱、標識碼、UID,可識別數據源。 CLI 會依名稱、標識碼和 uid 的順序搜尋,直到找到相符項目為止。

--name -n

Azure 受控 Grafana 的名稱。

選擇性參數

--api-key --token -t

Api 金鑰或服務帳戶令牌,這是隨機產生的字串,用來與 Grafana 端點互動;如果遺失,CLI 將會使用目前登入用戶的認證。

--resource-group -g

資源群組的名稱。 您可以使用 az configure --defaults group=<name> 來設定預設群組。

全域參數
--debug

增加記錄詳細資訊,以顯示所有偵錯記錄。

--help -h

顯示此說明訊息並結束。

--only-show-errors

只顯示錯誤,隱藏警告。

--output -o

輸出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
預設值: json
--query

JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/

--subscription

訂用帳戶的名稱或識別碼。 您可以使用 來設定預設訂用 az account set -s NAME_OR_ID帳戶。

--verbose

增加記錄詳細資訊。 使用 --debug 來取得完整偵錯記錄。

az grafana data-source update

更新數據源。

az grafana data-source update --data-source
                              --definition
                              --name
                              [--api-key]
                              [--resource-group]

必要參數

--data-source

名稱、標識碼、UID,可識別數據源。 CLI 會依名稱、標識碼和 uid 的順序搜尋,直到找到相符項目為止。

--definition

具有數據源定義的 Json 字串,或具有這類內容的檔案路徑。

--name -n

Azure 受控 Grafana 的名稱。

選擇性參數

--api-key --token -t

Api 金鑰或服務帳戶令牌,這是隨機產生的字串,用來與 Grafana 端點互動;如果遺失,CLI 將會使用目前登入用戶的認證。

--resource-group -g

資源群組的名稱。 您可以使用 az configure --defaults group=<name> 來設定預設群組。

全域參數
--debug

增加記錄詳細資訊,以顯示所有偵錯記錄。

--help -h

顯示此說明訊息並結束。

--only-show-errors

只顯示錯誤,隱藏警告。

--output -o

輸出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
預設值: json
--query

JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/

--subscription

訂用帳戶的名稱或識別碼。 您可以使用 來設定預設訂用 az account set -s NAME_OR_ID帳戶。

--verbose

增加記錄詳細資訊。 使用 --debug 來取得完整偵錯記錄。