0
votes

I have an Azure Function App. I want to log the duration for some specific part of the code in that Function App. Where would be the right place to store this in? I can see dependencies is the only collection that has a duration property. But documentation states this collection is mostly SQL server, Storage etc. Page views and request has this too, but does not seems like the right place. Any pointers where you add this kind of monitoring?

1

1 Answers

0
votes

You can log them as customMetrics.

Use the LogMetric extension method on ILogger instance to create custom metrics.

        public static void Run([BlobTrigger("samples-workitems/{name}", Connection = "AzureWebJobsStorage")]Stream myBlob, string name, ILogger log)
        {
            log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");

            //specify the name of the metric as the first parameter, and fill in the duration time as the 2nd parameter.
            log.LogMetric("duration_time", 119);
        }

Then in azure portal -> application insights -> logs, you can check the duration time in customMetrics table:

enter image description here