Introducing a new way to review your PRs.

Read the announcement

near / nearcore

Reference client for NEAR Protocol

View on GitHub

20 documents · Updated Nov 23, 2026

docs / telemetry-and-node-observability

Telemetry and node observability

NEAR node observability turns node activity into logs, metrics, traces, health responses, and periodic telemetry reports. Operators use these signals to check whether a node is serving requests and following the chain, then move from broad symptoms to detailed execution evidence when they investigate a fault. See Operations and observability for the wider operating model.

Observability signals

The node exposes several signals because each one answers a different operator question. Health and status endpoints give a quick point-in-time view, metrics show change over time, logs explain events, and traces connect work across a request or task.

SignalOperator questionMain view
Health and statusCan the node answer, and what chain state does it report?/health and /status
MetricsIs a value rising, falling, slow, or failing over time?Prometheus text from /metrics
LogsWhat happened, where, and at what severity?Process log output
TracesWhich nested operations made a request or task slow?OpenTelemetry collector and trace store
Network telemetryWhat is the node’s coarse health and identity across the network?Configured telemetry endpoints
Diagnostic toolsWhat detailed state or storage work needs direct inspection?Debug RPC and IO trace output

References: core/…/README.md• L1-10 chain/…/lib.rs• L3183-3213 docs/…/otel_traces.md• L4-20

Node health interfaces

The node’s HTTP service provides small interfaces for liveness and inspection. /health runs a health check through the client and returns success only when that check completes; /status returns the node’s current status view. The same service exposes /network_info for peer-related information and /metrics for the full Prometheus registry.

When operators need to keep metrics access separate from RPC access, the node can start a second HTTP listener that serves only /metrics. The listener is optional, while the regular RPC service includes /metrics whenever RPC is enabled.

References: chain/…/lib.rs• L1182-1203 chain/…/lib.rs• L3036-3060 chain/…/lib.rs• L3183-3190 chain/…/lib.rs• L3215-3289

Metrics

Metrics provide numeric signals that monitoring systems can sample and compare over time. The node uses counters for totals and errors, gauges for current state, and histograms for distributions such as request or processing time; all components share one Prometheus registry.

The most useful metric groups describe node progress and load. They include block and chunk production, transaction and receipt work, peer and system activity, RPC traffic and latency, configuration validity, state sync work, and telemetry upload results. The network layer adds signals for peer connections, traffic by message type, route and edge state, reachability, dropped messages, and routed-message latency and hop counts. The view client also records processing time by message type, which helps separate slow chain-read requests from other client work. The log layer counts messages by severity, with extra target and source-location labels for higher-severity messages.

Some metrics require more work than normal reporting. The runtime setting expensive_metrics controls those measurements, so enabling it can improve diagnosis while adding node work. Metric names normally use the near_ prefix, which keeps node metrics distinct and easier to query.

Routed-message latency is recorded only when the message has a valid creation time. The value is capped at one minute, and hop counts are capped at twenty, so missing or invalid timestamps produce no latency sample and unusually large values appear at the cap.

References: core/…/metrics.rs• L1-20 core/…/metrics.rs• L78-90 core/…/metrics.rs• L214-253 core/…/log_counter.rs• L8-24 core/…/log_counter.rs• L28-72 chain/…/metrics.rs• L462-470 chain/…/view_client_actor.rs• L779-792 chain/…/metrics.rs• L5-76 chain/…/metrics.rs• L111-206 chain/…/metrics.rs• L233-365 chain/…/metrics.rs• L379-410 chain/…/metrics.rs• L421-510 nearcore/…/metrics.rs• L20-80

Logging

Logging records discrete events with a severity, target, and context. The node builds a shared tracing subscriber for process output, and the filter selects which targets and levels reach the log. The default filter favors useful operational messages; RUST_LOG or a target-specific verbose setting can raise detail for a focused investigation.

View-client request handlers emit debug records for incoming work, while selected transaction and network validation failures add targeted messages. This gives operators a request-level trail that can be compared with the matching processing-time metric without making normal request handling depend on verbose logs.

Span logging is separate from trace export. When enabled, it adds span entry and exit events with duration and resource information to the process log. This helps when an operator cannot use a trace collector, but high-volume filters can create substantial log noise.

References: core/…/env_filter.rs• L5-15 core/…/env_filter.rs• L30-75 core/…/subscriber.rs• L36-55 core/…/subscriber.rs• L100-146 core/…/subscriber.rs• L184-213 chain/…/view_client_actor.rs• L724-726 chain/…/view_client_actor.rs• L779-783 chain/…/view_client_actor.rs• L2068-2069

