Skip to main content

Protocol reference

The rules for writing to the socket yourself instead of using emit. The ids and fields are on Publish telemetry.

The socket​

Read the path from /etc/constellation/socket.env (default /run/constellation-agent/telemetry.sock) and connect with AF_UNIX / SOCK_STREAM. Writing needs membership of the constellation group, which takes effect when the process restarts. The API key is in a separate root-only file, which publishers cannot read.

Framing​

One record per line, ended by \n. No envelope, no length prefix, no reply.

link,ground_station_id=GS-001,ground_antenna_id=GS-001-ANT-1,satellite_id=SAT-9 elevation_deg=22.8,carrier_locked=true 1785528000000000000
PartRequiredSeparator
Measurement (link)yesNone
Tags (the ids)yes, before each key=value
Fieldsyes, at least onea space, then key=value pairs joined by ,
Timestampnoa space, then nanoseconds

An unescaped space anywhere else changes the parse.

Field types​

TypeWriteExample
Floata numberes_n0_db=12.7
Integera number with iframes_good=4820i
Booleantrue / falsecarrier_locked=true
Stringdouble-quotedtrack_mode="program"

Floats must be finite (no NaN or Inf), and integers must fit in 64 bits. 1 is a float, not a boolean, and an unquoted word is a parse error. Integers are stored as floats, so 4820i reads back as 4820.0; write the i anyway, because that's the type the platform checks.

Escaping​

WhereEscape
Tag values (contact_id)comma, space, and = with \
String field values" and \ with \

Ids and field names on the list never need escaping. A newline can't appear anywhere, escaped or not.

link,ground_station_id=GS-001,ground_antenna_id=GS-001-ANT-1,satellite_id=SAT-9,contact_id=Pass\ 7\,\ east uplink_status="said \"ok\"" 1785528000000000000

Timestamps​

Nanoseconds since the Unix epoch, 19 digits today: date +%s%N, time.time_ns(), time.Now().UnixNano(). Seconds or milliseconds read as 1970, and the platform rejects a record stamped before 2000 or more than 5 minutes ahead of its clock (implausible_timestamp). Leave the timestamp off to use the agent's arrival time, which is the safer choice when the device clock is unreliable.

Connections​

Open one connection and keep writing to it; several lines per write is fine. When the agent restarts (upgrades, systemctl restart telegraf) the connection closes: reconnect with backoff, and hold samples meanwhile if you can't lose them.

Delivery​

A completed write means the agent received the bytes. It doesn't mean the line parsed or the platform accepted it, and there's no acknowledgement on the socket. Use verify and logs (see Troubleshooting) to confirm delivery.

Example encoder​

import socket, time

IDS = ("ground_station_id", "ground_antenna_id", "satellite_id")

def encode(ids, fields, timestamp_ns=None):
if not all(ids.get(name) for name in IDS):
raise ValueError("ground_station_id, ground_antenna_id and satellite_id are required")
tags = "".join(
f",{k}=" + v.replace(",", "\\,").replace(" ", "\\ ").replace("=", "\\=") for k, v in ids.items()
)
parts = []
for key, value in fields.items():
if isinstance(value, bool): # before int: bool is an int in Python
parts.append(f"{key}={str(value).lower()}")
elif isinstance(value, int):
parts.append(f"{key}={value}i")
elif isinstance(value, float):
parts.append(f"{key}={value!r}")
else:
parts.append(f'{key}="' + str(value).replace("\\", "\\\\").replace('"', '\\"') + '"')
line = f"link{tags} {','.join(parts)} {timestamp_ns or time.time_ns()}\n"
if line.count("\n") != 1:
raise ValueError("newlines can't appear in a record")
return line

path = open("/etc/constellation/socket.env").read().split("=", 1)[1].strip()
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s:
s.connect(path)
s.sendall(encode(
{"ground_station_id": "GS-001", "ground_antenna_id": "GS-001-ANT-1", "satellite_id": "SAT-9"},
{"elevation_deg": 22.8, "carrier_locked": True, "frames_good": 4820},
).encode())