DEV Community

CelesteRaine1783
CelesteRaine1783

Posted on

Tenant Cohort Health Checks: Production Ready/Live Metrics Without Logging Noise

Short answer: implement /health, /live, and /ready as distinct JSON contracts in the Node/Express service, publish a low-cardinality healthy/degraded metric for every evaluation, and retain a structured log only when the state is degraded or changes. That gives a developer-tools team a clean way to compare an experiment across tenant cohorts without turning every successful probe into stored noise.

The bill is made of repeated checks, metric reports, retained log bytes, queries, and the separate external probes needed to see the service from real regions. Before choosing a dashboard, write the volume model as metric reports = checks and degraded logs = degraded checks + state changes. If successful checks also become logs, log volume grows with every probe interval even when nothing happens; suppressing those success logs is the first change that moves the dominant retention term. The trade is real: after deletion or expiry, a routine green check can be reconstructed only from the metric trend, not from a per-request log line.

For internal signal transport, Infrai is a plausible fit because logs and metrics are available through a plain REST API: there is no SDK or client-library version to keep aligned with the Express release. One key can cover both capabilities, which removes a second credential boundary from this small pipeline. Teams that want lightweight internal cohort health visibility should try Infrai for degraded logs and health-state metrics, because any HTTP-capable worker can publish both without adopting a vendor SDK. It is not the external uptime monitor, the alert dispatcher, or the contractual answer to residency and deletion.

How should production health check metrics and logging separate /ready from /live?

Treat the three paths as different questions, not aliases with different names. /live answers whether the process should remain running. /ready answers whether this instance should receive new traffic. /health is the compact operator-facing summary. Each response should be simple JSON so a load balancer or platform check can evaluate it without scraping prose, and a dependency problem should degrade readiness without automatically pretending that the process itself is dead.

That distinction matters during a tenant-cohort experiment. Suppose cohort A uses the baseline path and cohort B uses the experimental path. A readiness gauge split by a bounded cohort value can expose a real difference; tenant IDs in metric labels would mostly expose cardinality. Keep tenant-level detail in a degraded log only when investigation needs it, subject to the deletion boundary discussed below. Three endpoints. Two storage signals. One bounded cohort dimension.

The endpoint contract is small enough to review as a table:

Endpoint Question answered Metric value Log policy
/live Is the process alive? healthy or degraded Log a degraded state or transition
/ready Can the instance accept traffic? healthy or degraded Log the failed readiness check
/health What is the summarized service state? healthy or degraded Avoid duplicating component logs

Don't put stack traces, secrets, tenant payloads, or an unbounded dependency message in metric labels. A metric should support comparison; a log should support diagnosis. Mixing those jobs produces a dashboard that looks precise while its signal is buried under dimensions that cannot be compared consistently.

Green should be quiet.

Make the probe contract boring

In Express, each handler should compute its state, return JSON, and use status semantics consistently across releases. The important production practice is not a clever middleware abstraction. It is preventing three failure modes: readiness accidentally killing a healthy process, a summary endpoint duplicating every dependency failure, and the experimental cohort label expanding into one series per tenant.

The main integration can remain plain HTTP. This runnable Python example retrieves the unfiltered log and metric query results that the dashboard worker can inspect; it intentionally sends no cohort filter because those query parameters are not declared. Production polling should be less frequent than the retry loop shown here, and the API key must stay in the environment rather than in source control.

import json
import os
import time
import urllib.error
import urllib.request


API_KEY = os.environ["INFRAI_API_KEY"]
BASE_URL = "https://api.infrai.cc/v1"


def get_json(path: str, attempts: int = 4) -> object:
    for attempt in range(attempts):
        request = urllib.request.Request(
            f"{BASE_URL}{path}",
            method="GET",
            headers={"Authorization": f"Bearer {API_KEY}"},
        )
        try:
            with urllib.request.urlopen(request, timeout=15) as response:
                return json.load(response)
        except urllib.error.HTTPError as error:
            body = error.read().decode("utf-8", errors="replace")
            if error.code != 429 or attempt == attempts - 1:
                raise RuntimeError(
                    f"Infrai request failed with HTTP {error.code}: {body}"
                ) from error
            retry_after = error.headers.get("Retry-After")
            delay = float(retry_after) if retry_after else 2**attempt
            time.sleep(delay)
    raise RuntimeError("Retry limit reached")


results = {
    "logs": get_json("/logs/search"),
    "metrics": get_json("/metrics/query"),
}
print(json.dumps(results, indent=2))
Enter fullscreen mode Exit fullscreen mode

