Log Ingestion and Query
Asked at Datadog· Onsite
Reported by the problem's creator, not verified
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
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
apilogs. The third needs serviceapi, levelERRORandfailedin the message, which only the log at time 2 satisfies.