addfields
Utilizzare il comando addfields per generare dati aggregati all'interno di gruppi identificati da qualsiasi comando di raggruppamento, ad esempio stats, link o timestats. L'output del comando include un campo per ogni aggregazione nella subquery stats.
È possibile utilizzare il comando addfields con i campi di runtime generati utilizzando i comandi stats, eventstats e eval.
Sintassi
addfields <subquery> [, <subquery>]dove subquery può essere espanso come segue: [ <logical_expression> / <boolean_expression> | <eventstats_functions> / <stats_functions> ]
Parametri
Nella tabella seguente sono elencati i parametri utilizzati in questo comando, insieme alle relative descrizioni.
| Parametro | Descrizione |
|---|---|
|
|
Ogni subquery deve iniziare con un'espressione logica o booleana per selezionare un subset di dati all'interno di ciascun gruppo. Per informazioni dettagliate sulle espressioni, vedere cerca e dove. |
eventstats_functions |
Le funzioni eventstat da applicare alle proprietà del gruppo. Per i dettagli sulle funzioni disponibili, vedere statistiche evento. |
|
|
Le funzioni statistiche da applicare ai dati selezionati. Per informazioni dettagliate sulle funzioni disponibili, vedere statistiche. |
Il comando addfields può essere utilizzato nelle seguenti modalità:
-
Per i campi trovati nel file di log:
addfields [ <field> | stats ...] -
Per i campi creati al di fuori di
linkutilizzandoeval:addfields [ * | where <field> | stats ...] -
Per i campi creati all'interno di
linkutilizzando un valorestats,eventstatsoeval:addfields [ * | where <field> | eventstats ...]
Per esempi di utilizzo di questo comando in scenari tipici, vedere:
I comandi seguenti restituiscono i conteggi in base al pattern di nomi entità per ogni tipo di entità:
* | link 'Entity Type'
| addfields
[ substr(Entity, 0, 3) = 'adc' | stats count as 'ADC Count' ],
[ substr(Entity, 0, 3) = 'slc' | stats count as 'SLC Count']
* | stats count by 'Entity Type'
| addfields
[ substr(Entity, 0, 3) = 'adc' | stats count as 'ADC Count' ],
[ substr(Entity, 0, 3) = 'slc' | stats count as 'SLC Count']I comandi seguenti restituiscono i conteggi in base al pattern di nomi entità per ogni tipo di entità:
* | link 'Entity Type'
| stats avg('Content Size') as 'Content Size', earliest(Severity) as Severity
| addfields
[ * | where 'Entity Type' = 'Cluster Database'
| sort 'Content Size'
| eventstats first('Content Size') by Severity
]
* | stats avg('Content Size') as 'Content Size', earliest(Severity) as Severity by 'Entity Type'
| addfields
[ * | where 'Entity Type' = 'Cluster Database'
| sort 'Content Size'
| eventstats first('Content Size') by Severity ]
Identificare l'ultimo evento utilizzando il numero di riga:
'Log Source' = 'Database Alert Logs' and Label != null and Entity = MyDB
| rename Entity as Database
| link span = 1minute Time, Database, Label
| sort Database, 'Start Time'
| eventstats rownum as 'Row Number' by Database
| addfields
[ * | where Label = 'Abnormal Termination'
| eventstats last('Row Number') as 'Crash Row'
]