Unexpected data in a destination Logstore
If a destination Logstore contains unexpected data after data transformation, unmatched logs routed to the default storage target are likely the cause.
A Logstore named website_log contains 5,000 log entries. Of these, 1,000 entries have a SourceIP of 192.0.2.54, 1,000 have a SourceIP of 192.0.2.28, and 1,000 have a SourceIP of 192.0.2.136. The remaining 2,000 entries have other SourceIP values. You want to transform these entries and send them to different destination Logstores.
-
Transformation requirements
-
Distribute log entries with a
SourceIPof192.0.2.54to a Logstore named54_log. -
Distribute log entries with a
SourceIPof192.0.2.28to a Logstore named28_log. -
Distribute log entries with a
SourceIPof192.0.2.136to a Logstore named136_log.
-
-
Expected results
-
The
54_logLogstore contains 1,000 log entries, all of which have aSourceIPof192.0.2.54. -
The
28_logLogstore contains 1,000 log entries, all of which have aSourceIPof192.0.2.28. -
The
136_logLogstore contains 1,000 log entries, all of which have aSourceIPof192.0.2.136.
-
-
Transformation statement
e_if(e_search("SourceIP==192.0.2.54"), e_output(name="54-target", project="sls-test", logstore="54_log")) e_if(e_search("SourceIP==192.0.2.28"), e_output(name="28-target", project="sls-test", logstore="28_log")) e_if(e_search("SourceIP==192.0.2.136"), e_output(name="136-target", project="sls-test", logstore="136_log")) -
Storage target
You configure three storage targets:
54-target(default),28-target, and136-target. These targets route data to the54_log,28_log, and136_logLogstores, respectively, in thesls-testproject. -
Actual results
-
(Unexpected) The
54_logLogstore contains 3,000 log entries. In addition to the expected logs with aSourceIPof192.0.2.54, it also contains logs with otherSourceIPvalues. -
(As expected) The
28_logLogstore contains 1,000 log entries, all of which have aSourceIPof192.0.2.28. -
(As expected) The
136_logLogstore contains 1,000 log entries, all of which have aSourceIPof192.0.2.136.
-
-
Cause
Logs that match a condition in an
e_outputfunction are sent to the specified destination Logstore. Logs that do not match any condition are automatically sent to the default storage target. In this example, the default target (54-target) routes unmatched logs to the54_logLogstore. -
Solution
Add the
e_drop()function to the end of your transformation statement to discard all unmatched logs.e_if(e_search("SourceIP==192.0.2.54"), e_output(name="54-target", project="sls-test", logstore="54_log")) e_if(e_search("SourceIP==192.0.2.28"), e_output(name="28-target", project="sls-test", logstore="28_log")) e_if(e_search("SourceIP==192.0.2.136"), e_output(name="136-target", project="sls-test", logstore="136_log")) e_drop()