python - 使用 python sdk 从 azure 存储中提取指标

标签 python azure azure-blob-storage

我正在尝试从 Azure 存储获取指标,例如 transaction_count、入口、导出、服务器成功延迟等。

我正在尝试使用以下代码:

from azure.storage.blob import BlobAnalyticsLogging, Metrics, CorsRule, RetentionPolicy

# Create logging settings
logging = BlobAnalyticsLogging(read=True, write=True, delete=True, retention_policy=RetentionPolicy(enabled=True, days=5))

# Create metrics for requests statistics
hour_metrics = Metrics(enabled=True, include_apis=True, retention_policy=RetentionPolicy(enabled=True, days=5))
minute_metrics = Metrics(enabled=True, include_apis=True,retention_policy=RetentionPolicy(enabled=True, days=5))

# Create CORS rules
cors_rule = CorsRule(['www.xyz.com'], ['GET'])
cors = [cors_rule]

# Set the service properties
blob_service_client.set_service_properties(logging, hour_metrics, minute_metrics, cors)
# [END set_blob_service_properties]

# [START get_blob_service_properties]
properties = blob_service_client.get_service_properties()
# [END get_blob_service_properties]

print (properties)

这不会给出错误,但返回以下输出:

{'analytics_logging':,'hour_metrics':,'month_metrics':,“cors”:[],“target_version”:无,“delete_retention_policy”:,'static_website':}

我知道也许我遗漏了一些东西,文档非常密集,我不太理解。

提前感谢您提供任何可能的答案

最佳答案

您可能希望单独读取服务属性,即:

analytics_logging = blob_service_client.get_service_properties().get('analytics_logging')

这样您应该能够在代码中进一步处理(或读取)输出。

关于python - 使用 python sdk 从 azure 存储中提取指标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71767628/

相关文章:

python - for循环被用作while循环(python)

python - 返回数据框的按钮

python - 将继承的 mixin 方法装饰为 pyqtSlot

azure - 使用 Python Sdk 识别没有任何资源(例如表、容器)的存储帐户

azure - 无法配置 Azure 事件中心生产者

azure - 保存自定义模型 Azure 表单识别器时出错

python - 是否可以使用 Python SDK 检查特定 Azure blob 上是否有租约?

python - 当没有任何选项卡时,cornerWidget 会消失

azure - 有没有办法使用逻辑应用将数据加载到 Azure 数据湖存储第 2 代?

c# - 将 block blob 上传到 Azure 时为 "The request body is too large and exceeds the maximum permissible limit"