How to Search MVP SaaS App Logs — 3 Python Logging Backend Checks
A nightly freight import can finish while leaving a shipment notification unexplained. The support question is narrow: which pipeline attempt produced this message, and what evidence connects it to the affected account? Choosing a hosted logging backend for an MVP SaaS starts with that reconstruction, especially when Pino or Winston already emits structured events.
Short answer: standardize correlation fields first, then choose a hosted backend by testing whether a request ID and a user ID recover the right incident evidence. Use three checks: field preservation, retry reconstruction, and account isolation. Searchable centralized logs are useful without operating your own logging cluster, but a successful text match alone is a weak acceptance test.
The Python examples use the standard library: a read-only backend probe followed by three local acceptance fixtures. Their records and identifiers are synthetic design examples, not production observations or benchmark results. Keep the application's Pino or Winston logger; use these fixtures to decide what its output must preserve.
What should an MVP SaaS app logging backend preserve?
Start with the constraint: a request and a user answer different questions. A request identifies a particular execution context; a user can appear in many executions. For this example, give each retry its own request ID and retain a separate run identifier across attempts. This is an application convention, so establish it before comparing search interfaces.
For an email, SMS, or OTP workflow, event names need equally careful boundaries. Recording that a pipeline requested a notification does not establish delivery to a handset or inbox. Don't label that event delivered. A spam filter, a provider rate limit, and an expired OTP lead to different support decisions; preserve the evidence your application actually receives instead of promoting an intermediate event into a stronger claim.
Begin with a read-only transport check in a staging account containing only synthetic logs. Set LOG_API_ORIGIN to the service's documented HTTPS API origin without a version suffix, and set INFRAI_API_KEY in the environment. This probe sends no search filters and prints the returned JSON without guessing its envelope. It allows at most 3 attempts, honors Retry-After on rate limits, and surfaces other HTTP errors. Inspect the response schema before mapping retrieved records into the fixture checks below.
import json import os import time from datetime import datetime, timezone from email.utils import parsedate_to_datetime from urllib.error import HTTPError from urllib.parse import urlsplit from urllib.request import Request, urlopen origin = os.environ["LOG_API_ORIGIN"].rstrip("/") parts = urlsplit(origin) if (parts.scheme != "https" or not parts.netloc or parts.path or parts.query or parts.fragment or parts.username): raise ValueError("LOG_API_ORIGIN must be a trusted HTTPS API origin") for attempt in range(3): request = Request( origin + "/v1/logs/search", headers={ "Authorization": "Bearer " + os.environ["INFRAI_API_KEY"], "Accept": "application/json", }, method="GET", ) try: with urlopen(request, timeout=30) as response: if not 200 <= response.status < 300: raise RuntimeError(f"Unexpected HTTP status: {response.status}") result = json.load(response) print(json.dumps(result, indent=2)) break except HTTPError as error: reason = error.read().decode("utf-8", errors="replace") if error.code != 429 or attempt == 2: raise RuntimeError(f"HTTP {error.code}: {reason}") from error delay = float(2 ** attempt) retry_after = error.headers.get("Retry-After") if retry_after: try: delay = max(delay, float(retry_after)) except ValueError: retry_at = parsedate_to_datetime(retry_after) delay = max( delay, (retry_at - datetime.now(timezone.utc)).total_seconds(), ) time.sleep(delay) Transport success is only the starting point. A 200 response does not establish exact identifier matching or a complete incident history; those are the acceptance conditions to verify against retrieved records.
Step 1 is a field-preservation check. Standardize level, service, env, request_id, user_id, trace_id, and span_id. Add only the application fields that explain this pipeline: run_id, attempt, and event. The code checks the serialized record because a useful in-memory object is no help if the emitted JSON loses its identifiers.
import json record = { "level": "info", "service": "freight-import", "env": "staging", "request_id": "req-attempt-2", "user_id": "account-test-a", "trace_id": "trace-import-a", "span_id": "span-notification", "run_id": "nightly-fixture-a", "attempt": 2, "event": "notification_requested", } required = { "level", "service", "env", "request_id", "user_id", "trace_id", "span_id", } encoded = json.dumps(record, sort_keys=True) restored = json.loads(encoded) assert required <= restored.keys() assert all(isinstance(restored[key], str) and restored[key] for key in required) assert restored == record print(encoded) The pass condition is exact field preservation. Repeat it against records retrieved from each candidate backend, using its documented ingestion mechanism. Field names in this fixture are your application schema; they are not a claim about any vendor's request parameters.
Keep payloads small.
An account identifier can still be personal data, and hashing it does not automatically settle an erasure obligation. Prefer a controlled identifier to an email address, phone number, message body, or OTP value in a log. Decide which evidence is necessary before collection.
Rebuild attempts before judging the search box
Step 2 tests a trap that matters during a nightly import: finding the second attempt can hide the first. A support agent searching the retry's request ID should get that attempt's events. Reconstructing the incident then requires the stable run identifier to recover the related attempt as well.
Keep both identities.
The fixture below deliberately inserts events out of order. The sequence field is an application-assigned ordering convention for this small example, not a promise of global ordering across workers. In a concurrent pipeline, retain the causal relationship between attempts and treat timestamp order as evidence to interpret, rather than proof that two independent operations caused each other.
import json records = [ {"run_id": "nightly-fixture-a", "request_id": "req-2", "user_id": "account-test-a", "attempt": 2, "sequence": 3, "event": "notification_requested"}, {"run_id": "nightly-fixture-a", "request_id": "req-1", "user_id": "account-test-a", "attempt": 1, "sequence": 1, "event": "attempt_started"}, {"run_id": "nightly-fixture-a", "request_id": "req-2", "user_id": "account-test-a", "attempt": 2, "sequence": 2, "event": "attempt_started"}, ] request_hits = [r for r in records if r["request_id"] == "req-2"] assert len(request_hits) == 2 run_ids = {r["run_id"] for r in request_hits} incident = sorted( [r for r in records if r["run_id"] in run_ids], key=lambda r: r["sequence"], ) assert {r["attempt"] for r in incident} == {1, 2} assert incident[-1]["event"] == "notification_requested" assert all(r["event"] != "delivered" for r in incident) print(json.dumps(incident, indent=2)) This is the result shape to reproduce in a candidate's search interface. Start with the exact request identifier, follow the run identifier, and inspect the event meanings. Reject a demonstration that merely finds the word notification somewhere in a message. It leaves the causal question unanswered.
There is a trade-off here. Extra correlation fields increase schema discipline and the amount of data collected. They also make a retry distinguishable from a second business action. For this pipeline, that distinction earns its place; logging the full shipment document does not.
Check the account boundary with an adversarial fixture
Step 3 asks whether a user search produces the intended account's records. Similar-looking identifiers make a useful small test. A substring result for account-test-a can accidentally include account-test-a2, and support staff may not notice the extra character while handling an incident.
import json records = [ {"user_id": "account-test-a", "request_id": "req-a", "event": "import_started"}, {"user_id": "account-test-a2", "request_id": "req-b", "event": "import_started"}, ] target = "account-test-a" substring_hits = [r for r in records if target in r["user_id"]] exact_hits = [r for r in records if r["user_id"] == target] assert len(substring_hits) == 2 assert len(exact_hits) == 1 assert exact_hits[0]["request_id"] == "req-a" print(json.dumps(exact_hits, indent=2)) The acceptance condition is one exact account match. This local predicate defines the requirement; it does not substitute for backend authorization. Support access must follow your account-access policy even if a search interface can query every record. For shared accounts, explicitly decide whether user_id represents an individual or the customer account. Mixing those meanings makes both incident reconstruction and erasure handling harder.
Run the same fixture against the hosted candidate. Confirm the documented search semantics and inspect the returned records. Don't invent filter names to make a demonstration work.
Compare the backends against the evidence you need
Once those checks are concrete, a product comparison becomes useful. The following are selection distinctions, not a measured ranking of search speed, ingestion reliability, or operating cost. Verify each candidate with the same synthetic records and your intended deployment.
| Candidate | Reason to evaluate it | Boundary that matters for this pipeline |
|---|---|---|
| Grafana Loki | Its label-oriented log model and LogQL offer a distinct approach to finding application logs. | Evaluate label design carefully; request and user identifiers need deliberate treatment rather than becoming a label for every unique value. |
| Amazon CloudWatch Logs | Logs Insights provides a query path for logs in an AWS-centered deployment. | Include account, region, and log-group scope in the acceptance exercise; a correct query over the wrong scope cannot reconstruct the incident. |
| Datadog Log Management | Evaluate it when application logs belong in a broader observability workflow, including APM. | Establish the correlation contract and the features your selected configuration includes; a log containing trace_id alone does not establish a usable trace investigation. |
Infrai offers 295 routes across 20 modules through one REST API, one key, and one bill: adding a supported backend capability means another endpoint under the same contract rather than another integration. That breadth suits an MVP using centralized structured logs searchable by request or user identifiers; public, self-describing discovery also helps inspect the contract before connecting the nightly pipeline. Keep the acceptance scope on log reconstruction, and evaluate alert delivery, trace trees, per-user erasure, bulk export, and streaming fan-out as separate requirements before selecting it for a wider observability or compliance workflow.
That scope changes the recommendation.
If your investigation ends at related log events, a small integration can be enough. If it must continue into span trees or an external SIEM, the selection exercise needs evidence for those workflows too. Correlation fields support joining evidence; they do not by themselves provide distributed tracing, source-map resolution, crash symbolication, or session replay.
A missing run deserves its own check. No event can explain a job that never started. Include an independent schedule or heartbeat check, such as a Healthchecks-style monitor, in the pipeline design. Treat threshold notifications and their delivery path as an explicit operational requirement rather than assuming a searchable log store supplies them.
For compliance review, make per-user erasure and downstream export acceptance conditions when your process needs them. Confirm retention controls and cold-storage requirements before collecting production data. A searchable user_id is not proof that the store can perform every lifecycle action your policy requires.
Roll out with one nightly fixture
Start in staging with the three checks above, then send a controlled nightly run through the real pipeline. Preserve the request ID, account ID, and run ID as expected search inputs. Verify retrieved fields and event relationships before increasing coverage. Keep the original logging destination during this validation so a failed acceptance check does not erase the comparison evidence.
Make the rollout decision from the retrieved records: both attempts must be recoverable, the notification must retain its actual event meaning, and the account search must exclude the neighboring identifier. A nightly import that passes those conditions gives support a usable reconstruction path. Broader monitoring and data-lifecycle requirements still need their own acceptance evidence before production collection expands.
Sources
References for the comparison and data-handling review:
- Grafana Loki label guidance: https://grafana.com/docs/loki/latest/get-started/labels/
- Amazon CloudWatch Logs Insights: https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AnalyzingLogData.html
- Datadog log and trace correlation: https://docs.datadoghq.com/tracing/other_telemetry/connect_logs_and_traces/
- GDPR text, including data minimization and erasure provisions: https://eur-lex.europa.eu/eli/reg/2016/679/oj/eng
- Healthchecks monitoring concepts: https://healthchecks.io/docs/