Hey ppl, can I get your opinion on the best approach here? We have a multi-tenant service for customer devices and working on using Loki to store their device logs. The device logs could be json, logfmt or just text and we would like our tenants to be able to use most features of logQL. However we also would like to associate some extra meta data with each message, such as version
, isStdErr
, isSystem
and serviceId
. The options I am considering are:
- Store meta data as labels but this would push cardinality limits.
- Try parse the log line to add our metadata before writing to Loki. However, this seems error prone and resource intensive. First try parse as JSON then try as logfmt and if plain text reformat the message to logfmt to add the meta data.
- Store each log line as JSON with metadata properties and a
message
property containing the device log. However I think it would require all queries to line_format the message property to search with in the message. e.g.{device_id="1"} | json | line_format "{{.message}}" | ...user query
- … something else I haven’t thought of?