Open tomkerkhove opened 6 years ago
Would like to work on this one with Heba.
@plooploops Just out of curiosity - Did you manage to fix this? If not, what progress did you make and found any relevant docs?
If you prefer not to work on this anymore, no problem - Just let me know please!
@tomkerkhove I can continue doing some research, but pulling custom metrics doesn't appear to be immediately available in the Azure Monitor SDK. We may be able to use the Resource URI template to pull a custom metric, but first we were having issues submitting to a REST endpoint for a storage account.
https://docs.microsoft.com/en-us/azure/azure-monitor/platform/metrics-store-custom-rest-api
https://docs.microsoft.com/en-us/azure/azure-monitor/platform/rest-api-walkthrough
We may need to wrap a REST API instead of using the SDK for now; I'll let you know how the research goes though.
@plooploops That's interesting - Maybe it already works then if we just specify the name of the custom metric on existing scrapers. Did you test that?
We are currently struggling with being able to get values from custom metrics. Our current case is with Azure Functions. When you create an Azure function, you have standard metrics available at the Microsoft.Web/sites level, but the Application Insights resource that is linked to the function also defines some interesting custom metrics (for each function in the function app):
In the picture above HttpTrigger1
is the name of my function.
After investigations, it seems that the Azure Monitor SDK (through the fluent API that you are using in Promitor) does not allow to retrieve those custom metrics. To be able to get them, you need to use the Application Insights SDK/REST APIs. I've done something like that:
var accesstoken = GetAccessToken("0000", "0000", "0000");
string url = "https://api.applicationinsights.io/v1/apps/APP_INSIGHTS_APP_ID/metrics/customMetrics/HttpTrigger1 Count";
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + accesstoken);
var response = httpClient.GetAsync(url).Result;
if (response.StatusCode == System.Net.HttpStatusCode.OK)
{
string content = response.Content.ReadAsStringAsync().Result;
Console.WriteLine(content);
}
That's being said, I think that to solve this issue, we could:
What do you think about? cc @tomkerkhove @brusMX
Also adding that it seems to have 2 kinds of custom metrics in Azure, one in Azure Monitor and one for Azure Application Insights. For the first one, I was not able to find a way to list them / retrieve their values from the Azure Monitor SDK. Looks like there is only one REST API to create new custom metrics ¯\(ツ)/¯
Thanks for the analysis @jcorioland and sorry for the late reply!
I've opened an issue related to Azure Functions metric duplication - https://github.com/Azure/azure-functions-host/issues/4746
In terms of the 2 approaches, I suggest to keep this one open for when Azure Monitor supports this and opened #645 to track the Application Insights approach
Hi @tomkerkhove, Has the support for scraping custom metrics from Azure Monitor been added?
We haven't made any change yet but I'd need to give it a go to see if it works out of the box.
Did you try it already?
Hi @tomkerkhove, Has the support for scraping custom metrics from Azure Monitor been added?
Can you elaborate on your scenario @dhagashtrivedi please? Do you write them to Azure Monitor or Application Insights?
Hi @tomkerkhove, yes we write them to Azure Monitor in a different metric Namespace.
Sounds good! Once it's out of preview I'll add this to our planning.
Add support for custom metrics from Azure Monitor. These can originate from services such as Azure Application Insights.
Here is how you can add one.
Specification