Ravindra BagaleCourses & study guides मराठी

Chapter 95: Logging with Loki, Elastic Stack and CloudWatch

DevOps

95.4 Privacy — allowlists, redaction and safe correlation

Story (fictional teaching scenario). At a fictional Satara shop, Rutuja and Ken from Kyoto decide that a support investigation needs an error category, not a customer form or access token.

Privacy — allowlists, redaction and safe correlation
Privacy — allowlists, redaction and safe correlation

Why

Logs often spread to storage, dashboards, alerts and exports. Prevention is safer than trying to erase every copy later.

What

  • An allowlist keeps only explicitly approved fields.
  • Redaction removes or replaces sensitive content.
  • A correlation ID connects events for one operation without requiring a person’s name.
  • Data minimization means keeping only information needed for the diagnostic purpose.
  • A mask in a dashboard does not prove the original value was never ingested.

How

  1. Exclude credentials, personal details, payment details and full request bodies at the source.

  2. Prefer event codes and controlled fields to free-form messages.

  3. Redact before serialization and forwarding, not only at display time.

  4. Test nested fields, exceptions, alternate encodings and failure paths using fake data only.

Example 1: Drop a fictional field

  1. Read the command or request.
raw = {"level":"ERROR", "private_note":"FICTIONAL_REMOVE"}
safe = {key: raw[key] for key in ("level",)}
print(safe)
  1. Read the result.

Output (illustrative; NOT executed against Loki, Elastic or CloudWatch)

{'level': 'ERROR'}
  1. Line by line: raw contains invented demonstration content only. The tuple lists the one approved key. The comprehension creates a new object without the unknown field. This tiny example does not detect all sensitive strings; the full lab intentionally supports only its fake schema.

Example 2: Correlation without personal data

  1. Read the command or request.
API event: request_id=req-demo-003
Worker event: request_id=req-demo-003
  1. Read the result.

Output (illustrative; NOT executed against Loki, Elastic or CloudWatch)

Two fictional events can be searched together without storing a name or email.
  1. Line by line: A correlation ID is not a user identity or authorization token. Real IDs may still be sensitive context and need restricted access. Do not promote unbounded request IDs to Loki index labels.

Ravindra Bagale's Tip

Do not log secrets and rely on a later dashboard mask.

Did you understand? Let us try it once more.