OpenTelemetry tracing

OpenTelemetry tracing carries spans and events to an external collector. A span represents a timed or nested unit of work, while an event marks a point in that work; together they show how node activity moves through a request or task. The node can export at INFO, DEBUG, or TRACE levels, and the exporter identifies each node with chain, node, and validator account attributes when available.

Tracing can cross a network message boundary. The sender places the current trace context in the message, and the receiver restores it so work on different nodes can belong to the same trace. Operators can use the node identity attributes to distinguish traces from several nodes in one trace store.

Tracing is filtered at the selected level and sent through a batch processor. A broad level can create high ingest volume, so target-specific filters are better for focused work. The repository’s trace workflow describes Grafana Loki for events, Tempo for traces, and Jaeger as a local viewing option.

References: core/…/opentelemetry.rs• L13-20 core/…/opentelemetry.rs• L23-69 chain/…/trace_context.rs• L21-69 docs/…/otel_traces.md• L15-46 docs/…/otel_traces.md• L204-217

Runtime observability controls

The file ${NEAR_HOME}/log_config.json is the runtime control point for log filters, OpenTelemetry filters, and expensive metrics. A SIGHUP signal makes neard read the file and apply the new settings without a node restart. If the file is absent, the node returns to its startup settings.

The reload path updates logs and exported traces independently. A malformed filter can fail one or both updates and is reported to the process log, so operators should confirm the update message and then check the signal they intended to change.

When rust_log and opentelemetry use target filters, operators can increase detail for one subsystem without increasing all node output. This keeps local log volume and remote trace ingest within reason.

References: core/…/log_config.rs• L5-25 core/…/README.md• L7-28 nearcore/…/dyn_config.rs• L10-24 nearcore/…/dyn_config.rs• L78-115 core/…/lib.rs• L67-90 neard/…/cli.rs• L619-627 core/…/reload.rs• L83-105 core/…/reload.rs• L109-173

Network telemetry

Network telemetry is a periodic JSON report for a telemetry service, not the detailed trace stream. The node builds the report from agent data, host resource data, and chain data, then sends it to each configured endpoint through an asynchronous actor. The report includes software and protocol version, CPU and memory use, network bandwidth, boot time, chain position, sync status, peer count, validator role, and block-production timing.

The first report is allowed at startup. Later reports are throttled to at most one request per configured interval, which defaults to ten seconds. Each endpoint result is counted as successful or failed, and a failed upload is logged without making the node’s main work depend on the telemetry service.

Mainnet and testnet configuration adds the public NEAR telemetry endpoint by default. Operators can add an endpoint with the run command or configure endpoint and interval values in the node configuration.

References: core/…/telemetry.rs• L1-47 chain/…/info.rs• L44-73 chain/…/info.rs• L560-618 chain/…/lib.rs• L12-30 chain/…/lib.rs• L40-73 chain/…/lib.rs• L87-122 chain/…/metrics.rs• L1-11 nearcore/…/config.rs• L224-243 nearcore/…/config.rs• L1183-1197 neard/…/cli.rs• L470-483 neard/…/cli.rs• L550-554

Diagnostic tooling

Diagnostic tooling gives an operator more detail than normal health checks and dashboards. Debug RPC is disabled by default because some views can be CPU-heavy; when enabled, it adds block, epoch, thread, client-config, and other debug views to the node’s HTTP service.

The optional IO trace records the sequence of database and storage operations under nested spans. It is intended for deep storage and cache analysis, and its output can be replayed by the runtime parameter estimator. Use it for a bounded investigation rather than as a normal production signal because its detail can be much higher than ordinary logs or traces.

The node also runs a periodic trie metric task. It reports postponed receipts by shard, which gives an operator a direct congestion signal and can emit detailed trie records only when trace logging is enabled.

References: chain/…/lib.rs• L172-190 chain/…/lib.rs• L3192-3207 core/…/subscriber.rs• L47-55 core/…/subscriber.rs• L149-169 core/…/io_tracer.rs• L1-18 nearcore/…/metrics.rs• L83-100 nearcore/…/metrics.rs• L185-211 nearcore/…/lib.rs• L666-672

Investigation flow

An investigation works best when it starts with low-cost signals and adds detail only when the symptom is clear. The following flow links the node interfaces to the evidence they produce.

