2 つのデータ ソースがあります。1 つは API 呼び出しのリストを含み、もう 1 つは関連するすべての認証イベントを含みます。Api 呼び出しごとに複数の認証イベントが存在する可能性があります。次のような認証イベントを見つけたい:
a) API 呼び出しと同じ「識別子」を含む
b) API 呼び出しから 1 秒以内に発生した
c) API に最も近い上記のフィルタリングの後に呼び出します。
foreachループで各ApiCallイベントをループし、autheventsでフィルターステートメントを使用して正しいイベントを見つけることを計画していましたが、これは可能ではないようです(PIGのネストされたFOREACHでフィルターを使用)
これを達成するための他の方法を提案できる人はいますか。それが役立つ場合は、使用しようとした Pig スクリプトを次に示します。
apiRequests = LOAD '/Documents/ApiRequests.txt' AS (api_fileName:chararray, api_requestTime:long, api_timeFromLog:chararray, api_call:chararray, api_leadString:chararray, api_xmlPayload:chararray, api_sourceIp:chararray, api_username:chararray, api_identifier:chararray);
authEvents = LOAD '/Documents/AuthEvents.txt' AS (auth_fileName:chararray, auth_requestTime:long, auth_timeFromLog:chararray, auth_call:chararray, auth_leadString:chararray, auth_xmlPayload:chararray, auth_sourceIp:chararray, auth_username:chararray, auth_identifier:chararray);
specificApiCall = FILTER apiRequests BY api_call == 'CSGetUser'; -- Get all events for this specific call
match = foreach specificApiCall { -- Now try to get the closest mathcing auth event
filtered1 = filter authEvents by auth_identifier == api_identifier; -- Only use auth events that have the same identifier (this will return several)
filtered2 = filter filtered1 by (auth_requestTime-api_requestTime)<1000; -- Further refine by usings auth events within a second on the api call's tiime
sorted = order filtered2 by auth_requestTime; -- Get the auth event that's closest to the api call
limited = limit sorted 1;
generate limited;
};
dump match;