你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

az grafana data-source

注意

此参考是 Azure CLI(版本 2.38.0 或更高版本)的 amg 扩展的一部分。 该扩展将在首次运行 az grafana data-source 命令时自动安装。 详细了解扩展。

用于管理实例数据源的命令。

命令

名称 说明 类型 状态
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 Monitor 数据源

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 Monitor 数据源

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

订阅的名称或 ID。 可以使用 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

可以标识数据源的名称、ID、uid。 CLI 将按名称、ID 和 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

订阅的名称或 ID。 可以使用 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

订阅的名称或 ID。 可以使用 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

可以标识数据源的名称、ID、uid。 CLI 将按名称、ID 和 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 的格式,例如表,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

订阅的名称或 ID。 可以使用 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

可以标识数据源的名称、ID、uid。 CLI 将按名称、ID 和 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

订阅的名称或 ID。 可以使用 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

可以标识数据源的名称、ID、uid。 CLI 将按名称、ID 和 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

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。