简体   繁体   English

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

[英]How to visualize metrics application insights?

I am adding metrics to my application insights, but I don't know how to visualize values I track. 我正在为我的应用程序洞察添加指标,但我不知道如何可视化我跟踪的值。 I don't know if I'm doing it correctly. 我不知道我是否正确地做到了。

My code looks like: 我的代码看起来像:

    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;
            .........

I call the method like: 我把这个方法称为:

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);
        }

    }

I don't know if I'm getting the track correctly or not, because I can't see anything on Azure Application Insights. 我不知道我是否正确获取了该轨道,因为我在Azure Application Insights上看不到任何内容。

Azure Portal Application Insights Azure门户应用程序洞察

Maybe I have an error on my code? 也许我的代码有错误? Anyone help? 有人帮吗?

Found the solution. 找到了解决方案。 You have to click on Metrics and look for your metric you have made. 您必须单击“指标”并查找您所做的指标。

在此输入图像描述

And you can get the graphs by selecting it. 您可以通过选择它来获取图表。

在此输入图像描述

You can also check them by query at Analysis. 您也可以通过Analysis查询来查看它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM