Skip to content

Troubleshooting: Usage Billing - Data Enrichment

The DIP enricher reads raw events from the RAW_EVENTS_<n> NATS streams, enriches them, and publishes the results to the ENRICHED_EVENTS_<n> streams. Exporters read from those. This page covers raw messages the enricher gave up on.

The enricher retries a raw message that fails, with increasing delays (1s, 5s, 30s, then 60s), and stops after 15 deliveries, about 12 minutes of retries. It stops immediately when the failure can never succeed. A stopped message is terminated: NATS does not deliver it again, and its events are not enriched or exported until someone replays it.

Each terminated message increments enricher_messages_terminated_total, labeled with a reason:

reasonMeaningReplay once the cause is fixed?
max_deliveriesA failure that could have been temporary (NATS unavailable, publish timeouts) lasted for all 15 deliveries.Yes. The events are probably valid.
permanent_errorA failure that repeats on every delivery: the enricher panicked on the payload, or a result was larger than the NATS message size limit.No. Replaying fails the same way. Keep the payload for the DIP team.

Terminated messages stay in the raw stream until the stream’s retention expires. Replay or save them before then.

  • Query enricher_messages_terminated_total by reason in Grafana Explore (it isn’t on a dashboard yet). Are many messages being terminated, or a few?
    • Many max_deliveries at once usually means NATS was unavailable for more than ~12 minutes. Check NATS health first: NATS - Usage Billing Dashboard, NATS - Runbooks.
    • A few permanent_error usually means malformed input from a client.
  • On the Data Insights Platform - Usage Billing Dashboard, check the Enrichment panels for a drop in enriched events.

In Kibana, search the enricher’s logs for:

"handling message, terminating"

Each entry carries:

  • stream and stream_seq: where the raw message is in NATS.
  • num_delivered: how many times it was delivered.
  • reason: max_deliveries or permanent_error.
  • error: the last failure.

Earlier attempts for the same message are logged as handling message, will retry with the same stream_seq.

Use the nats CLI in the nats-box deployment (see NATS Operations), after connecting to the cluster as described in GKE setup:

➜ ~ kubectl -n nats exec -it deploy/nats-box -- sh
~ # nats stream get RAW_EVENTS_0 123456

The output shows the message’s subject, headers, and payload. Raw events are Thrift-encoded, so the payload is mostly binary. To share or replay the message, save it to your workstation instead of the pod, where it would be lost on restart:

➜ ~ kubectl -n nats exec deploy/nats-box -- nats stream get RAW_EVENTS_0 123456 --json > raw-123456.json
➜ ~ jq -r .subject raw-123456.json

The file holds the message’s subject and its payload in data, base64-encoded. Payloads can contain customer data, so share them only in a confidential issue.

  • For max_deliveries, once the cause (usually NATS) is fixed, publish the payload again to its original subject. The enricher processes it as a new message:

    ➜ ~ jq -r .data raw-123456.json | base64 -d \
    | kubectl -n nats exec -i deploy/nats-box -- nats pub "$(jq -r .subject raw-123456.json)" --force-stdin --no-templates

    --no-templates is required: by default, nats pub treats {{ in the payload as a template and changes the bytes it publishes. The raw message had no NATS headers, so the replay is identical to the original.

    Replay each terminated message once. If some of its events were published before it was terminated, replaying publishes them again. DIP promises at-least-once delivery and leaves deduplication to destination systems (see Message queueing).

  • For permanent_error, don’t replay. Open a confidential issue for the DIP team (~“group::platform insights”) with the stream, stream_seq, error, and the saved raw-<stream_seq>.json, before the stream’s retention removes the message.