The query came in hot. Sensitive fields right in front of me. Names, emails, credit card numbers. Clear as day in my logs.
This is where SQL data masking stops being a nice-to-have and becomes a survival tool. With Lnav SQL data masking, you can scan live query output, strip or scramble sensitive values, and keep visibility without leaking private data. Most engineers know Lnav as a log file navigator. Few realize it’s also a precise tool for intercepting and rewriting output in flight.
Masking in Lnav works by defining SQL expressions that run on the displayed data. You load your log files or query results, then use :sql to run masking logic directly inside Lnav. That means you stay in one interface—no export, no extra pipeline, no risk of leaving raw data in a temp file. Whether you need to redact email addresses, hash IDs, or replace credit cards with fake formats, the command set is fast and scriptable.
Why it works for real workloads:
- On-the-fly masking: Data never leaves your environment unprotected.
- Portable masking rules: The same expressions work across multiple log sources.
- Search with safety: Indexed search still works, but the masked values don’t give away the real thing.
- Zero setup overhead: No new service to deploy.
Common masking strategies in Lnav SQL include using functions like replace(), substring patterns, and regular expressions in the SQL view. For example, to mask all email domains: