View current instances wuth kql query in Azure Web Apps

Johann 0 Reputation points

Hi there,

I'm trying to view the current intances with a KQL query but not really successful, tired a couple of different KQL query, see below :

| where timestamp >= ago(24h)
| summarize CountOfEvents=count() by bin(timestamp, 1h), cloud_RoleInstance
| render timechart 

Second KQL query :

| project TimeGenerated, ResourceId, CurrentInstanceCount, NewInstanceCount, ScaleDirection, ResultType
| sort by TimeGenerated desc

Third KQL query :

let grainTime = 30sec;
| where timestamp >= ago(24h)
| summarize ['rate/minute'] = dcount(cloud_RoleInstance) by bin(timestamp, grainTime)
| render timechart

All these KQL queries works but not really what I'm looking for. As mentioned I want to display the current running instances, in the Web App, even if it's manually scaled or rule based?

Any help would be appreciated.

Thanks 😀

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,042 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Deepanshu katara 5,685 Reputation points

    Hi Johan ,

    Please check below query if it helps your requirement

    | where Message contains "Starting instance" or Message contains "Stopping instance"
    | project InstanceId = extractjson("$.InstanceID", Message), State = iff(Message contains "Starting instance", "Running", "Stopped")
    | summarize InstanceCount = count() by State

    Ref doc -->

    Kindly check once and accept if it helps

  2. VenkateshDodda-MSFT 19,301 Reputation points Microsoft Employee

    @Johann Thank you for posting your question in Microsoft Q&A.

    Based on the information, I understand that you want to know the current number of instances of the app service that is running using KQL query irrespective whether it is scaled out or not. Correct me if my understanding is wrong.

    The above shared queries Traces, Requests table are part of application insights. Ideally application insights are used to understand the application behavior.

    If you want to know more about the environment information like how many instances that app service is running and also about different configuration settings, it would be better to relay on Azure Resource Graph explorer.

    • If you are performing scaling at the app service plan level, then you can the below query which focus on currentnumberofworkers property.

    User's image

    • Alternatively, if you don't have dependency on the KQL query then you can leverage this Azure Management Rest API WebApps List instance Identifiers to pull the number of instances.

    Hope this helps, let me know if you have any further questions on this.