Is there a way to download the forwarding logs as a .csv file via the command line using RTL? #1355
Replies: 5 comments
-
RTL cannot be used directly to convert CLN response into .csv without going to the UI. Steps RTL takes to create .csv: I have not used Grafana personally but ChatGPT confirms that it can directly consume json response also. In that case, you can remove RTL from the stack and directly communicate with Core Lightning via clnrest. You can also try clnrest's requests from CLN demo node here. |
Beta Was this translation helpful? Give feedback.
-
Thank you @ShahanaFarooqui for the detailed response on this very much appreciated. May I ask you what the specific RTL REST request to clrests listforwards is so I can make a bash script to do the exact same thing to create the JSON data file which I will then convert to a CSV file via the command line so I can automate my forwards data and insert it into my MySQL database directly from the command line? I want to make sure the CSV file is consistent with the one which is generated via RTL. With very best regards, Clarke |
Beta Was this translation helpful? Give feedback.
-
@clarketowson Not sure if I understood you correctly, but I am just calling simple listforwards directly. So if you check the request url in RTL, it is a simple POST listforwards REST call to get the data. Then RTL filters out all records except latest 1,000 if the forwarding status was In curl, the request should look something like:
Where you can adjust |
Beta Was this translation helpful? Give feedback.
-
Thanks @ShahanaFarooqui I have got used to working with the bitcoin-lightning-cli command as I run RTL in a docker container with BTCPay. As we know the bitcoin-lightning-cli.sh listforwards command gives JSON output like this: { But does not include the in_channel_alias and out_channel_alias. Basically i'm looking to create a bash script to give: { where $nodeAliasA and $nodeAliasB are the aliases of the nodes involved in the forwarding transactions. then I could create a CSV file from the JSON combined data like: 828836x514x1 | 11432 | 811606x1334x0 | 3135 | 80002680 | 80000880 | 1800 | settled | 1707454330 | 1707454338 | Taeping | ⚡AdicaMinibolt⚡ which then matches the same format/layout of the CSV file generated by RTL. Then I could create a bash script to call MariaDB and insert those forwarding details into a separate database I have setup which i'm using Grafana to pull the forwarding details from. I populated the separate database manually by importing the CSV file from RTL and I keep it up to date manually but using a cron script would automated this. I'm running RTL from within a docker container on a BTCPay Server. But i'm running all my scripts on the server host outside of the docker containers. Being able to add it as a simple cron job on the host would be ideal. I have been chatting with the admin of the lightningnetwork+ website and he has expressed interest in the idea of node operators on his site being able to display forwarding logs like I have. I'm still fine tuning the dashboard at the moment: Best Regards, Clarke |
Beta Was this translation helpful? Give feedback.
-
To map forwarding channel ids with their aliases, I am using already stored channels data in RTL. For script, you might want to fetch all channels first then map them with these channel ids. |
Beta Was this translation helpful? Give feedback.
-
Hi Everyone,
I have recently been doing some work with Grafana and have created a dashboard based on my nodes forwarding logs.
The CSV file that can be downloaded from RTL is very useful for this.
Is there a way to download the forwarding logs as a .csv file via the command line using RTL or if not how exactly does RTL interact with the underlying c-lightning in order to create the CSV file?
Best Regards,
Clarke
Beta Was this translation helpful? Give feedback.
All reactions