Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用RESTAPI获取Azure事件中心指标?_Python_Rest_Azure_Azure Eventhub_Cortana Intelligence - Fatal编程技术网

Python 使用RESTAPI获取Azure事件中心指标?

Python 使用RESTAPI获取Azure事件中心指标?,python,rest,azure,azure-eventhub,cortana-intelligence,Python,Rest,Azure,Azure Eventhub,Cortana Intelligence,我正在尝试使用rest API获取事件中心度量, 阅读和 我有python代码,可以调用url并得到响应 我目前正在尝试以下代码 def get_metrics(subscription, eventhub, cert, specific_partition=None): apiversion = '2014-01' namespace = eventhub['namespace'] eventhubname = eventhub['name'] url = "h

我正在尝试使用rest API获取事件中心度量, 阅读和 我有python代码,可以调用url并得到响应 我目前正在尝试以下代码

def get_metrics(subscription, eventhub, cert, specific_partition=None):
    apiversion = '2014-01'
    namespace = eventhub['namespace']
    eventhubname = eventhub['name']
    url = "https://management.core.windows.net/{}/services/ServiceBus/Namespaces/{}/eventhubs/{}/Metrics/requests.total/Rollups/P1D/Values/?$filter=timestamp%20gt%20datetime'2016-04-09T00:00:00.0000000Z'&api-version={}".format(
        subscription, namespace, eventhubname, apiversion)
    request = requests.Request('GET', url, headers=DEFAULT_HEADERS).prepare()
    session = requests.Session()
    if cert is None or not os.path.isfile(cert):
        raise ValueError('You must give certificate file')
    session.cert = cert
    result = session.send(request)
    return result
我的问题是url,当在上面的代码中使用url时,我得到

<Error xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Code>InternalError</Code><Message>The server encountered an internal error. Please retry the request.</Message></Error>
我可以让API输出所有可能的汇总和所有可能的指标,但当尝试获取实际值时,它失败了


url中是否有错误,或者是azure/azure documantation中的错误?

通常,当我们出现此问题时,这意味着我们为Rest API组合的端点存在错误,因此服务在解析端点时会引发异常

与我成功的测试相比,我发现有趣的是过滤器参数
timestamp
引发的问题,其第一个字母应大写为
timestamp
。以下端点在我这方面工作得很好。希望对你有帮助

url = "https://management.core.windows.net/{}/services/ServiceBus/Namespaces/{}/eventhubs/{}/Metrics/requests.total/Rollups/P1D/Values/?$filter=Timestamp%20gt%20datetime'2016-04-09T00:00:00.0000000Z'&api-version={}".format(
        subscription, namespace, eventhubname, '2012-03-01')

您的
默认\u标题是什么?只是内容类型和授权?内容类型和x-ms-version,我使用SessionTanks的证书,您也可以更新azure站点上的文档吗?