Products › lamco-dbus-tools › Docs

Read a D-Bus capture's JSON records by hand with jq

Read a D-Bus capture's JSON records by hand with jq: Each mechanism's records, from bus messages and counters to the kernel's stamps, and how to unwrap them.

Describes version 0.4.1. Every command here was run on 2026-12-01 against captures in the repository: docs/measurements/stage-13/records/ made by its run.sh, the kernel part's measurements of 2026-12-01, and a test fixture.

dbustell reads captures for you. When a question isn't one of its lenses, or a capture is to go into another tool, the JSON is the whole of it: Every record of every mechanism, with its stamps. The capture format describes each field; this page shows how to get at them with jq.

What's in a capture

Each mechanism that was asked for has an entry in dissectors, saying whether it ran and how many records it gave:

$ jq -r '.dissectors[] | [.mechanism_id, .status, .record_count] | @tsv' stats.json
bus-identity    ran 9
bus-names   ran 5
host-journal    ran 0
bus-messages    ran 22

The records themselves, counted by mechanism:

$ jq -r '[.records[].mechanism_id] | group_by(.) | map([.[0], length] | @tsv)[]' stats.json
bus-counters    3
bus-identity    9
bus-messages    22
bus-names   5
instrument  2

Turning a payload into plain JSON

A record's payload keeps each value with its type, so nothing is lost on the way through JSON: {"str": ...}, {"u32": ...}, a map as a list of pairs, a list as {"list": [...]}, and "null". One jq function unwraps it:

def plain: if type == "object" then (if has("map") then (.map | map({key: .[0], value: (.[1] | plain)}) | from_entries)
  elif has("list") then (.list | map(plain))
  else (to_entries[0].value | if type == "object" or type == "array" then plain else . end) end)
  elif . == "null" then null else . end;

It's kept as docs/measurements/stage-13/records/plain.jq. Each query below that uses plain was run as jq -L . 'include "plain"; QUERY' beside that file; it's shown without the include for clarity.

The bus and its names

bus-identity holds one record for each thing the bus said of itself:

$ jq -r '.records[] | select(.mechanism_id=="bus-identity") | .member' stats.json
bus id features interfaces stats activatable_names driver_credentials driver_process driver_version

bus-names holds the names as of the start, a record for each name and each connection. dbustell names reads them; who owns a name is its own how-to.

Messages

bus-messages is a message each, as the monitor read it:

$ jq -r '.records[] | select(.mechanism_id=="bus-messages") | .payload | plain | [.type.name, (.sender // "-"), (.member // "-")] | @tsv' stats.json | head -5
method_return   org.freedesktop.DBus    -
signal  org.freedesktop.DBus    NameLost
method_call :1.2    GetConnectionStats
method_return   org.freedesktop.DBus    -
method_call :1.2    GetConnectionStats

The bus's counters

bus-counters is a poll of the bus's statistics each --stats seconds of a recording:

$ jq -c '.records[] | select(.mechanism_id=="bus-counters") | .payload | plain | .totals | {ActiveConnections, BusNames, MatchRules}' stats.json | head -2
{"ActiveConnections":2,"BusNames":3,"MatchRules":1}
{"ActiveConnections":3,"BusNames":3,"MatchRules":2}

How the recording went

instrument holds the recorder's own connection and its monitor: What it was asked, how it ended, and its guard:

$ jq -c '.records[] | select(.mechanism_id=="instrument" and .member=="monitor") | .payload | plain | {messages_kept, ended, filtered_by, budget_bytes}' stats.json
{"messages_kept":22,"ended":"stopped","filtered_by":null,"budget_bytes":16646144}

A service's interfaces

service-interfaces, from dbussee introspect, holds an object record for each object and a walk saying what was asked:

$ jq '.records[] | select(.mechanism_id=="service-interfaces" and .member=="walk") | .payload | plain | {service, asked, objects}' introspect.json
{
  "service": "com.example.Lamp",
  "asked": 4,
  "objects": 1
}

What dbusdo did, and what a relayed program sent

driver-acts is a record for each act. For relay, it says what the bus saw:

$ jq -c '.records[] | select(.mechanism_id=="driver-acts") | .payload | plain | {exit, connections, messages_to_bus, messages_to_program}' relay.json
{"exit":0,"connections":1,"messages_to_bus":2,"messages_to_program":3}

relay-messages is each message that went through the relay, by leg:

$ jq -r '.records[] | select(.mechanism_id=="relay-messages" and .member=="message") | .payload | plain | [.leg, .type.name, (.member // "-")] | @tsv' relay.json
to_bus  method_call Hello
to_program  method_return   -
to_program  signal  NameAcquired
to_bus  method_call Get
to_program  method_return   -

The host's journal and units

host-journal is each line of the journal for the recording's span that bears on the bus, and host-units the units those lines and the started services name (here, from a test's recording):

$ jq -r '.records[] | select(.mechanism_id=="host-journal") | .payload | plain | .message' start-logged-first.json | head -2
[session uid=1000 pid=2362568 pidfd=4] Connection :1.1 (uid=1000 pid=2362570 comm="/build/ta") became a monitor.
[session uid=1000 pid=2362568 pidfd=4] Activating service name='com.example.Bypass2362556.dbus_daemon' requested by ':1.2' (uid=1000 pid=2362556 (the line cut here)
$ jq -c '.records[] | select(.mechanism_id=="host-units") | {member, name: (.payload | plain | .name)}' start-logged-first.json
{"member":"meant_for","name":"com.example.Bypass2362556.dbus_daemon"}

The kernel's stamps

kernel-sockets, from a recording with --kernel, is each message at each socket it crossed, with the kernel's clock:

$ zcat split-dbus-daemon-rec.json.gz | jq -r '.records[] | select(.mechanism_id=="kernel-sockets") | [(.stamps[] | select(.clock=="kernel_monotonic" and (.role | endswith("begun") | not)) | .role), (.payload | plain | .pid, .type, .serial, .reply_serial)] | @tsv' | head -4
sent    2252    method_call 15  0
received    2251    method_call 15  0
sent    2251    method_return   1   15
sent    2251    signal  2   0

Sandboxes and audits

sandbox-grants and sandbox-instances, from dbussee sandbox, hold what each sandboxed application may reach and each running one; the machine here has none, and the capture says so:

$ jq -r '.dissectors[] | "\(.mechanism_id): \(.detail)"' sandbox.json
sandbox-grants: 0 Flatpak applications, 0 Snap profiles, 0 Firejail profiles, read from their files.
sandbox-instances: 0 Flatpak instances, each proxy's connections found by asking the bus for each connection's process.

audit-collection, from dbussee audit collect, is one record holding the whole collection, which dbustell audit reads, here of the machine the page was written on:

$ jq -c '.records[] | select(.mechanism_id=="audit-collection") | .payload | plain | keys' audit.json
["apparmor_profiles","bus","json","policy_files","polkit_actions","root","service_files","units"]