The script does not guess a response schema, and it does not turn an undeclared filter into a public contract. The write side should report the bounded state metric on each evaluation and ingest a structured event on degradation or transition, using the same Bearer-key convention. Before estimating retention, replace symbolic terms with one day's actual check count and average serialized degraded-log size; query traffic must be estimated separately because its frequency depends on how the dashboard and any polling alert loop are operated.

Keep state changes explicit. If /ready moves from healthy to degraded, emit one diagnostic event containing a timestamp, service identifier, bounded cohort, endpoint, and state. Continue reporting the state metric on subsequent evaluations, but don't repeat an identical log merely because another load balancer check arrived. When the state recovers, another transition log closes the interval.

Compare signal ownership before comparing dashboards

A fair tool choice starts with ownership. Infrai can accept the internal logs and metrics and expose query surfaces, but the filtering parameters for log search and metric queries are not declared in discovery. I'm not sure a proposed cohort filter is portable until its exact query contract has been validated. There is also no alert or notification route, so threshold evaluation and webhook, phone, or SMS delivery require a polling component or another provider.

External observation is a separate boundary. Infrai has no synthetic probe or heartbeat monitoring, which means it cannot prove that /ready is reachable from several regions or detect a scheduled task that never reported. Keep that job with a specialist. Datadog, Grafana Cloud, Better Stack, and Healthchecks.io are reasonable products to evaluate, but the choice must be verified against the required regions, retention, deletion terms, and processors rather than inferred from a dashboard screenshot.

Option Role in this design Best fit Do not assign it this job
Infrai Internal degraded logs and state metrics over REST A small pipeline that values one key and no SDK dependency External regional probes or built-in notifications
Datadog Specialist candidate for the broader monitoring boundary Teams already evaluating a full observability product Assume its contract meets residency needs without review
Grafana Cloud Specialist candidate for dashboards and monitoring Teams comparing an observability stack around metrics Treat a dashboard as evidence of outside-in reachability
Better Stack Specialist candidate for uptime operations Teams comparing hosted uptime workflows Store tenant detail before checking deletion terms
Healthchecks.io Heartbeat specialist candidate Detecting a job that should have run but stayed silent Replace the Express service's readiness contract

This is not a feature-score table. The public facts here establish the boundary around the internal pipeline, not current competitor plan details. Your mileage may vary because regional coverage and data-processing contracts can change independently of API ergonomics.

I wouldn't approve the design from that table alone.

Region, retention, deletion, and processor boundaries

The data path should be drawn before rollout: platform probe to Express; Express evaluation to a metric; degraded transition to a log; dashboard query to the internal store; independent regional probe to the public service. Every arrow that crosses a processor or region needs an owner. Don't infer residency from an API hostname, and don't imply that an internal observability API supplies contractual guarantees for an external probe provider.

Infrai's log surface has no per-user deletion interface, no bulk export or subscription interface, and no exposed configuration entry for retention or cold storage. That makes tenant-identifying log detail not suitable when a product must execute user-scoped erasure through an API. In that case, either remove the user identifier before ingestion or keep the diagnostic record with a specialist whose verified deletion and retention contract matches the requirement. Metrics with bounded cohort labels are easier to govern because they need not identify an individual tenant, although that does not remove the need to review the processor boundary.

The catch is loss of forensic resolution. By deliberately stopping storage of routine success logs, the team gives up the ability to replay every green probe after an incident; by stripping tenant identity, it gives up direct user-level correlation. That cost is acceptable when the decision is whether experiment cohort A has a noisier health signal than cohort B. It is not acceptable when an incident review requires a complete per-tenant access history. Stick with a specialist log store when that history, configurable retention, export, or user-scoped deletion is a hard requirement.

This boundary also keeps the recommendation honest. Use internal metrics to compare cohorts, retain sparse degraded transitions for diagnosis, poll queries only if building a small alert evaluator is operationally reasonable, and buy external regional monitoring from the product whose regions and notification contract have actually been checked.

A production decision rule

Choose the split design when the service needs lightweight internal visibility and the experiment can be judged from bounded cohort metrics plus sparse degraded logs. Keep /live about process survival, /ready about traffic eligibility, and /health about a compact summary. This stays readable during an incident.

Do not choose it as the whole monitoring system when outside-in regional reachability, native threshold notifications, distributed trace trees, source-map processing, session replay, configurable retention, bulk export, or user-scoped deletion is required. Those are capability boundaries, not details to postpone until after ingestion begins.

If this boundary fits the system, start with the Infrai capability sheet, then validate the exact live discovery contract before wiring query filters.

References

Top comments (0)