Query to get CustomMetrics in an app returns empty result. Using APIKey for authentication.
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- azure, csharp
- Domain
- api, cloud, observability-sre
Research direction
Start by reproducing the ReadAsync method with the supplied customMetrics | take 1 query, application ID, and API key, then compare the response with the Azure portal result. Inspect the returned QueryResults and authentication context to identify why the console app receives no rows. Done means the cause of the empty result and the required correction are documented.
Written by the indexing model from the issue text.
Description
I'm trying to access AppInsights data, for now trying through a console app, using APIKey for authentication.
Surprisingly, I get empty result as response. Same query returns expected result when run in Azure portal.
Please help me understand what I am missing here.
Code:
public async Task<IList<IDictionary<string, string>>> ReadAsync(string applicationId, string apiKey)
{
ApiKeyClientCredentials credentials = new ApiKeyClientCredentials(apiKey);
using ApplicationInsightsDataClient client = new ApplicationInsightsDataClient(credentials);
client.AppId = applicationId;
string query = "customMetrics | take 1";
HttpOperationResponse<QueryResults> queryWithHttpMessagesAsync = await client.QueryWithHttpMessagesAsync(query);
QueryResults result = queryWithHttpMessagesAsync.Body;
IList<IDictionary<string, string>> resultsDictionary = result.Results.ToList();
return resultsDictionary;
}

- Dominant language
- PowerShell
- Stars
- 1.2k
- Forks
- 493
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/AzureMonitorCommunity
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
-
Difficulty 4/5 3-5 days Newbie friendliness 10/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 4/5 3-5 days Newbie friendliness 20/100
All issues in microsoft/AzureMonitorCommunity
Similar issues
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100