Is there a way to capture / log all the messages up/down from a device on community TTNv3?

I would like to be able to capture the full messages that appear in the “live data” window for a device along with interpretation header that is displayed in the in window for off line analysis …
(screenshots of course are possible but they dont capture all the history in the window and it doesnt include the full messages)

It looks like there is a “storage integration” that can be configured to capture the uplink messages but it doesnt look like it would include the downlink messages (and not clear if this is only for the application data or if it would include the lowlevel messaging/errors etc …)

Is there a way to capture device traffic on the community server setup ?

Yes, you can use the events API for this, see
https://www.thethingsindustries.com/docs/reference/api/events/

Example with curl:

curl https://eu1.cloud.thethings.network/api/v3/events \
    -H "Authorization: Bearer NNSXS.4AP5MAHVWHRIJCY4L3EXKVRQFPQXJ4JJ2TOFNQA.FRQSDKXMEY3ISJVXYD5FDGOGQWNHLPZ3IM7N32RHJNYPZHMJEQKA" \
    -H "Accept: text/event-stream" \
    --data '{"identifiers":[{"application_ids":{"application_id":"rak7204-bertrik"}}]}'

The ‘Authorization’ header contains an API key you generated in the console, in this case a application API key with rights ‘read application traffic’.

You will see receive basically the same info as in the device live view of the console, JSON messages wrapped in a ‘result’ wrapper, separated by a blank line, for example:

{"result":{"name":"events.stream.start","time":"2021-10-31T06:58:41.367623523Z","identifiers":[{"application_ids":{"application_id":"rak7204-bertrik"}}],"correlation_ids":["rpc:/ttn.lorawan.v3.Events/Stream:75d69191-138d-46c1-8e51-32bd608a3d71"],"origin":"ip-10-100-7-169.eu-west-1.compute.internal","unique_id":"01FKAJ99JQVD7REQYDYVQX81EF"}}

{"result":{"name":"ns.up.data.receive","time":"2021-10-31T07:00:37.825643154Z","identifiers":[{"device_ids":{"device_id":"rak7204","application_ids":{"application_id":"rak7204-bertrik"},"dev_eui":"323833355F387902","join_eui":"70B3D57ED003881B","dev_addr":"260B4205"}}],"data":{"@type":"type.googleapis.com/ttn.lorawan.v3.UplinkMessage","raw_payload":"QAVCCyaCPBIDBgiK0p7R9DE5Ttc559VAvMkbGU4s/n+nGA==","payload":{"m_hdr":{"m_type":"UNCONFIRMED_UP"},"mic":"/n+nGA==","mac_payload":{"f_hdr":{"dev_addr":"260B4205","f_ctrl":{"adr":true},"f_cnt":4668,"f_opts":"AwY="},"f_port":8,"frm_payload":"itKe0fQxOU7XOefVQLzJGxlOLA==","full_f_cnt":4668}},"settings":{"data_rate":{"lora":{"bandwidth":125000,"spreading_factor":11}},"data_rate_index":1,"coding_rate":"4/5","frequency":"868500000","timestamp":1842261132,"time":"2021-10-31T07:00:37.744802951Z"},"rx_metadata":[{"gateway_ids":{"gateway_id":"bertrik-ttig-2","eui":"58A0CBFFFE802765"},"time":"2021-10-31T07:00:37.744802951Z","timestamp":1842261132,"rssi":-41,"channel_rssi":-41,"snr":9.5,"location":{"latitude":52.02263293883559,"longitude":4.692435826556128,"source":"SOURCE_REGISTRY"},"uplink_token":"ChwKGgoOYmVydHJpay10dGlnLTISCFigy//+gCdlEIzZuu4GGgwIlf74iwYQtoPTgwMg4IXI+s6mBQ=="}],"received_at":"2021-10-31T07:00:37.816421818Z","correlation_ids":["gs:conn:01FK9W57E6X4JP11MSSRJ6ENTQ","gs:up:host:01FK9W57EGX6FKEQVBP569P8VN","gs:uplink:01FKAJCV9NJVPQBS6C0ZWCG3N9","ns:uplink:01FKAJCV9RCHM98V50MTFHCTCJ","rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01FKAJCV9RRJS7ZQPA0N6JGRRM"],"device_channel_index":2,"consumed_airtime":"0.987136s"},"correlation_ids":["gs:conn:01FK9W57E6X4JP11MSSRJ6ENTQ","gs:up:host:01FK9W57EGX6FKEQVBP569P8VN","gs:uplink:01FKAJCV9NJVPQBS6C0ZWCG3N9","ns:uplink:01FKAJCV9RCHM98V50MTFHCTCJ","rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01FKAJCV9RRJS7ZQPA0N6JGRRM"],"origin":"ip-10-100-4-61.eu-west-1.compute.internal","context":{"tenant-id":"CgN0dG4="},"visibility":{"rights":["RIGHT_APPLICATION_TRAFFIC_READ"]},"unique_id":"01FKAJCVA156Z27RR0BKCHRNXN"}}

{"result":{"name":"ns.mac.link_adr.answer.reject","time":"2021-10-31T07:00:38.019947413Z","identifiers":[{"device_ids":{"device_id":"rak7204","application_ids":{"application_id":"rak7204-bertrik"},"dev_eui":"323833355F387902","join_eui":"70B3D57ED003881B","dev_addr":"260B4205"}}],"data":{"@type":"type.googleapis.com/ttn.lorawan.v3.MACCommand.LinkADRAns","data_rate_index_ack":true,"tx_power_index_ack":true},"correlation_ids":["gs:conn:01FK9W57E6X4JP11MSSRJ6ENTQ","gs:up:host:01FK9W57EGX6FKEQVBP569P8VN","gs:uplink:01FKAJCV9NJVPQBS6C0ZWCG3N9","ns:uplink:01FKAJCV9RCHM98V50MTFHCTCJ","rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01FKAJCV9RRJS7ZQPA0N6JGRRM"],"origin":"ip-10-100-4-61.eu-west-1.compute.internal","context":{"tenant-id":"CgN0dG4="},"visibility":{"rights":["RIGHT_APPLICATION_TRAFFIC_READ"]},"unique_id":"01FKAJCVG3Y5WD4M5CHZ2K3M14"}}

etc

2 Likes