Now, let’s validate that you can produce and consume log records as the two different user profiles.
Produce log records with different severity levels:
echo '{"level": "info", "message": "Application started"}
{"level": "debug", "message": "Loading configuration from /etc/app/config.yaml"}
{"level": "error", "message": "Failed to connect to database"}
{"level": "trace", "message": "Entering function processRequest()"}
{"level": "warn", "message": "High memory usage detected"}' | kafkactl -C logs-cluster.yaml --context sre produce app_logs
We’ve produced 5 log records:
- 2 internal logs (
debug, trace) - will be classified with x-internal: true
- 3 regular logs (
info, error, warn) - no classification header
Consume logs as the SRE user. You should see all 5 records:
kafkactl -C logs-cluster.yaml --context sre consume app_logs --from-beginning --exit --print-headers
The output includes all logs, with x-internal:true header on debug and trace entries:
#{"level": "info", "message": "Application started"}
x-internal:true#{"level": "debug", "message": "Loading configuration from /etc/app/config.yaml"}
#{"level": "error", "message": "Failed to connect to database"}
x-internal:true#{"level": "trace", "message": "Entering function processRequest()"}
#{"level": "warn", "message": "High memory usage detected"}
Consume logs as the developer user. You should only see 3 records (debug and trace logs are filtered out):
kafkactl -C logs-cluster.yaml --context dev consume app_logs --from-beginning --exit --print-headers
The output excludes debug and trace logs:
#{"level": "info", "message": "Application started"}
#{"level": "error", "message": "Failed to connect to database"}
#{"level": "warn", "message": "High memory usage detected"}
The developer user only sees the logs relevant to their work, while the verbose debug and trace logs are automatically filtered out.