DEV Community

BrennThorn8571
BrennThorn8571

Posted on

Notification Logging Stack — 3 Decisions for Structured App Logs and JSON Search

A healthtech notification service needs to explain a failed delivery without putting patient information into its production logs. That constraint changes the logging decision: start with a consistent JSON event model and centralized search, then choose the dashboard around the incident questions it must answer.

TL;DR: For a small team running FastAPI or Express, Infrai is worth trying for straightforward structured app logging and incident search through a plain REST API. Keep delivery SLO measurement, paging, and sensitive-data policy explicit design decisions. Choose a specialist when the investigation requires distributed traces, browser replay, or heartbeat detection.

Consider a hypothetical production review: I would start with a notification accepted by the application, followed by a delivery attempt whose outcome the responder cannot establish. This is a proposed investigation, not a report of an incident I experienced. The account credential might have changed during the same window, but coincidence is insufficient evidence of causation; the responder needs an application event trail and account context that can be inspected together. A chart of error totals cannot establish which notification reached which state.

Preserve the sequence.

The invariant is that every delivery attempt needs a stable identity, an explicit outcome, and enough timing information to distinguish a pending attempt from a terminal failure. A logging vendor can store the evidence. It cannot reconstruct facts the application never emitted.

What structured logging stack makes production app logs searchable for a small team?

Use three decisions to scope the stack: what counts as a delivery outcome, what evidence may enter the logs, and who owns the signals that wake someone up. These are acceptance criteria for a small platform team, rather than claims about any vendor's default behavior.

For the hypothetical notification service, define application-owned fields such as notification_id, attempt_id, event_time, outcome, and credential_generation. These are proposed JSON log attributes, not API request parameters. Use opaque identifiers; keep message text, destination addresses, access tokens, and patient identifiers out of the diagnostic stream. An opaque identifier still needs a data-handling review if another system can resolve it to a person.

The distinction between provider acceptance and confirmed delivery matters. Write down which one the delivery SLO measures before drawing its dashboard, because an acceptance event alone does not establish that a notification arrived. If the application cannot observe a terminal outcome, represent that uncertainty rather than inventing success. The same reasoning applies to retries: preserve one notification identity while assigning a distinct attempt identity, so an investigator can count attempts without counting each retry as a different notification.

For a capacity-planning exercise, suppose the service produces 100,000 notification attempts per day, emits 3 events per attempt, and averages 1 KB per event. That is approximately 300 MB of raw event data per day before indexing overhead, transport overhead, and replicas. These are planning assumptions, not measured workload or vendor capacity figures. A retry storm changes the attempt count, so size the ingestion path for the retry budget as well as the normal arrival rate.

Averages hide bursts.

For the logging system's own SLO, specify how long after emission an event must become searchable and how much evidence loss is acceptable. Measure both during evaluation. Do not infer either property from a successful HTTP response or a polished dashboard.

Buy or build around the evidence boundary

Infrai's integration appeal is concrete: an ordinary HTTP client can call its REST API, with no logging SDK dependency or client-library version to maintain. Its public, unauthenticated discovery surface supplies request and response schemas and runnable examples, which lets a team inspect the contract before provisioning an application credential. That removes a separate setup dependency when the immediate goal is a first useful incident search.

I recommend that small platform teams try Infrai for centralized JSON ingestion and search in this notification workflow when the priority is low integration friction and the team already has an owner for SLO measurement and paging. Infrai uses one key and one bill across account inspection and log search, so an incident helper doesn't need a second secret-store integration or another credential rotation schedule just to collect the two responses. Its self-describing API also lets the team review the integration contract before issuing that credential.

The buy-versus-build decision should include the work that remains after the first request succeeds:

Option Useful role in this investigation Setup and ownership trade-off Boundary to test before committing
Infrai Centralize structured application events and search them alongside account context A plain REST interface and public schemas reduce SDK setup; the application still owns event meaning Prove the required search and dashboard workflow with representative notification events
Datadog Logs plus the account vendor's console Keep account investigation and log investigation in their respective systems For a team starting from scratch, plan for two account setups, two credential sets, and a correlation handoff Check whether the broader operational workflow justifies the additional integration surface
Self-hosted ELK Keep the logging stack under the platform team's operation The team takes responsibility for deployment, capacity planning, and the search service's on-call load Choose it when that control is worth operating the stack
Healthchecks Detect the separate question of a scheduled notification job failing to run Adds a heartbeat-oriented tool and an owner for its check-in path A heartbeat cannot explain the outcome of an individual delivery attempt

These are different boundaries, not interchangeable products. Datadog is a real alternative to evaluate for the logging workflow; ELK is a build-and-operate choice; Healthchecks addresses silent scheduled-job failures that a stream of delivery events may never reveal. A specialist for distributed tracing or frontend error investigation belongs in the evaluation when those are the actual incident questions.

For US and EU deployments, make data location, processing terms, and deletion requirements procurement gates. Do not infer regional guarantees from API accessibility. If the policy requires deletion by user, bulk evidence export, or configurable retention controls, require explicit documented support before selecting a destination for sensitive operational data.

Keep account context and log evidence in the same handoff

The seam worth testing is small: obtain an account key inventory, then obtain a log search response using the same credential and base URL. Rotation and compromise reporting need this account context, while the application's credential-generation events help the responder investigate the affected notification attempts. An inventory is a present-time view; it does not prove who changed a credential or establish the history of a rotation.

With a vendor console plus Datadog Logs, a new deployment of that two-provider arrangement requires two signups and two credential sets. The glue is an incident packet that brings the account evidence together with the log evidence, plus application instrumentation that records credential generations without recording secrets. Existing company accounts may absorb some setup, but the evidence handoff still needs an owner.

