Skip to content

[yamcs-recorder] Export YAMCS events to Loki - #303

Merged
FarkasJoseph merged 5 commits into
v6from
yamcs/events-otel
Oct 8, 2026
Merged

FarkasJoseph merged 5 commits into
v6from
yamcs/events-otel

Conversation

@FarkasJoseph

Copy link
Copy Markdown
Collaborator

Why

Grafana can't show YAMCS events yet. yamcs-recorder copies only telemetry from YAMCS into TimescaleDB, so the Hermes datasource hides its Events query.

What

  • With --otlp host:port, yamcs-recorder also sends each new YAMCS event to Loki, Grafana's log database, through the OpenTelemetry collector at that address.
  • Each event becomes one Loki log line with its message, generation time and a level from its YAMCS severity, for example warn for WATCH.
  • Its other YAMCS fields become Loki fields you can filter on, named yamcs_<field>, and each entry of its extra map, such as an F Prime argument, becomes yamcs_extra_<key>.
  • Docker compose now runs Loki and the collector from the existing configs, and events show up in Grafana's existing Loki datasource.

Testing

  • Unit tests in CI check the log record each YAMCS severity, field and argument turns into.
  • Ran no-op commands against YAMCS 5.12.8 through this branch's compose, with Grafana's plugin download turned off. Their events reached Loki matching YAMCS's archive field by field, and Grafana showed them as info and warn.
  • After a collector restart, export resumed within 7 seconds.

Notes

  • Grafana can miss events that YAMCS still archives. With the defaults in config/loki.yml, Loki rejects an event more than an hour older than the newest for its instance, more than 7 days old, or more than 10 minutes in the future, so a late downlink can leave gaps. Editing that config can raise those limits. Events raised while the recorder or collector is down are lost too.
  • F Prime event arguments arrive as fprime-yamcs's Python str() text, so structs aren't JSON, bools read True and opcodes are plain numbers. That's fixable upstream.
  • The root compose's Grafana doesn't start, because Hermes's latest release, v5.0.8, lacks the plugin zip it downloads. That predates this PR.

- Add the Go bindings the proto-go-yamcs script generates from events.proto and events_service.proto
- Add SubscribeEvents, which subscribes to an instance's new events
- Test subscribing when YAMCS_GRPC_ADDRESS is set, raising one event with CreateEvent
- Describe the event subscription test in the README
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Grafana plugin dev build

A development build of the Grafana datasource plugin is available for this PR (updated on every push).

To try it, set GF_INSTALL_PLUGINS to https://github.com/nasa/hermes/releases/download/grafana-plugin-pr-303/nasa-hermes-datasource.zip;nasa-hermes-datasource.

- Add LogRecord, which maps an event's times, severity, message and fields onto a log record
- Number each YAMCS severity in its OpenTelemetry band, with CRITICAL and SEVERE in FATAL, and leave the severity text unset
- Put YAMCS's own fields, including the severity name, in yamcs.<field> attributes, leaving out an empty type or createdBy
- Map WARNING_NEW to WARNING and ERROR to SEVERE in yamcs.severity
- Add each extra entry as a yamcs.extra.<key> attribute, in key order
- Test the conversion against archived fprime-project events
- Add a loki service using config/loki.yml, publishing 3100 and keeping its data in a loki-data volume
- Add an otel-collector service using config/otel-collector.yml, publishing OTLP on 4317 (gRPC) and 4318 (HTTP)
- Start Loki with Grafana, which provisions a Loki datasource
- Add --otlp, the collector's OTLP gRPC address, and log at startup whether events are exported
- Exit at startup when --otlp is not host:port
- Subscribe to the instance's events and emit each as a log record from a second goroutine
- Batch and export records with service.name set to the instance, and flush them on exit
- Cap gRPC's wait between reconnects to the collector at 5 seconds
- Return from run when either subscription ends, after stopping the other
- Log OpenTelemetry SDK errors through the recorder's logger
- Add an events count to the stats line
- Describe event export, its log record mapping, the events Loki drops and Loki queries in the package doc and README
- Point the datasource plugin README's Events note at Loki
@FarkasJoseph
FarkasJoseph merged commit 5e95995 into v6 Oct 8, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant