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 mediante i comandi stats, eventstats e eval.

Sintassi

addfields <subquery> [, <subquery>]

dove è possibile espandere subquery nel modo seguente: [ <logical_expression> / <boolean_expression> | <eventstats_functions> / <stats_functions> ]

Parametri

La tabella seguente elenca i parametri utilizzati in questo comando e le relative descrizioni.

Parametro descrizione;

logical_expression, boolean_expression

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 ricerca e dove.

eventstats_functions Funzioni delle statistiche degli eventi da applicare alle proprietà del gruppo. Per i dettagli sulle funzioni disponibili, vedere eventstats.

stats_functions

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 presenti nel file di log:

    addfields [ <field> | stats ...]
  • Per i campi creati al di fuori di link utilizzando eval:

    addfields [ * | where <field> | stats ...]
  • Per i campi creati all'interno di link utilizzando stats, eventstats o eval:

    addfields [ * | where <field> | eventstats ...]

I comandi riportati di seguito restituiscono i conteggi in base al pattern del nome 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 riportati di seguito restituiscono i conteggi in base al pattern del nome 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'
   ]