5 concepts · 10 practice questions
At a customer you often cannot log in yourself: an operator runs commands on a screen share, or sends you exported logs. Start with when it began, what changed around then, and who is affected, which sets both the search and the severity. Restore service before finding the root cause when a recent change is the likely trigger and a rollback is safe, but capture logs first. Build a diagnostics command into the product in advance, so one request gathers versions, configuration and recent errors with secrets removed.
import json
import platform
import re
from pathlib import Path
APP_VERSION = "3.2.1"
SECRET = re.compile(r"(password|token|secret|api_key)\s*[=:]\s*\S+", re.I)
def diagnostics(config_path, log_path, lines=500):
"""The operator runs this and reviews the output before sending it."""
config = SECRET.sub(r"\1=[redacted]", Path(config_path).read_text())
tail = Path(log_path).read_text().splitlines()[-lines:]
return json.dumps({
"version": APP_VERSION,
"python": platform.python_version(),
"config": config,
"recent_errors": [SECRET.sub(r"\1=[redacted]", line)
for line in tail if " ERROR " in line],
}, indent=2)
Sign in to read the rest and take the 10-question test.
Sign in to continue