Application Insights – Metrics, Logs and Traces · AZ-204: Developing Solutions for Microsoft Azure Monitor and Troubleshoot Azure Solutions

A .NET worker records one CPU-utilization value every second and needs an accurate one-minute average in Application Insights Metrics Explorer. Which…

Practice question from Application Insights – Metrics, Logs and Traces (AZ-204: Developing Solutions for Microsoft Azure Monitor and Troubleshoot Azure Solutions), with the correct answer and a step-by-step solution.

easy · MCQ · Q-3A6691

A .NET worker records one CPU-utilization value every second and needs an accurate one-minute average in Application Insights Metrics Explorer. Which code is the most appropriate way to record the custom metric?

  1. A.telemetryClient.TrackTrace($"CPU: {cpuPercent}");
  2. B.telemetryClient.GetMetric("CpuUtilization").TrackValue(cpuPercent);Correct answer
  3. C.telemetryClient.TrackEvent("CpuUtilization", new Dictionary<string, string> { ["Value"] = cpuPercent.ToString() });
  4. D.telemetryClient.TrackRequest("CpuUtilization", DateTimeOffset.UtcNow, TimeSpan.FromSeconds(cpuPercent), "200", true);

Solution

GetMetric creates a custom metric that aggregates values locally before sending them to Application Insights. Metrics Explorer can then calculate the one-minute average efficiently. Traces and events are logs, not numeric metric measurements.

More from Application Insights – Metrics, Logs and Traces

All of Application Insights – Metrics, Logs and Traces

Practise more Monitor and Troubleshoot Azure Solutions

Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.

Start practising free

Free to start · No credit card needed