XML, JSON 등 다양한 유형의 로그를 별도 개발 없이 파싱, 정규화 가능한가?

로그프레소 쿼리 언어는 높은 수준의 표현력을 제공하므로 별도의 개발 없이 사용자가 쿼리 작성만으로 파싱 및 정규화를 수행할 수 있습니다.

XML 파싱 예시

아래는 보안뉴스 RSS를 쿼리로 파싱하는 예제입니다.

wget encoding=euc-kr url="http://www.boannews.com/media/news_rss.xml?mkind=1" 
| parsexml field=line 
| parsemap field=channel 
| explode item
| parsemap field=item 
| fields title, link, description

JSON 파싱 예시

아래는 Zscaler Private Access 로그를 parsejson 명령어로 파싱하는 예제입니다.

json "{}" 
| eval line = "{\"LogTimestamp\":\"Wed Jul 3 05:17:22 2019\",\"Customer\":\"Safe March\",\"SessionID\":\"8A64Qwj9zCkfYDGJVoUZ\",\"SessionType\":\"ZPN_ASSISTANT_BROKER_CONTROL\",\"SessionStatus\":\"ZPN_STATUS_AUTHENTICATED\",\"Version\":\"19.20.3\",\"Platform\":\"el7\",\"ZEN\":\"US-NY-8179\",\"Connector\":\"Seattle App Connector 1\",\"ConnectorGroup\":\"Azure App Connectors\",\"PrivateIP\":\"10.0.0.4\",\"PublicIP\":\"0.0.0.0\",\"Latitude\":47,\"Longitude\":-122,\"CountryCode\":\"\",\"TimestampAuthentication\":\"2019-06-27T05:05:23.348Z\",\"TimestampUnAuthentication\":\"\",\"CPUUtilization\":1,\"MemUtilization\":20,\"ServiceCount\":2,\"InterfaceDefRoute\":\"eth0\",\"DefRouteGW\":\"10.0.0.1\",\"PrimaryDNSResolver\":\"168.63.129.16\",\"HostStartTime\":\"1513229995\",\"ConnectorStartTime\":\"1555920005\",\"NumOfInterfaces\":2,\"BytesRxInterface\":319831966346,\"PacketsRxInterface\":1617569938,\"ErrorsRxInterface\":0,\"DiscardsRxInterface\":0,\"BytesTxInterface\":192958782635,\"PacketsTxInterface\":1797471190,\"ErrorsTxInterface\":0,\"DiscardsTxInterface\":0,\"TotalBytesRx\":10902554,\"TotalBytesTx\":48931771}"
| parsejson