如何可视化指标应用程序洞察?

问题描述 投票:0回答:1

我正在为我的应用程序洞察添加指标,但我不知道如何可视化我跟踪的值。我不知道我是否正确地做到了。

我的代码看起来像:

    public void AddCustomMetric(String metricName,double Amount,  List<Property> additionalProperties)
    {
        CreateMetric(metricName, Amount, additionalProperties);
    }

    private void CreateMetric(String metricName, double amount, List<Property> additionalProperties)
    {
        List<String> metrycsNameList = new List<String>();
        List<String> metrycsValueList = new List<String>();
        try
        {
           additionalProperties.ForEach(property => metrycsValueList.Add(property.Value));
           additionalProperties.ForEach(property => metrycsNameList.Add(property.Name));
           Metric metric = _client.GetMetric(new MetricIdentifier("MetricNamespace", metricName, metrycsNameList));
            //metrycsValueList.ForEach(metricValue => metric.TrackValue(Amount, metricValue, "hola", "adios"));
            AddMetricValues(metric, amount, metrycsValueList);
        }
        catch (Exception ex)
        {
            throw new CustomMetricException("CustomMetricException", "Error adding a Custom Metric", ex.StackTrace);
        }

    }

    private void AddMetricValues(Metric metric, double amount, List<String> metrycsValueList)
    {
        int numberOfElements = metrycsValueList.Count;

        switch (numberOfElements)
        {
            case 1:
                metric.TrackValue(amount, metrycsValueList[0]);
                break;
            case 2:
                metric.TrackValue(amount, metrycsValueList[0], metrycsValueList[1]);
                break;
            case 3:
                metric.TrackValue(amount, metrycsValueList[0], metrycsValueList[1], metrycsValueList[2]); 
                break;
            .........

我把这个方法称为:

public void AddCustomMetricTestTupla()
    {
        List<Property> propertiesList = new List<Property>();
        propertiesList.Add(new Property("propertyExample", "value"));
        propertiesList.Add(new Property("propertyExample1", "value2"));
        propertiesList.Add(new Property("propertyExample2", "value3"));

        //Tests method AddCustomMetric giving a tuple as a param.
        using (AzureInsightsClient azureInsightsClient = new AzureInsightsClient(myClientKey))
        {
            azureInsightsClient.FlushMetrics();
            azureInsightsClient.AddCustomMetric("Example", 2, propertiesList);
        }

    }

我不知道我是否正确获取了该轨道,因为我在Azure Application Insights上看不到任何内容。

Azure Portal Application Insights

也许我的代码有错误?有人帮吗?

c# azure azure-application-insights
1个回答
0
投票

找到了解决方案。您必须单击“指标”并查找您所做的指标。

enter image description here

您可以通过选择它来获取图表。

enter image description here

您也可以通过Analysis查询来查看它们。

© www.soinside.com 2019 - 2024. All rights reserved.