Query / Log Stream Matching

Asked at Datadog· Screen

Reported by the problem's creator, not verified

Import another question

You process a stream of messages in order. Each message registers a query or is a log line, and each message produces zero or one output line.

Examples

  1. Example 1

    Input: livetail_stream = ["Q: database","Q: Stacktrace","Q: loading failed","L: Database service started","Q: snapshot loading","Q: fail","L: Started processing events","L: Loading main DB snapshot","L: Loading snapshot failed no stacktrace available"]

    Output: ["ACK: database; ID=1","ACK: Stacktrace; ID=2","ACK: loading failed; ID=3","M: Database service started; Q=1","ACK: snapshot loading; ID=4","ACK: fail; ID=5","M: Loading main DB snapshot; Q=4","M: Loading snapshot failed no stacktrace available; Q=2,3,4"]

    Explanation: Query 1 matches the first log line. The last line contains stacktrace (query 2), loading and failed (query 3), and snapshot (query 4); query 5 (fail) does not match because failed is a different whole word. Started processing events matches no query, so it produces no output.

Import your own questions
Paste a question you were asked and get a full problem: statement, tests and a checked solution.
Import a question

Code

Loading editor…

Ln 1, Col 1

Start an attempt to use Coach.