【问题标题】:Where to find Access log for mastekey access in Azure Cosmos DB在 Azure Cosmos DB 中哪里可以找到 masterkey 访问的访问日志
【发布时间】:2017-10-16 17:47:18
【问题描述】:

您能否帮我了解我在哪里可以找到使用主密钥访问 CosmosDB/DocumentDB azure 的所有活动的日志。

背景: 我在日志中只能找到访问 azure 上的文档数据库的用户 ID。我们还在 python 中使用 Pydocumentdb 编写了一个脚本,该脚本使用 masterkey 从 Azure Cosmos DB 访问数据。但在日志中都看不到。

谢谢

【问题讨论】:

  • 嗨,现在有更新吗?
  • 您好,我请假了,我会在周五之前确认答复。
  • 当然!有任何问题请随时告诉我。谢谢

标签: python python-2.7 azure azure-cosmosdb azure-log-analytics


【解决方案1】:

Azure Cosmos DB 中的Diagnostic logging 使您能够执行此监控,以监控访问数据库的方式和时间。

请点击左侧导航中的Diagnostic logs,然后在您的azure cosmos db中点击Turn on diagnostics

您可以将日志文件存储在azure account,流到eventhub或发送到azure analytics

从进行 Azure Cosmos DB 操作时起,您的帐户 two hours 中就可以使用日志。您可以自行管理存储帐户中的日志。

单个 blob 存储为文本,格式为 JSON blob。

{
    "records":
    [
        {
           "time": "Fri, 23 Jun 2017 19:29:50.266 GMT",
           "resourceId": "contosocosmosdb",
           "category": "DataPlaneRequests",
           "operationName": "Query",
           "resourceType": "Database",
           "properties": {"activityId": "05fcf607-6f64-48fe-81a5-f13ac13dd1eb",`
           "userAgent": "documentdb-dotnet-sdk/1.12.0 Host/64-bit MicrosoftWindowsNT/6.2.9200.0 AzureSearchIndexer/1.0.0",`
           "resourceType": "Database","statusCode": "200","documentResourceId": "",`
           "clientIpAddress": "13.92.241.0","requestCharge": "2.260","collectionRid": "",`
           "duration": "9250","requestLength": "72","responseLength": "209", "resourceTokenUserRid": ""}
        }
    ]
}

更多详情请参考here

更新答案:

据我观察,Azure Cosmos DB 中的日志并没有使用Master keyResource Token 区分请求。

不过,我想为您提供一个解决方法。

你知道,Python Document DB SDK 实际上是REST API

因此,您可以通过reverse proxy 将您的HTTP 请求发送到Azure 服务器,例如Nginx

您可以通过请求URL的格式来判断是哪种访问方式,并记录在reverse proxy层中。

希望对你有帮助。

【讨论】:

  • 嗨,Jay,我打开了诊断日志记录。我可以在日志操作日志和数据平面请求日志下看到存储帐户中的两个文件夹。我的问题是我在哪里以及如何找到使用 DocumentDB 的主密钥请求的文档 DB 的请求日志。我可以找到用户访问日志,但找不到 Masterkey 访问日志。
  • @PrafulMattoo 嗨,Praful。请查看我的更新答案。
  • 这很有帮助 非常感谢。我会接受答案。祝你有美好的一天:)
猜你喜欢
  • 2019-07-12
  • 2019-10-10
  • 1970-01-01
  • 2020-10-08
  • 2018-07-02
  • 2012-03-12
  • 1970-01-01
  • 2019-05-06
  • 1970-01-01
相关资源
最近更新 更多