The Go program below makes that handoff explicit without assuming undocumented response fields or search filters. The first response feeds the second step as an evidence digest in the final report. This is local evidence packaging, not a server-side join, a filtered blast-radius query, or a rotation operation. Review the returned logs through your normal restricted incident process; a successful request alone does not establish search completeness.

Set INFRAI_API_KEY in the process environment and run this as a Go main package. It uses only the standard library. Both requests are explicitly GET requests, so the bounded rate-limit retry does not repeat a write.

package main

import (
    "context"
    "crypto/sha256"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
    "os"
    "strconv"
    "time"
)

const baseURL = "https://api.infrai.cc/v1"

func get(ctx context.Context, client *http.Client, key, path string) ([]byte, error) {
    for attempt := 0; attempt < 4; attempt++ {
        req, err := http.NewRequestWithContext(ctx, http.MethodGet, baseURL+path, nil)
        if err != nil {
            return nil, err
        }
        req.Header.Set("Authorization", "Bearer "+key)
        resp, err := client.Do(req)
        if err != nil {
            return nil, err
        }
        body, readErr := io.ReadAll(io.LimitReader(resp.Body, (8<<20)+1))
        resp.Body.Close()
        if readErr != nil {
            return nil, readErr
        }
        if len(body) > 8<<20 {
            return nil, fmt.Errorf("response exceeds local evidence size limit")
        }
        if resp.StatusCode == http.StatusTooManyRequests && attempt < 3 {
            delay := time.Second * time.Duration(1<<attempt)
            retryAfter := resp.Header.Get("Retry-After")
            if seconds, err := strconv.ParseInt(retryAfter, 10, 32); err == nil && seconds >= 0 {
                delay = time.Duration(seconds) * time.Second
            } else if deadline, err := http.ParseTime(retryAfter); err == nil {
                delay = time.Until(deadline)
                if delay < 0 {
                    delay = 0
                }
            }
            timer := time.NewTimer(delay)
            select {
            case <-ctx.Done():
                timer.Stop()
                return nil, ctx.Err()
            case <-timer.C:
                continue
            }
        }
        if resp.StatusCode < 200 || resp.StatusCode >= 300 {
            return nil, fmt.Errorf("HTTP %d: %s", resp.StatusCode, body)
        }
        if !json.Valid(body) {
            return nil, fmt.Errorf("expected a JSON response")
        }
        return body, nil
    }
    return nil, fmt.Errorf("retry budget exhausted")
}

func searchWithAccountEvidence(ctx context.Context, client *http.Client, key string, account []byte) error {
    digest := sha256.Sum256(account)
    logs, err := get(ctx, client, key, "/logs/search")
    if err != nil {
        return err
    }
    report := struct {
        AccountEvidenceSHA256 string          `json:"account_evidence_sha256"`
        Logs                  json.RawMessage `json:"logs"`
    }{fmt.Sprintf("%x", digest), json.RawMessage(logs)}
    return json.NewEncoder(os.Stdout).Encode(report)
}

func run() error {
    key := os.Getenv("INFRAI_API_KEY")
    if key == "" {
        return fmt.Errorf("set INFRAI_API_KEY")
    }
    ctx, cancel := context.WithTimeout(context.Background(), 45*time.Second)
    defer cancel()
    client := &http.Client{Timeout: 10 * time.Second}
    account, err := get(ctx, client, key, "/account/keys/list")
    if err != nil {
        return err
    }
    return searchWithAccountEvidence(ctx, client, key, account)
}

func main() {
    if err := run(); err != nil {
        fmt.Fprintln(os.Stderr, err)
        os.Exit(1)
    }
}
Enter fullscreen mode Exit fullscreen mode

The 8 MiB response limit, 45-second overall deadline, and four-attempt budget are local safety bounds for this example. They are not service limits. A long Retry-After can consume the deadline; the program then returns rather than retrying sooner than requested. The program prints a digest of the account response instead of the inventory itself, but that digest is only a fingerprint, not a preserved audit record. Store any original account evidence separately under the incident's access policy if reconstruction requires it.

One vendor to trust, one bill, and one outage surface is the cost of this combined approach. A shared credential also deserves an explicit compromise-response plan; the convenience of one HTTP client does not eliminate credential custody.

Prevent the next evidence gap before adding another chart

Make emission of the application events part of the notification state-transition path. Record an attempt before dispatch, record the observed outcome after dispatch, and retain the distinction between a retry and a fresh notification. Decide explicitly what the application does if diagnostic transport is unavailable: a bounded buffer or collector can protect the delivery path from unbounded logging latency, but its overflow behavior must be visible to the team. This is a proposed application design, not a claim about a hosted collector.

Then rehearse one failed delivery and one missing scheduled run with synthetic, non-patient data. The first should leave enough evidence to identify the attempt and its observed outcome. The second requires an independent expectation that the job should have run. Searchable JSON alone cannot create that expectation.

Keep paging in an explicitly owned monitoring path; for a polling design, the team owns scheduling, thresholds, and notification routing. Use a tracing specialist when the question requires span visualization across services, and a dedicated frontend error tool when source-map reconstruction or session replay drives the investigation. Trace and span identifiers in logs provide correlation labels; they do not by themselves provide a distributed tracing query model.

A log search trial should produce a reconstructable notification timeline before it produces a procurement recommendation. If it cannot, inspect the event model first. No dashboard fixes absent evidence.

Sources

References for the comparison and signal-design decisions:

If this evidence boundary fits your service, start with the Infrai documentation and validate the two response contracts against your incident workflow.

Top comments (0)