flowchart TD
    A[Node symptom or alert] --> B{Health and status respond?}
    B -- No --> C[Check node logs and process state]
    B -- Yes --> D[Check metrics over time]
    D --> E{Slow, failing, or out of range?}
    E -- No --> F[Check peers and chain telemetry]
    E -- Yes --> G[Raise a target-specific log filter]
    G --> H[Enable focused OpenTelemetry spans]
    H --> I[Inspect trace in collector or trace store]
    I --> J{Storage or cache detail needed?}
    J -- Yes --> K[Capture and replay an IO trace]
    J -- No --> L[Use debug views and status details]

The first split separates an unavailable node from a node that is available but unhealthy. Metrics then show whether the issue is persistent or isolated. Logs, traces, and IO traces add successively finer detail, while runtime filters limit the cost of that detail.

References: chain/…/lib.rs• L3036-3060 chain/…/lib.rs• L3183-3190 core/…/reload.rs• L118-173 core/…/io_tracer.rs• L9-18 docs/…/otel_traces.md• L23-46

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the /metrics route, its optional separate listener, and Prometheus scrape access aligned when RPC configuration changes.
  • Keep LogConfig, dynamic-file loading, SIGHUP handling, and filter reload behavior aligned so a setting has the same meaning at startup and at runtime.
  • Keep OpenTelemetry resource attributes aligned with the identity fields used by trace queries when node or validator identity changes.
  • Keep telemetry payload fields, endpoint throttling, and upload-result metrics aligned when the network dashboard contract changes.
  • Keep metric names and label sets unique across the global registry when adding node or subsystem metrics.
  • Keep network metric label schemas and bounded latency or hop values aligned with dashboards when peer or routing metrics change.
  • Keep view-client message labels aligned with the handlers that record request latency so dashboards do not lose or misclassify read-request timing.
  • Keep IO trace producers and the estimator replay format aligned when storage or runtime trace fields change.

Important failure modes

TriggerConsequenceGuard
The health check cannot complete through the client/health returns 503 Service UnavailableCompare /health with /status and inspect node logs before treating the HTTP listener as down
prometheus_addr is set to the same address as the RPC listenerNo second metrics server is startedScrape /metrics on the main RPC address or use a distinct listener address
log_config.json contains an invalid filterThe affected log or trace filter is not applied and the reload reports an errorUse valid target-level directives and confirm the reload log
A configured telemetry endpoint is emptyTelemetry actor creation panics during node startupValidate endpoint values before starting the node
A telemetry upload fails or times outThe report is not delivered to that endpoint, but node processing continuesCheck telemetry result metrics and target telemetry warnings
A metric name conflicts in the global registryMetric creation fails and the owning component can fail to initializeUse a unique near_-prefixed name and stable labels
A routed message has no creation time or a future creation timeNo routed-message latency sample is recordedTreat missing samples as a timestamp or clock-data limit, not as zero latency
A routed message is older than one minute or has more than twenty hopsThe reported value is capped and does not show the full observed valueInterpret capped latency and hop values as lower bounds for unusually large observations
IO tracing is enabled for a high-volume workloadDetailed output can add load and obscure normal timingEnable it only for a focused storage investigation

Key files

FileWhy to read it
core/…/subscriber.rsShows how process logs, span events, OpenTelemetry export, and IO trace output are assembled.
core/…/reload.rsShows how runtime settings change log and trace filters and expensive metrics.
core/…/metrics.rsDefines the shared Prometheus registry and metric rules.
chain/…/lib.rsDefines health, status, metrics, and optional debug HTTP surfaces.
chain/…/metrics.rsIllustrates the RPC metrics that expose request volume, latency, timeouts, and errors.
chain/…/view_client_actor.rsShows how read requests expose debug logs and per-message processing latency for RPC and network-assisted views.
chain/…/metrics.rsDefines client health, chain progress, state sync, and view-client latency metrics.
chain/…/info.rsShows how node state becomes periodic metrics and network telemetry data.
chain/…/metrics.rsDefines network metrics for peers, message traffic, routing, drops, reachability, and routed-message timing.
chain/…/lib.rsShows the reporting boundary, endpoint throttle, and upload outcome behavior.
core/…/telemetry.rsDefines the high-level telemetry payload shared with telemetry consumers.
nearcore/…/dyn_config.rsShows how runtime configuration files are read and how invalid settings affect node health metrics.
chain/…/trace_context.rsShows the trace context contract used across network messages.
core/…/io_tracer.rsExplains the optional detailed storage trace and its replay purpose.
docs/…/otel_traces.mdGives the operator and developer workflow for collecting and viewing OpenTelemetry traces.