簡體   English   中英

容器級別的 azure 存儲指標

[英]azure storage metrics at container level

我指的是 azure 提供的文檔

https://docs.microsoft.com/en-us/azure/storage/common/storage-metrics-in-azure-monitor#read-metric-values-with-the-net-sdk

我已經進行了更改,並使用 azure-mgmt-monitor 依賴項使代碼適用於 java。 這是代碼

public void listStorageMetricDefinition() {
    String resourceId = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{storageAccountName}";
    String subscriptionId = "*****************************";
    String tenantId = "*****************************";
    String applicationId = "*****************************";
    String accessKey = "*****************************";

    ApplicationTokenCredentials credentials = (ApplicationTokenCredentials) new ApplicationTokenCredentials(
            applicationId, tenantId, accessKey, AzureEnvironment.AZURE).withDefaultSubscriptionId(subscriptionId);
    MonitorManagementClientImpl clientImpl = new MonitorManagementClientImpl(credentials);

    Date startTime = DateTime.now().minusMinutes(30).toDate();
    Date endTime = DateTime.now().toDate();
    //DateTime must be in below format
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
    String startInterval = dateFormat.format(startTime);
    String endInterval = dateFormat.format(endTime);
    String timespan = startInterval + "/" + endInterval;
    Period interval = Period.minutes(1);
    String metricNames = "Egress";
    String aggregation = "Total";
    Integer top = null;
    String orderby = null;
    String filter = null;
    String metricNamespace = null;

    ResponseInner response = clientImpl.metrics().list(resourceId, timespan, interval, metricNames, aggregation,
            top, orderby, filter, null, metricNamespace);
    List<MetricInner> value = response.value();
    for (MetricInner metric : value) {
        System.out.println("id " + metric.id());
        System.out.println("name " + metric.name().value());
        System.out.println("type " + metric.type());
        System.out.println("unit " + metric.unit());
        List<TimeSeriesElement> timeseries = metric.timeseries();
        timeseries.forEach(ts -> {
            ts.data().forEach(dt -> {
                System.out.println(dt.timeStamp() + "--" + dt.total());
            });
        });
    }
}

通過使用上述方法,我可以讀取存儲帳戶級別的指標值,但是如何找到容器級別的指標? 例如,如果我的存儲帳戶中有 3 個容器,我需要找到每個容器的指標而不是完整的存儲帳戶。

請建議是否有其他方法可以在容器級別查找指標。

沒有直接的方法可以做到這一點,但可以通過為存儲帳戶配置監控來實現這一點。 按照以下鏈接配置監控,

https://docs.microsoft.com/en-us/azure/storage/common/storage-monitor-storage-account

配置存儲帳戶進行監控后,它將在您的存儲帳戶中創建一個名為 $logs 的新容器。 這個新容器在 azure 門戶中不可見,但您可以使用 Azure 存儲資源管理器工具查看和探索這個新容器。 下載該工具的鏈接如下。

https://azure.microsoft.com/en-us/features/storage-explorer/

$logs 容器中的日志根據日期和時間在單獨的文件夾中隔離。

/blob/yyyy/MM/dd/HHmm/000000.log

/blob/yyyy/MM/dd/HHmm/000001.log

其中 mm 始終為 00。

在此處輸入圖像描述

日志架構可以在 azure 文檔中找到。

https://docs.microsoft.com/en-us/rest/api/storageservices/storage-analytics-log-format

可以使用模式格式讀取日志文件並創建有用的指標。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM