容器级别的Azure存储指标

我指的是azp在

提供的文档

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个容器,则需要查找每个容器的指标,而不是完整的存储帐户。

请建议是否还有其他方法可以在容器级别查找指标。

yumikooo 回答:容器级别的Azure存储指标

没有直接的方法,但是可以通过配置存储帐户的监视来实现。请点击以下链接配置监视,

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

一旦配置了存储帐户进行监视,它将在您的存储帐户中创建一个名称为$ logs的新容器。这个新容器在azure门户中不可见,但是您可以使用Azure Storage Explorer工具查看和浏览这个新容器。下面提供了下载该工具的链接。

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。

enter image description here

有关日志的架构,可以在位置的azure文档中找到。

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

可以使用架构格式读取日志文件,并创建有用的度量标准(如果有)。

本文链接:https://www.f2er.com/2519968.html

大家都在问