Необходимо создать в Splunk таблицу, которая является вложенной таблицей или имеет несколько столбцов - PullRequest
0 голосов
/ 28 мая 2020

У меня есть рабочий поиск Splunk, который извлекает данные из файла xml в операторе регистрации. В результате поиска создается таблица с 14 столбцами. Ниже приведен запрос, который создает эту таблицу

<sourcetype and other data>..| xmlkv  | rex max_match=0 "\<ns2\:numberCode\>(?P<location>[^\<]+)"| eval Segment1_Origin =  mvindex(location, 7), Segment1_Destination = mvindex(location, 8), Segment2_Origin = mvindex(location, 10), Segment2_Destination = mvindex(location, 11), Segment3_Origin = mvindex(location, 13), Segment3_Destination = mvindex(location, 14)  |  rex max_match=0 "\<carrier\>(?P<carrier>[^\<]+)" | eval Segment1_Carrier =  mvindex(carrier, 0), Segment2_Carrier = mvindex(carrier, 1), Segment3_Carrier = mvindex(carrier, 2) |  rex max_match=0 "\<billingMethod\>(?P<billingMethod>[^\<]+)" | eval Segment1_BillingMethod =  mvindex(billingMethod, 0), Segment2_BillingMethod = mvindex(billingMethod, 1), Segment3_BillingMethod = mvindex(billingMethod, 2) | table purchCostReference, eventType, Segment1_Carrier, Segment1_BillingMethod, Segment1_Origin, Segment1_Destination, Segment2_Carrier, Segment2_BillingMethod, Segment2_Origin, Segment2_Destination, Segment3_Carrier, Segment3_BillingMethod, Segment3_Origin, Segment3_Destination | sort purchCostReference, eventType

Таблица выглядит следующим образом (все столбцы не показаны из-за размера): enter image description here

Я бы например, таблица, в которой таблица каким-то образом вложена по сегментам. enter image description here

Или вот так: enter image description here

Возможна ли одна из этих конструкций таблиц в Splunk?

1 Ответ

0 голосов
/ 29 мая 2020

Вот как я создал второй экземпляр таблицы. Добавлено поле времени. Используя эти команды, я проанализировал значения, необходимые в xml

sourcetype... |xmlkv | rex max_match=0 "\<purchasedCostTripSegment\>(?P<segment>[^\<]+)" |eval Segments =  mvrange(1,mvcount(mvindex(segment, 0, 2))+1,1) | rex max_match=0 "\<carrier\>(?P<Carriers>[^\<]+)" | rex max_match=0 "\<billingMethod\>(?P<BillingMethod>[^\<]+)" | rex max_match=0 "<purchasedCostTripSegment>[\s\S]*?<origin>\s*<ns2:numberCode>(?P<Origin>\d+)"  | rex max_match=0 "<purchasedCostTripSegment>[\s\S]*?<destination>\s*<ns2:numberCode>(?P<Destination>\d+)" | eval Time =_time | convert timeformat="%m-%d-%Y %H:%M:%S" ctime(Time) | table purchCostReference, eventType, Time, Segments, Carriers, BillingMethod, Origin, Destination | sort - Time
...