Our application uses Application Insights, an Azure service, to monitor some user actions and webapp performance. This service is disabled by default, but you can enable it for your application.
In the Azure portal:
- open the page of your Static Web App instance
- select "Application Insights" in the left panel
- select "Yes" next to "Enable Application Insights" (see note below if you can't enable Application Insights)
- click on "Save"
Then, edit the configuration file src/config/ApplicationInsights.json in the source code of your webapp:
- replace the value of
APPLICATION_INSIGHTS_INSTRUMENTATION_KEY
with the instrumentation key that has been generated for your application - set
ENABLE_APPLICATION_INSIGHTS
totrue
Note: in the Azure portal, if you can't enable Application Insights and encounter an error message such as "App Insights is only applicable to Static Web Apps with at least one function", please check that the value of "api_location" parameter is set to "api" in your GitHub Actions workflow file, in the ".github/workflows folder".
The monitoring will then be enabled for your webapp. For further information on how to consult these custom metrics, see: How to view logs and metrics in Application Insights.
This section lists the custom metrics provided by the azure-sample-webapp, and what user actions trigger each on of them.
This event is triggered each time a user uploads a file for scenario parameters of type "file upload" (via the "Browse" button) and "editable table" (via the "Import file" button), in the scenario parameters panel. See Scenario Parameters Configuration - File parameters for more details on these parameters types.
In Application Insights Portal, this event is labeled UploadFileValue.
This event is triggered each time a user downloads a file for scenario parameters of type "file upload" (by clicking on the "Download" button),in the scenario parameters panel. This does not apply to editable tables. See Scenario Parameters Configuration - File parameters for more details on files parameters.
In Application Insights Portal, this event is labeled DownloadFileValue.
This event is triggered each time a user creates a new scenario, i.e. when clicking on the "Create" button from the scenario creation dialog.
In Application Insights Portal, this event is labeled CreateScenarioValue.
This event is triggered each time a user launches a scenario, either by clicking "Launch" or "Update and launch" buttons.
In Application Insights Portal, this event is labeled LaunchScenarioValue.
The duration is measured between the moment the user has clicked on the "Launch" button, and the moment the application has detected the related scenario status to be either "Successful" or "Error".
Notes:
- the measured run duration can be higher than the real duration. Indeed, once the scenario has been launched, the application will check the scenario's status regularly at a specific time interval. Thus, the run duration measurement error is inferior or equal to this interval.
- if a user closes the webapp before the end of the scenario run, the metric point for this run will not be registered
In Application Insights Portal, this event is labeled RunDurationValue.