> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/powershell-universal/it/piattaforma/monitoring.md).

# Monitoraggio

Monitori PowerShell Universal con Azure Application Insights e i contatori delle prestazioni di Windows, e consulti i processi attivi e le sessioni utente nella console.

PowerShell Universal si integra automaticamente con Microsoft Application Insights per fornire monitoraggio e avvisi per il suo sistema. Fornisce inoltre contatori delle prestazioni per varie funzionalità dell'ambiente.

## Application Insights

### Configurazione di Application Insights

All'interno dell'Azure Portal, dovrà creare una nuova risorsa Application Insights. Una volta creata, dovrà copiare la stringa di connessione.

Successivamente, incolli la stringa di connessione nel [file delle impostazioni ](/powershell-universal/it/config/settings.md)di PowerShell Universal. Infine, riavvii il server PowerShell Universal. Il monitoraggio dell'applicazione sarà ora abilitato.

```json
  "ApplicationInsights": {
    "ConnectionString": "InstrumentationKey=73b84b67-6fc9-4c37-9f54-000000000000"
  },
```

Se esegue PowerShell Universal in Azure, può anche creare una nuova Application Setting. All'interno della sua app Web, clicchi su Configuration e poi clicchi su New application setting.

Il nome dovrebbe essere:

```
APPLICATIONINSIGHTS__CONNECTIONSTRING
```

Il valore dovrebbe essere la stringa di connessione. Riavvii la sua app Web per iniziare a raccogliere le metriche.

### Visualizzazione dei dati di monitoraggio

All'interno dell'Azure Portal, può visualizzare la risorsa Application Insights per consultare informazioni sul suo server PowerShell Universal. Ciò includerà dati come risposte non riuscite, tempo di risposta del server, richieste al server e disponibilità. Potrà inoltre configurare avvisi per monitorare condizioni particolari del server PowerShell Universal.

## Contatori delle prestazioni

{% hint style="info" %}
I contatori delle prestazioni sono supportati solo su Windows.
{% endhint %}

I contatori delle prestazioni vengono installati eseguendo il programma di installazione MSI. Una volta fatto questo, i dati sulle prestazioni verranno generati automaticamente dai seguenti contatori.

* PowerShell Universal \ Active API Endpoints \ \_Total
* PowerShell Universal \ Active API Endpoints \ Endpoint
* PowerShell Universal \ API Endpoint Calls per Second \ \_Total
* PowerShell Universal \ API Endpoint Calls per Second \ Endpoint
* PowerShell Universal \ API Execution Time \ \_Total
* PowerShell Universal \ API Execution Time \ Endpoint
* PowerShell Universal \ Active Dashboard Connections \ \_Total
* PowerShell Universal \ Active Dashboard Connections \ Dashboard

### Installazione

Per impostazione predefinita, l'MSI installerà i contatori delle prestazioni. Se esegue PowerShell Universal al di fuori dell'MSI, dovrà installarli manualmente. Può farlo con il seguente script. Dovrà eseguirlo da un prompt con privilegi elevati.

```powershell
$categoryName = "PowerShell Universal"
$categoryType = [System.Diagnostics.PerformanceCounterCategoryType]::MultiInstance
$categoryExists = [System.Diagnostics.PerformanceCounterCategory]::Exists($categoryName)

If (-Not $categoryExists)
{
$objCCDC = New-Object System.Diagnostics.CounterCreationDataCollection
$objCCD1 = New-Object System.Diagnostics.CounterCreationData
$objCCD1.CounterName = "Active Endpoints"
$objCCD1.CounterType = "NumberOfItems32"
$objCCD1.CounterHelp = "Active number of executing endpoints."
$objCCDC.Add($objCCD1) | Out-Null

$objCCD1 = New-Object System.Diagnostics.CounterCreationData
$objCCD1.CounterName = "Execution Time"
$objCCD1.CounterType = "averageTimer32"
$objCCD1.CounterHelp = "Average execution time."
$objCCDC.Add($objCCD1) | Out-Null

$objCCD1 = New-Object System.Diagnostics.CounterCreationData
$objCCD1.CounterName = "Execution Time Base"
$objCCD1.CounterType = "averageBase"
$objCCD1.CounterHelp = "Average execution time base."
$objCCDC.Add($objCCD1) | Out-Null

$objCCD1 = New-Object System.Diagnostics.CounterCreationData
$objCCD1.CounterName = "Calls per second"
$objCCD1.CounterType = "rateOfCountsPerSecond64"
$objCCD1.CounterHelp = "Number of executions per second."
$objCCDC.Add($objCCD1) | Out-Null

$objCCD1 = New-Object System.Diagnostics.CounterCreationData
$objCCD1.CounterName = "Active Connections"
$objCCD1.CounterType = "numberOfItems64"
$objCCD1.CounterHelp = "Number of active connections to dashboards"
$objCCDC.Add($objCCD1) | Out-Null

[System.Diagnostics.PerformanceCounterCategory]::Create($categoryName, $categoryHelp, $categoryType, $objCCDC)|Out-Null
}
```

## Processi

I processi avviati direttamente da PowerShell Universal verranno visualizzati nella pagina dei processi. Può accedere a questa pagina cliccando su Home e poi sulla scheda Processes.

Le informazioni includono l'ID del processo, lo scopo, il nome del file e l'utilizzo della memoria. Può anche visualizzare lo stato dei runspace all'interno del processo.

Tenga presente che i processi avviati dai suoi script non verranno elencati qui.

## Sessioni utente

Può visualizzare le sessioni utente per le dashboard e per la console di amministrazione cliccando sulla scheda User Sessions nella pagina Home. Le informazioni sulla sessione includono l'ora di connessione, l'origine, il nome utente, la stringa dello user agent e l'indirizzo IP remoto.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.devolutions.net/powershell-universal/it/piattaforma/monitoring.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
