Log Ingestion and Query

Asked at Datadog· Onsite

Reported by the problem's creator, not verified

Import another question

A logging service stores log lines and answers count queries. Implement a class LogStore that starts empty and supports adding logs and querying counts of stored logs.

Examples

  1. Example 1

    Input: init = [], operations = [["add",[1,"api","INFO","hello world"]],["add",[2,"api","ERROR","something failed"]],["add",[3,"web","INFO","user login"]],["query",[1,3,"*","*","*"]],["query",[1,2,"api","*","*"]],["query",[2,3,"api","ERROR","failed"]]]

    Output: [null,null,null,3,2,1]

    Explanation: The three logs sit in times 1 to 3, so the unfiltered query counts 3. The second query keeps the two api logs. The third needs service api, level ERROR and failed in the message, which only the log at time 2 satisfies.

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.