Skip to content

log-extractor: parse Bitcoin Core debug.log log messages #336

Description

@0xB10C

edit 2026-03: This issue was previously intended for using the Drain Algorithm, but I think we can do better (and it's easier) by parsing the log staements in the source code of Bitcoin Core. This is discussed further down below.


With the log-extractor @m4ycon added, we have a stream of log messages that we could use for e.g. anomaly detection. I've experimented a bit with the Drain algorithm (Drain: An Online Log Parsing Approach with Fixed Depth Tree) to parse logs and was surprised by the fairly minimal work required to parse a debug.log with 8.7M entries down to a 231 templates: https://gist.github.com/0xB10C/4e6ad297ad698aa42c08164b31500622

$ head debug.log-20260107-hal_templates.csv
EventId,EventTemplate,Occurrences
cfd83b52,received: <*> <*> bytes peer <*>,1177351
bab6597b,got inv: wtx <*> <*> peer <*>,3329366
2696937b,Requesting wtx <*> peer <*>,442336
b31d2e19,sending <*> <*> bytes peer <*>,1888676
49aa8dc6,Enqueuing TransactionAddedToMempool: txid <*> wtxid <*>,441394
c56e0b70,"AcceptToMemoryPool: peer <*> accepted <*> wtxid <*> poolsz <*> txn, <*> kB",441394
43942aab,TransactionAddedToMempool: txid <*> wtxid <*>,441394
1957b746,"socket closed, disconnecting peer <*> peeraddr <*>",9710
f0fea8d0,Resetting socket for peer <*> peeraddr <*>,11191

I've used the Python example from https://github.com/logpai/logparser for this (ty for telling me about this @jharveyb!). With more pre-processing (masking hashes such as block header hashes + txids + wtxids, peer ids, IP addresses, .onion and .i2p addresses, ...) I think we can get to a good starting point for having good Bitcoin Core debug.log templates to work with in anomaly detection.

It probably makes sense to experiment with https://github.com/logpai/Drain3 as it supports persistence (of the tree) and streaming logs into it. A good starting point is probably https://github.com/logpai/Drain3/blob/master/examples/drain_bigfile_demo.py

Then, a next step could be to implement Drain in e.g. Rust (or use https://github.com/haydenflinner/drainrs / https://github.com/benwtrent/drain-rs) and tune it for usage with Bitcoin Core debug.logs. Also, implementing Bitcoin Core specific pre-processing logic should be helpful for good results.

Very basic anomaly detection could be done by looking at the number of occurrences of templates per timeframe (e.g. 10min/hour). Large standard deviations could indicate anomalies. Additionally, log messages that only rarely occur are probably interesting to look at. This is something that could be implemented in e.g. a metrics-tool like Prometheus exporter.

From there on, exploring e.g. techniques and tools from https://github.com/logpai/loglizer could be considered.


Sample logs that can be used for this: https://demo.peer.observer/debug-logs/

Activity

  1. added theissue type on Jan 10, 2026
  2. 0xB10C commented on Jan 10, 2026

    @0xB10C
    CollaboratorAuthor

    An obvious alternative could be to implement (optional) structured logging for Bitcoin Core. This would allow skipping the whole parsing part. I think this could be a worthwhile project, but out-of-scope for this issue.

  3. 0xB10C commented on Jan 10, 2026

    @0xB10C
    CollaboratorAuthor

    I found this Literature Review on Log Anomaly Detection Approaches Utilizing Online Parsing Methodology talk interesting too. Specially this table:

    Image

    SwissLog and NuLog might be alternatives to Drain.

    However, there seems to be a lot more literature on this. Could even be a topic for a thesis?

  4. 0xB10C commented on Jan 10, 2026

    @0xB10C
    CollaboratorAuthor

    I have historical logs that I'd be a) happy to provide for development and benchmarking of something like this and b) would want to run through this to look for rare messages and anomalies: https://bnoc.xyz/t/offer-detailed-bitcoin-core-node-debug-logs-2024/36/2

  5. added
    help wanted
    ₿OSS-project
    on Jan 10, 2026
  6. edilmedeiros commented on Jan 12, 2026

    @edilmedeiros
    Contributor

    Also, implementing Bitcoin Core specific pre-processing logic should be helpful for good results.

    Curious what I thought about this that touches the Core codebase.

  7. 0xB10C commented on Jan 13, 2026

    @0xB10C
    CollaboratorAuthor

    Also, implementing Bitcoin Core specific pre-processing logic should be helpful for good results.

    Curious what I thought about this that touches the Core codebase.

    I'm not 100% sure I understand your question. From my quick-and-dirty experiments I found the following preprocessing helpful:

    • replace("=", "= ") (often used in e.g. peer=id)
    • replace("(", "( ")
    • replace(")", " )")
    • replace IP addresses with an IP address marker (e.g. {IP}) using a regex
    • replace [...].onion with an Onion marker
    • replace [...].b32.i2p with an I2P marker
    • replace wtxid=[a-f0-9]{64} and txid=[a-f0-9]{64} with markers
    • ...
  8. 0xB10C commented on Jan 13, 2026

    @0xB10C
    CollaboratorAuthor

    Another approach I tried to generate templates was to use libclang to generate the compilation AST from the source code of Bitcoin Core and then piece together the log statements. This might work, but I think I found an even simpler solution:

    Use clang to get the source code as individual tokens and piece these together into the log statements. The following is a quick-and-dirty implementation of this.

    from clang.cindex import Index
    
    index = Index.create()
    tu = index.parse("bitcoin/src/net_processing.cpp")
    
    def logstatement_to_dict(statements):
        d = {}
        d["type"] = statements[0]
    
        i = 1
        if statements[i].startswith("BCLog::"):
            d["category"] = statements[i].replace("BCLog::", "")
            i+=1
        else:
            d["category"] = None
    
        d["fmt"] = statements[i][1:-1]
        i+=1
        d["args"] = statements[i:]
        return d
    
    foundLog = False
    skipNextOpeningParentheses = False
    statement = []
    part = [];
    
    for token in tu.get_tokens(extent=tu.cursor.extent):
        tk = token.spelling
    
        if tk == "LogDebug" or tk == "LogInfo" or tk == "LogWarning" or tk == "LogError":
            # append the "Log*" statement
            statement.append(tk);
            foundLog = True
            skipNextOpeningParentheses = True
            continue
    
        if foundLog:
            match tk:
                case ",":
                    statement.append("".join(part).replace("\\n", ""));
                    part = []
                case "(":
                    if skipNextOpeningParentheses:
                        skipNextOpeningParentheses = False
                        continue
                    part.append(tk)
                case ";":
                    foundLog = False
                    part.append(tk)
                    # Since this is the last part, remove the trailing ");" from it
                    part_str = "".join(part);
                    part_str = part_str.replace(");", "")
                    statement.append(part_str);
                    part = []
                    if len(statement) > 0:
                        print(logstatement_to_dict(statement))
                    statement = []
                case _:
                    part.append(tk)

    For net_processing.cpp, it produces the following output:

    {'type': 'LogDebug', 'category': 'NET', 'fmt': "Not downloading blocks from peer=%d, which doesn't have the snapshot block in its best chain.", 'args': ['peer.m_id']}
    {'type': 'LogDebug', 'category': 'NET', 'fmt': 'send version message: version %d, blocks=%d, them=%s, txrelay=%d, peer=%d', 'args': ['PROTOCOL_VERSION', 'nNodeStartingHeight', 'addr_you.ToStringAddrPort()', 'tx_relay', 'nodeid']}
    {'type': 'LogDebug', 'category': 'NET', 'fmt': 'send version message: version %d, blocks=%d, txrelay=%d, peer=%d', 'args': ['PROTOCOL_VERSION', 'nNodeStartingHeight', 'tx_relay', 'nodeid']}
    {'type': 'LogDebug', 'category': 'NET', 'fmt': 'Cleared nodestate for peer=%d', 'args': ['nodeid']}
    {'type': 'LogDebug', 'category': 'NET', 'fmt': 'Misbehaving: peer=%d%s', 'args': ['peer.m_id', 'message_prefixed']}
    {'type': 'LogDebug', 'category': 'NET', 'fmt': 'peer=%d: %s', 'args': ['nodeid', 'message']}
    {'type': 'LogDebug', 'category': 'NET', 'fmt': 'Requesting block %s from peer=%d', 'args': ['hash.ToString()', 'peer_id']}
    {'type': 'LogDebug', 'category': 'NET', 'fmt': 'Decreased stalling timeout to %d seconds', 'args': ['count_seconds(new_timeout)']}
    {'type': 'LogDebug', 'category': 'NET', 'fmt': '%s sending header-and-ids %s to peer=%d', 'args': ['"PeerManager::NewPoWValidBlock"', 'hashBlock.ToString()', 'pnode->GetId()']}
    {'type': 'LogDebug', 'category': 'NET', 'fmt': 'failed to activate chain (%s)', 'args': ['state.ToString()']}
    {'type': 'LogDebug', 'category': 'NET', 'fmt': "%s: ignoring request from peer=%i for old block that isn't in the main chain", 'args': ['__func__', 'pfrom.GetId()']}
    {'type': 'LogDebug', 'category': 'NET', 'fmt': 'historical block serving limit reached, %s', 'args': ['pfrom.DisconnectMsg(fLogIPs)']}
    {'type': 'LogDebug', 'category': 'NET', 'fmt': 'Ignore block request below NODE_NETWORK_LIMITED threshold, %s', 'args': ['pfrom.DisconnectMsg(fLogIPs)']}
    {'type': 'LogDebug', 'category': 'NET', 'fmt': 'Block was pruned before it could be read, %s', 'args': ['pfrom.DisconnectMsg(fLogIPs)']}
    {'type': 'LogError', 'category': None, 'fmt': 'Cannot load block from disk, %s', 'args': ['pfrom.DisconnectMsg(fLogIPs)']}
    {'type': 'LogDebug', 'category': 'NET', 'fmt': 'Block was pruned before it could be read, %s', 'args': ['pfrom.DisconnectMsg(fLogIPs)']}
    {'type': 'LogError', 'category': None, 'fmt': 'Cannot load block from disk, %s', 'args': ['pfrom.DisconnectMsg(fLogIPs)']}
    {'type': 'LogDebug', 'category': 'CMPCTBLOCK', 'fmt': 'Peer %d sent us a GETBLOCKTXN for block %s, sending a BLOCKTXN with %u txns. (%u bytes)', 'args': ['pfrom.GetId()', 'block.GetHash().ToString()', 'resp.txn.size()', 'tx_requested_size']}
    {'type': 'LogDebug', 'category': 'NET', 'fmt': 'received header %s: missing prev block %s, sending getheaders (%d) to end (peer=%d)', 'args': ['headers[0].GetHash().ToString()', 'headers[0].hashPrevBlock.ToString()', 'best_header->nHeight', 'pfrom.GetId()']}
    ...
    

    By replacing the %d, %s, ... with (regex) wildcards, I think we can probably match a log line to log statements quite well and even extract the argument names and values from it.

    These will probably change across different versions, but most of the log statements should be good for two or three major versions?

  9. jharveyb commented on Jan 16, 2026

    @jharveyb

    Awesome results so far! I'm happy these tools are proving useful.

    * NuLog
      
      * paper [NuLog: Self-Supervised Log Parsing](https://arxiv.org/abs/2003.07905)
      * code [NuLog](https://github.com/nulog/nulog)
    

    This one looks cool compared to SwissLog, AFAIU we wouldn't need to manually train a dictionary first. Though I suppose building one from old logs would be fine.

    It seems like there was a follow-up paper to the Lit. Review you posted:

    https://ieeexplore.ieee.org/abstract/document/10496061

    Which has another useful comparison table of different implementations and techniques.

    I'm not 100% sure I understand your question. From my quick-and-dirty experiments I found the following preprocessing helpful:
    replace [...].onion with an Onion marker
    replace [...].b32.i2p with an I2P marker

    I would think that we actually want to retain the full addresses here, but also add a marker? Maybe IPV4 and IPV6 for those address, as the onion and I2P connection strings already have a suffix.

    But keeping the addresses may help detect a peer behaving anomalously.

    For net_processing.cpp, it produces the following output:

    By replacing the %d, %s, ... with (regex) wildcards, I think we can probably match a log line to log statements quite well and even extract the argument names and values from it.

    This is sick! Seems helpful for adding richer info, and also quite portable to other projects if needed.

    I'll keep looking around for other anomaly detection tools.

  10. davidgumberg commented on Jan 31, 2026

    @davidgumberg

    I also want good tools for handling debug logs less in the interest of anomaly detection / monitoring and more in the interest of extracting data from logs, I agree on structured logging in Bitcoin Core as the ideal solution to this, but meanwhile:

    https://github.com/davidgumberg/leave.logalone

    Here is an example of this script's output taken from current master at bitcoin/bitcoin:

    https://gist.github.com/davidgumberg/ccdf804c536acaddaccfde0135e61a12

    {
    "fmt": "Not connected to Tor control port %s, retrying in %.2f s\\n",
    "regex": "Not connected to Tor control port (\\S+), retrying in %\\.2f s\\\\n",
    "regex_types": [
      "str"
    ],
    "args": [
      "m_tor_control_center",
      "reconnect_timeout"
    ],
    "file": "src/torcontrol.cpp",
    "line": 643,
    "column": 5,
    "macro": "LogDebug",
    "category": "BCLog::TOR"
    },

    I took a stab at it and came to the same conclusion as @0xB10C above, that using libclang to navigate the AST is not worth it, there just isn't enough functionality exposed in libclang to make this approach viable in a way that isn't awful. But, libclang kindly provides a tokenizer that can be used for this purpose. I "use" the AST, but not really, as I basically just look for macros named Log.* and then manually parse the tokens, I'll drop the AST stuff soon in exchange for token searching as in above: #336 (comment)

    As-is this script works pretty well, but WalletLogPrintf() and any other non-macro use of log functions won't work well for now, on account of the AST woes, but this can be fixed with token parsing, which I'll change my script to at some point and special handling will be needed for the LOG_TIME_MICROS.* / BCLog::Timer RAII style logs, but that's the case for any approach, and shouldn't be too bad to deal with.

    Some other nice-to-haves I'm thinking for this tool/library would be:

    • Easy for a user to specify a log message they are interested in. Not ideal, but maybe via regex (LOL). But: this regex will just have to be a partial match and unique to one fmt str, not have all the match patterns etc. e.g. you do something like:

      # fmt_str = "Requesting block %s from peer=%d\n",
      block_rq_pattern = LogPatterns.from_regex("Requesting block.*from")
      block_rq_msgs = block_rq_pattern.match(file)
    • The user can access the variable values by index

      for msg in block_rq_msgs:
          print(f"blockhash={msg[0]}")
    • The user should be able to access the matches as dict entries:

      for msg in block_rq_msgs:
          print(f"blockhash={msg["blockhash"]}")
      • Easy if the argument is a named variable:

        # LogDebug(BCLog::PRIVBROADCAST, "Ignoring unnecessary request to schedule an already scheduled transaction: %s", txstr);
        already_scheduled_tx_msgs = already_scheduled_tx_pattern.match(file)
        for msg in already_scheduled_tx_msgs:
            print(f"txstr:{txstr}")
      • Hard if the argument is an expression!

        LogInfo("Using data directory %s", fs::PathToString(gArgs.GetDataDirNet()));
      • Can be mixed for messages that have both named args and expressions,
        access the named args by keys (and index) and access all the expression
        args by index only.

      • Maybe? User can specify custom dict keys for the matches, e.g.:

        # fmt_str = "Requesting block %s from peer=%d\mn",
        block_rq_pattern = LogPatterns.from_regex("Requesting block.*from")
        block_rq_pattern.set_keys("blockhash", "peerid")
        
        block_rq_msgs = block_rq_pattern.match(file)
        for msg in block_rq_msgs:
            print(msg["blockhash"])
        • Maybe the user has a table of these that they load?
      • Maybe? Can use a tiny LLM to generate keynames? Something like
        qwen2.5coder-0.5b would do a good job inventing a name and can run on
        pretty minimal hardware, but how would the user discover the variable
        name? In that case couldn't they just as well have picked their own names?

    • You should be able to build and use log message db's for multiple versions, it
      would be trivial to read the startup log message and generate / select a log
      message index based on the commit hash / version name.

    • pandas?

  11. 0xB10C commented on Mar 11, 2026

    @0xB10C
    CollaboratorAuthor

    Noting down what I think are next steps here. I think its is a bit of a bigger effort and there's a lot still to figure out.

    1. extract possible log statement templates (and their arguments) from Bitcoin Core source code into e.g a JSON file. Both log-extractor: parse Bitcoin Core debug.log log messages #336 (comment) and log-extractor: parse Bitcoin Core debug.log log messages #336 (comment) show python examples of this. Maybe it's possible in Rust tool too? This could be a standalone tool or part of peer-observer.
    2. have a way of loading this JSON file in the log-extractor on start-up. The log-extractor should then try to match "log statement templates" to log lines received from a live log. Then, create (see below) an event and publish it into NATS.
    3. Based on these events, count e.g. the number of occurences/rate of this "log statement template" in e.g. the metrics tool.

    Here's a rough schema and example what I think an event could look like. Here, as a JSON object, but this would be a protobuf message for the other peer-observer tools to consume.

    {
      "log": "Requesting block 000000000000000000011a0fedc5c137037e3a4b3716316ba14237e40446e2d8 from peer=1337"
      "statement": "Requesting block %s from peer=%d",
      "args": {
        "hash.ToString()": "000000000000000000011a0fedc5c137037e3a4b3716316ba14237e40446e2d8",
        "peer_id": 1337,
      }, 
    }
  12. changed the title [-]log-extractor: parse Bitcoin Core debug.log log messages with `Drain` and detect anomalies[/-] [+]log-extractor: parse Bitcoin Core debug.log log messages[/+] on Mar 11, 2026
  13. 0xB10C commented on Mar 11, 2026

    @0xB10C
    CollaboratorAuthor

    (also removed the Drain part from the title. I think Drain is a valid approach, but probably easier to go with the source-code parsing approach first)

  14. 0xB10C commented on May 25, 2026

    @0xB10C
    CollaboratorAuthor

    An obvious alternative could be to implement (optional) structured logging for Bitcoin Core. This would allow skipping the whole parsing part. I think this could be a worthwhile project, but out-of-scope for this issue.

    There's some discussion about how structured logging could look like in Bitcoin Core: bitcoin/bitcoin#35369

  15. davidgumberg commented on Jun 2, 2026

    @davidgumberg

    Just wanted to share an update on the tool I've been working on https://radicle.network/nodes/iris.radicle.network/rad%3Az37pH1UAxFvazXnfAMS5qbcUjQaP6

    I have implemented approximately something pulled from the interfaces I described above, I'm using a callback here because the use case I am building for needs stateful parsing, but there maybe is a better interface for those that don't need state, here is what an example application looks like:

    import sys
    
    from pathlib import Path
    from leave.logalone import isolate
    from leave.metadata import LogEntry
    from leave.db import (
        CreateLogDBForHash
    )
    
    
    REPO = Path.home() / "btc" / "bitcoin"
    
    
    class CBHandler:
        def __init__(self):
            self.total_transaction_rq_count = 0
    
        def gbt_callback(self, _: LogEntry, dict: dict) -> None:
            self.total_transaction_rq_count += int(dict["txn_count"])
    
    
    if __name__ == "__main__":
        if len(sys.argv) != 3:
            print("Usage!!!! [script.py] {debug.log} {commit-hash}")
            sys.exit(-1)
    
        handler = CBHandler()
        # todo, the db should really be an index of db's generating itself based on the logfile, but hmm sometimes commit is unknown in the startup version message...
        db = CreateLogDBForHash(REPO, sys.argv[2])
    
        # Should it be fuzzy or there be a fuzzy option instead of regex?
        gbt_pattern = db.msg_with_args(
            "Peer.*sent us a GETBLOCKTXN",
            [
                "peerid", "blockhash", "txn_count", "txn_size"
            ],
            handler.gbt_callback
        )
        isolate(Path(sys.argv[1]), [gbt_pattern])
    
        print(f"... drumroll please... {handler.total_transaction_rq_count}")

    I don't know if this suits your needs @0xB10C as it is not in rust, but soliciting feedback on if this is in the right direction for an interface.

  16. 0xB10C commented on Jun 8, 2026

    @0xB10C
    CollaboratorAuthor

    I've been experimenting with a Drain-like implementation using a debug.log specific tokenizer a bit. A WIP tool can be found in https://github.com/peer-observer/debug-log-tool

    Basically, running a debug.log through it gives an output similar to the following:

    $ cargo run --release templates debug.log 
    
    === addrman ===
      1895 Added <INT> addresses ( of <INT> ) from <*> : <INT> tried , <INT> new
      1438 Removed <IPv4:PORT> from new [ <INT> ] [ <INT> ]
      1243 Added <IPv4:PORT> mapped to <*> to new [ <INT> ] [ <INT> ]
       566 Added <IPv6:PORT> mapped to <*> to new [ <INT> ] [ <INT> ]
       490 Selected <IPv4:PORT> from <*>
       389 Selected <IPv6:PORT> from new
       275 Removed <IPv6:PORT> from new [ <INT> ] [ <INT> ]
       236 Selected <ONION:PORT> from <*>
       227 Removed <ONION:PORT> from new [ <INT> ] [ <INT> ]
       164 Added <ONION:PORT> to new [ <INT> ] [ <INT> ]
       163 Collision with <*> while attempting to move <*> to tried table. Collisions = <INT>
        50 Selected <I2P:PORT> from <*>
        42 Removed <I2P:PORT> from new [ <INT> ] [ <INT> ]
        22 Moved <ONION:PORT> to tried [ <INT> ] [ <INT> ]
        15 Replacing <ONION:PORT> with <*> in tried table
        15 Moved <ONION:PORT> from tried [ <INT> ] [ <INT> ] to new [ <INT> ] [ <INT> ] to make space
        14 Added <I2P:PORT> to new [ <INT> ] [ <INT> ]
        11 Replacing <IPv4:PORT> with <*> in tried table
        11 Moved <IPv4:PORT> from tried [ <INT> ] [ <INT> ] to new [ <INT> ] [ <INT> ] to make space
         8 Moved <IPv4:PORT> mapped to <*> to tried [ <INT> ] [ <INT> ]
         6 GetAddr returned <INT> random addresses
         5 Moved <I2P:PORT> to tried [ <INT> ] [ <INT> ]
         3 Added <IPv6:PORT> to new [ <INT> ] [ <INT> ]
    
    === bench ===
       450 - Connect <*> : <DUR> [ <DUR> ( <DUR> / blk ) ]
       150 - Using cached block
       150 - Load block from disk : <DUR>
       150 - Sanity checks : <DUR> [ <DUR> ( <DUR> / blk ) ]
       150 - Fork checks : <DUR> [ <DUR> ( <DUR> / blk ) ]
       150 - Connect <INT> transactions : <DUR> ( <DUR> / tx , <DUR> / txin ) [ <DUR> ( <DUR> / blk ) ]
       150 - Verify <INT> txins : <DUR> ( <DUR> / txin ) [ <DUR> ( <DUR> / blk ) ]
       150 - Write undo data : <DUR> [ <DUR> ( <DUR> / blk ) ]
       150 - Index writing : <DUR> [ <DUR> ( <DUR> / blk ) ]
       150 - Flush : <DUR> [ <DUR> ( <DUR> / blk ) ]
       150 - Writing chainstate : <DUR> [ <DUR> ( <DUR> / blk ) ]
        51 FlushStateToDisk : find files to prune started
        51 FlushStateToDisk : find files to prune completed ( <DUR> )
        24 FlushStateToDisk : write block and undo data to disk started
        24 FlushStateToDisk : write block and undo data to disk completed ( <DUR> )
        24 FlushStateToDisk : write block index to disk started
        24 FlushStateToDisk : write block index to disk completed ( <DUR> )
        24 BatchWrite : write coins cache to disk ( <INT> out of <INT> cached coins ) started
        24 BatchWrite : write coins cache to disk ( <INT> out of <INT> cached coins ) completed ( <DUR> )
         2 FlushStateToDisk : unlink pruned files started
         2 FlushStateToDisk : unlink pruned files completed ( <DUR> )
    
    === cmpctblock ===
       192 Initializing PartiallyDownloadedBlock for block <HASH> using a cmpctblock of <BYTES>
       192 Initialized PartiallyDownloadedBlock for block <HASH> using a cmpctblock of <BYTES>
       150 Successfully reconstructed block <HASH> with <INT> txn prefilled , <INT> txn from mempool ( incl at least <INT> from extra pool ) and <INT> txn ( <BYTES> ) requested
       125 Reconstructed block <HASH> required tx <HASH>
        79 Peer <INT> sent us a GETBLOCKTXN for block <HASH> , sending a BLOCKTXN with <INT> txns. ( <BYTES> )
    
    === i2p ===
         7 Error connecting to <I2P:PORT> : "STREAM STATUS RESULT = CANT_REACH_PEER MESSAGE = "LeaseSet not found""
         2 Error connecting to <I2P:PORT> : Unexpected reply to "NAMING LOOKUP NAME = <*> : "NAMING REPLY RESULT = INVALID_KEY NAME = <*>
    
    === mempool ===
    596112 AcceptToMemoryPool : <PEER> : accepted <HASH> ( wtxid = <HASH> ) ( poolsz <INT> txn , <INT> kB )
      9680 replacing mempool tx <HASH> ( wtxid = <HASH> , fees = <INT> , vsize = <INT> ) . New tx <HASH> ( wtxid = <HASH> , fees = <INT> , vsize = <INT> )
      8775 replaced <INT> mempool transactions with <INT> new transaction for <INT> additional fees , <INT> delta bytes
        33 Expired <INT> transactions from the memory pool
         2 Mempool in non-optimal ordering after block.
         1 replacing mempool tx <HASH> ( wtxid = <HASH> , fees = <INT> , vsize = <INT> ) . New package <HASH> with <INT> txs , fees = <INT> , vsize = <INT>
         1 replaced <INT> mempool transactions with <INT> new one ( s ) for <INT> additional fees , <INT> delta bytes
    
    === mempoolrej ===
     18496 <HASH> ( wtxid = <HASH> ) from <PEER> was not accepted : <*>
       232 <HASH> ( wtxid = <HASH> ) from <PEER> was not accepted : insufficient fee , rejecting replacement <HASH> , less fees than conflicting txs; <FLOAT> < <FLOAT>
        90 <HASH> ( wtxid = <HASH> ) from <PEER> was not accepted : replacement-failed , insufficient feerate : does not improve feerate diagram
        73 <HASH> ( wtxid = <HASH> ) from <PEER> was not accepted : insufficient fee , rejecting replacement <HASH> , not enough additional fees to relay; <FLOAT> < <FLOAT>
        19 <HASH> ( wtxid = <HASH> ) from <PEER> was not accepted : min relay fee not met , <INT> < <INT>
    
    === msghand ===
       150 UpdateTip : new best = <HASH> <HEIGHT> version = <HEX> log2_work = <FLOAT> tx = <INT> date = ' <*> ' progress = <FLOAT> cache = <*> ( <*> )
        95 Saw new cmpctblock header hash = <HASH> <HEIGHT> <PEER> peeraddr = <IPv4:PORT>
        90 New block-relay-only peer connected : transport : <*> , version : <INT> , blocks = <INT> <PEER> peeraddr = <*>
        55 Saw new header hash = <HASH> <HEIGHT> <PEER> peeraddr = <*>
        47 New block-relay-only peer connected : transport : <*> , version : <INT> , blocks = <INT> <PEER> peeraddr = <IPv4:PORT> , mapped_as = <INT>
         8 New outbound-full-relay peer connected : transport : v2 , version : <INT> , blocks = <INT> <PEER> peeraddr = <*>
         3 New outbound-full-relay peer connected : transport : <*> , version : <INT> , blocks = <INT> <PEER> peeraddr = <IPv4:PORT> , mapped_as = <INT>
    
    === net ===
    10966474 got inv : <*> <HASH> <*> <PEER>
    2519883 received : <*> ( <BYTES> ) <PEER>
    1982604 sending tx ( <BYTES> ) <PEER>
    1427244 sending inv ( <BYTES> ) <PEER>
    591113 Requesting wtx <HASH> <PEER>
    324675 received getdata ( <INT> invsz ) <PEER>
    324675 received getdata for : <*> <HASH> <PEER>
    228218 sending getdata ( <BYTES> ) <PEER>
     93714 sending addrv2 ( <BYTES> ) <PEER>
     85547 sending pong ( <BYTES> ) <PEER>
     75860 Received addr : <INT> addresses ( <INT> processed , <INT> rate-limited ) from <PEER>
     75067 sending ping ( <BYTES> ) <PEER>
     31312 sending addr ( <BYTES> ) <PEER>
     20409 sending headers ( <BYTES> ) <PEER>
     17644 Requesting tx <HASH> <PEER>
     14582 getheaders <INT> to <*> from <PEER>
     13888 Added connection to <*> <PEER>
     13845 Cleared nodestate for <PEER>
     13575 sending version ( <BYTES> ) <PEER>
     13515 sending verack ( <BYTES> ) <PEER>
     13410 connection from <*> accepted
     12385 sending wtxidrelay ( <BYTES> ) <PEER>
     12385 sending sendaddrv2 ( <BYTES> ) <PEER>
     10890 sending sendcmpct ( <BYTES> ) <PEER>
     10734 sending feefilter ( <BYTES> ) <PEER>
     10651 sending getheaders ( <BYTES> ) <PEER>
     10507 initial getheaders ( <INT> ) to <PEER> ( <*> )
      8063 send version message : version = <INT> , blocks = <INT> , them = [ <IPv6> ] <*> , txrelay = <INT> , <PEER>
      7884 pcp : Timeout
      7197 Resetting socket for <PEER> peeraddr = <*>
      6648 Resetting socket for <PEER> peeraddr = [ <IPv6> ] <*>
      6549 SendMessages : sending inv <PEER> hash = <HASH>
      6149 sending notfound ( <BYTES> ) <PEER>
      5834 socket closed , disconnecting <PEER> peeraddr = <*>
      5827 SendMessages : sending header <HASH> to <PEER>
      5512 send version message : version = <INT> , blocks = <INT> , them = <IPv4:PORT> , txrelay = <INT> , <PEER>
      5354 New inbound peer connected : transport : <*> , version : <INT> , blocks = <INT> <PEER> peeraddr = [ <IPv6> ] <*> , mapped_as = <INT>
      5256 pcp : Retrying ( <INT> )
      4751 New inbound peer connected : transport : <*> , version : <INT> , blocks = <INT> <PEER> peeraddr = <IPv4:PORT> , mapped_as = <INT>
      4527 socket closed , disconnecting <PEER> peeraddr = [ <IPv6> ] <*>
      3003 receive version message : <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> , txrelay = <INT> , <PEER> peeraddr = <IPv4:PORT> , mapped_as = <INT>
      2807 receive version message : / <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> , <*> = <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> = <*>
      2650 receive version message : <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> , mapped_as = <INT>
      2628 pcp : Requesting port mapping for addr <*> port <INT> from gateway <*>
      2628 pcp : Internal address after connect : <*>
      2628 pcp : Giving up after <INT> tries
      2183 Advertising address <*> to <PEER>
      1596 receive version message : / <*> / : version <INT> , blocks = <INT> , us = <IPv4:PORT> , txrelay = <INT> , <PEER> peeraddr = [ <IPv6> ] <*> , mapped_as = <INT>
      1196 sending sendheaders ( <BYTES> ) <PEER>
      1107 trying v2 connection ( <*> ) to <*> , lastseen = <*>
       977 receive version message : / <*> / : version <INT> , blocks = <INT> , us = [ <IPv6> ] <*> , txrelay = <INT> , <PEER> peeraddr = <*>
       917 socket recv error , disconnecting <PEER> peeraddr = [ <IPv6> ] <*> : Connection reset by peer ( <INT> )
       890 selected inbound connection for eviction , disconnecting <PEER> peeraddr = [ <IPv6> ] <*>
       789 Ignoring repeated "getaddr". <PEER>
       763 New inbound peer connected : transport : <*> , version : <INT> , blocks = <INT> <PEER> peeraddr = <*>
       701 Making feeler connection to <*>
       684 connection attempt to <*> timed out
       562 receive version message : / <*> / <*> / : version <INT> , blocks = <INT> , us = <IPv4:PORT> , txrelay = <INT> , <PEER> peeraddr = [ <IPv6> ] <*> , mapped_as = <INT>
       524 portmap : gateway [ <*> ] : <*>
       508 receive version message : / <*> <*> <*> / : version <INT> , blocks = <INT> , us = <IPv4:PORT> , txrelay = <INT> , <PEER> peeraddr = <IPv4:PORT> , mapped_as = <INT>
       472 received : feefilter of <FLOAT> BTC / kvB from <PEER>
       415 Added time offset <DUR> , total samples <INT>
       353 start sending v2 handshake to <PEER>
       350 SOCKS5 connecting <ONION>
       326 selected inbound connection for eviction , disconnecting <PEER> peeraddr = <IPv4:PORT>
       323 receive version message : / <*> <*> <*> <*> <*> / : version <INT> , blocks = <INT> , us = <IPv4:PORT> , txrelay = <INT> , <PEER> peeraddr = <IPv4:PORT> , mapped_as = <INT>
       300 Making network specific connection to <*> on <*>
       277 sending getaddr ( <BYTES> ) <PEER>
       266 feeler connection completed , disconnecting <PEER> peeraddr = <*>
       254 SOCKS5 connected <ONION>
       252 trying v1 connection ( <*> ) to <*> , lastseen = <*>
       238 receive version message : / <*> <*> <*> <*> <*> / : version <INT> , blocks = <INT> , us = [ <IPv6> ] :0 , txrelay = <INT> , <PEER> peeraddr = <*>
       231 socket recv error , disconnecting <PEER> peeraddr = <IPv4:PORT> : <*> <*> <*> <*> ( <INT> )
       220 timeout of inflight <*> <HASH> from <PEER>
       212 receive version message : / <*> / <*> / : version <INT> , blocks = <INT> , us = [ <IPv6> ] :0 , txrelay = <INT> , <PEER> peeraddr = <*>
       188 receive version message : / Bitcoin <*> ( EB8.0 ) / : version <INT> , blocks = <INT> , us = <IPv4:PORT> , txrelay = <INT> , <PEER> peeraddr = [ <IPv6> ] <*> , mapped_as = <INT>
       183 version handshake timeout , disconnecting <PEER> peeraddr = [ <IPv6> ] <*>
       178 receive version message : / <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> , mapped_as = <INT>
       161 sending cmpctblock ( <BYTES> ) <PEER>
       148 version handshake timeout , disconnecting <PEER> peeraddr = <*>
       141 PeerManager::NewPoWValidBlock sending header-and-ids <HASH> to <PEER>
       128 sending alert ( <BYTES> ) <PEER>
       124 sending getblocktxn ( <BYTES> ) <PEER>
       123 wtxidrelay received after verack , disconnecting <PEER> peeraddr = [ <IPv6> ] <*>
       119 disconnecting extra block-relay-only <PEER> ( last block received at time <INT> )
        99 receive version message : / <*> <*> <*> <*> <*> <*> / : version <INT> , blocks = <INT> , us = <IPv4:PORT> , txrelay = <INT> , <PEER> peeraddr = <IPv4:PORT> , mapped_as = <INT>
        96 Flushed <INT> addresses to peers.dat <DUR>
        94 more getheaders ( from <HASH> ) to <PEER>
        82 Socks5 ( ) connect to <ONION:PORT> failed : <*> <*>
        79 sending blocktxn ( <BYTES> ) <PEER>
        79 wtxidrelay received after verack , disconnecting <PEER> peeraddr = <IPv4:PORT>
        63 keeping block-relay-only <PEER> chosen for eviction ( connect time : <INT> , blocks_in_flight : <INT> )
        57 sending block ( <BYTES> ) <PEER>
        55 Requesting block <HASH> from <PEER>
        48 receive version message : / btcwire:0.5.0 / Scout:0.0.7 ( solin.thetia.i2pfwd-slshnode-explorer ) / : version <INT> , blocks = <INT> , us = <IPv4:PORT> , txrelay = <INT> , <PEER> peeraddr = <I2P:PORT>
        48 sendaddrv2 received after verack , disconnecting <PEER> peeraddr = <IPv4:PORT>
        47 connect ( ) to <IPv4:PORT> failed after wait : Connection refused ( <INT> )
        43 retrying with v1 transport protocol for <PEER>
        41 receive version message : <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> <*> , txrelay = <INT> , <PEER> peeraddr = <*>
        41 sending getheaders to outbound <PEER> to verify chain work ( current best known <*> , benchmark blockhash : <HASH> )
        36 Peer <INT> sent us block transactions for block we weren ' t expecting
        27 connect ( ) to <IPv4:PORT> failed after wait : No route to host ( <INT> )
        27 socket recv error , disconnecting <PEER> peeraddr = <IPv4:PORT> : Connection timed out ( <INT> )
        26 ignoring redundant verack message from <PEER>
        26 socket send error , disconnecting <PEER> peeraddr = <IPv4:PORT> : <*> <*> <*> ( <INT> )
        24 receive version message : <*> : version <INT> , blocks = <INT> , us = <IPv4:PORT> , txrelay = <INT> , <PEER> peeraddr = <IPv4:PORT> , mapped_as = <INT>
        22 socket no message in first <INT> seconds , never received from peer , never sent to peer , disconnecting <PEER> peeraddr = <*>
        20 receive version message : / <*> / <*> / <*> / : version <INT> , blocks = <INT> , us = [ <IPv6> ] :8333 , txrelay = <INT> , <PEER> peeraddr = [ <IPv6> ] <*> , mapped_as = <INT>
        20 pong <PEER> : <*> <*> , <*> expected , <*> received , <BYTES>
        19 receive version message : / <*> ( <*> ) / : version <INT> , blocks = <INT> , us = [ <IPv6> ] :0 , txrelay = <INT> , <PEER> peeraddr = <*>
        18 Ignore block request below NODE_NETWORK_LIMITED threshold , disconnecting <PEER> peeraddr = <IPv4:PORT>
        18 connect ( ) to <IPv6:PORT> failed : Network is unreachable ( <INT> )
        18 ProcessMessages ( tx , <BYTES> ) : Exception ' <*> ( ) : <*> <*> <*> : iostream error ' ( NSt8ios_base7failureB5cxx11E ) caught
        13 socket no message in first <INT> seconds , never received from peer , disconnecting <PEER> peeraddr = <*>
        12 Misbehaving : <PEER> : header with invalid proof of work
        12 Disconnecting and discouraging peer <*>
        11 receive version message : / <*> <*> <*> <*> / : version <INT> , blocks = <INT> , us = [ <IPv6> ] :8333 , txrelay = <INT> , <PEER> peeraddr = [ <IPv6> ] <*> , mapped_as = <INT>
        10 socket send error , disconnecting <PEER> peeraddr = <*> : Broken pipe ( <INT> )
         9 setting try another outbound <*>
         9 getheaders ( <INT> ) <HASH> to <PEER>
         8 sendtxrcncl from <PEER> ignored , as our node does not have txreconciliation enabled
         7 socket receive timeout : <DUR> , disconnecting <PEER> peeraddr = <IPv4:PORT>
         7 disconnect by subnet = <IPv6> / <INT> match , disconnecting <PEER> peeraddr = [ <IPv6> ] <*>
         5 disconnecting extra outbound <PEER> ( last block announcement received at time <INT> )
         5 V2 handshake timeout , disconnecting <PEER> peeraddr = <*>
         5 ignoring addrv2 message from block-relay-only <PEER>
         5 disconnect by subnet = <IPv4> / <INT> match , disconnecting <PEER> peeraddr = <IPv4:PORT>
         4 mempool request with bloom filters disabled , disconnecting <PEER> peeraddr = <IPv4:PORT>
         3 receive version message : / <*> ( <*> ) / <*> / <*> / : version <INT> , blocks = <INT> , us = <IPv4:PORT> , txrelay = <INT> , <PEER> peeraddr = <IPv4:PORT> , mapped_as = <INT>
         3 Initial headers sync started with <PEER> : <HEIGHT> , max_commitments = <INT> , min_work = <HASH>
         3 socket send error , disconnecting <PEER> peeraddr = <IPv4:PORT> : <*> <*> <*> <*> ( <INT> )
         2 receive version message : Crawly : version <INT> , blocks = <INT> , us = <IPv4:PORT> , txrelay = <INT> , <PEER> peeraddr = <*>
         2 ping timeout : <DUR> , disconnecting <PEER> peeraddr = <IPv4:PORT>
         2 receive version message : / <*> ( <*> <*> <*> <*> / : version <INT> , blocks = <INT> , us = [ <IPv6> ] :0 , txrelay = <INT> , <PEER> peeraddr = <IPv4:PORT>
         2 Protecting outbound <PEER> from eviction
         1 receive version message : Crawly : version <INT> , blocks = <INT> , us = [ <IPv6> ] :8333 , txrelay = <INT> , <PEER> peeraddr = [ <IPv6> ] :33434 , mapped_as = <INT>
         1 Initial headers sync aborted with <PEER> : incomplete headers message at <HEIGHT> ( presync phase )
         1 Unsupported message "reject" prior to verack from <PEER>
         1 socket receive timeout : <DUR> , disconnecting <PEER> peeraddr = [ <IPv6> ] :31033
         1 receive version message : / Satoshi:29.3.0 ( BIP110 meow miao ) / Knots:20260210bip110-v0.4.1 / UASF-BIP110:0.4 / : version <INT> , blocks = <INT> , us = <IPv4:PORT> , txrelay = <INT> , <PEER> peeraddr = <IPv4:PORT> , mapped_as = <INT>
         1 peer does not offer the expected services ( <HEX> offered , <INT> expected ) , disconnecting <PEER> peeraddr = <IPv4:PORT>
         1 receive version message : / Satoshi:29.3.0 ( knots your keys knots your bitcoin ) / Knots:20260210bip110-v0.4.1 / UASF-BIP110:0.4 / : version <INT> , blocks = <INT> , us = <IPv4:PORT> , txrelay = <INT> , <PEER> peeraddr = <IPv4:PORT> , mapped_as = <INT>
         1 keeping outbound <PEER> chosen for eviction ( connect time : <INT> , blocks_in_flight : <INT> )
         1 receive version message : / Satoshi:29.3.0 ( MiniBolt node ) / Knots:20260210 / : version <INT> , blocks = <INT> , us = [ <IPv6> ] :0 , txrelay = <INT> , <PEER> peeraddr = <ONION:PORT>
    
    === scheduler ===
         4 Potential stale tip detected , will try using extra outbound peer ( last tip update : <INT> seconds ago )
         1 ASMap Health Check : <INT> clearnet peers are mapped to <INT> ASNs with <INT> peers being unmapped
    
    === txpackages ===
     81367 added <PEER> as a candidate for resolving orphan <HASH>
     62975 added <PEER> as announcer of orphan tx <HASH> ( wtxid = <HASH> )
     18392 stored orphan tx <HASH> ( wtxid = <HASH> ) , weight : <INT> ( mapsz <INT> outsz <INT> )
     17504 removed orphan tx <HASH> ( wtxid = <HASH> ) ( <INT> announcements )
     17462 added <HASH> ( wtxid = <HASH> ) to peer <INT> workset
     17443 accepted orphan tx <HASH> ( wtxid = <HASH> )
      4513 <PEER> orphanage overflow , removed <INT> of <INT> announcements
      4513 orphanage overflow , removed <INT> tx ( <INT> announcements )
       391 found tx <HASH> ( wtxid = <HASH> ) in reconsiderable rejects , looking for child in orphanage
       377 tx <HASH> ( wtxid = <HASH> ) failed but reconsiderable , looking for child in orphanage
        53 package evaluation for parent <HASH> ( wtxid = <HASH> , sender = <INT> ) + child <HASH> ( wtxid = <HASH> , sender = <INT> ) : package <*>
        53 Erased <INT> orphan transaction ( s ) from <PEER>
        19 Erased <INT> orphan transaction ( s ) included or conflicted by block
         4 invalid orphan tx <HASH> ( wtxid = <HASH> ) from <*> insufficient fee , rejecting replacement <HASH> , less fees than conflicting txs; <FLOAT> < <FLOAT>
         4 removed orphan tx <HASH> ( wtxid = <HASH> )
         1 package RBF checks passed : parent <HASH> ( wtxid = <HASH> ) , child <HASH> ( wtxid = <HASH> ) , package hash ( <HASH> )
    
    === validation ===
    596112 Enqueuing TransactionAddedToMempool : txid = <HASH> wtxid = <HASH>
    596112 TransactionAddedToMempool : txid = <HASH> wtxid = <HASH>
     10666 Enqueuing TransactionRemovedFromMempool : txid = <HASH> wtxid = <HASH> reason = <*>
     10666 TransactionRemovedFromMempool : txid = <HASH> wtxid = <HASH> reason = <*>
       150 NewPoWValidBlock : block hash = <HASH>
       150 BlockChecked : block hash = <HASH> state = Valid
       150 Enqueuing MempoolTransactionsRemovedForBlock : block <HEIGHT> txs removed = <INT>
       150 MempoolTransactionsRemovedForBlock : block <HEIGHT> txs removed = <INT>
       150 Enqueuing BlockConnected : block hash = <HASH> block <HEIGHT>
       150 Enqueuing UpdatedBlockTip : new block hash = <HASH> fork block hash = <HASH> ( in IBD = false )
       150 ActiveTipChange : new block hash = <HASH> block <HEIGHT>
       150 BlockConnected : block hash = <HASH> block <HEIGHT>
       150 UpdatedBlockTip : new block hash = <HASH> fork block hash = <HASH> ( in IBD = false )
        51 Pre-allocating up to position <HEX> in <*>
        24 Enqueuing ChainStateFlushed : block hash = <HASH>
        24 ChainStateFlushed : block hash = <HASH>
    

    This works well. It needs a bit of fine tuning on the tokenization side and I need to think a bit more about how to handle receive version message: <USERAGENT> where the user agent can contain spaces, be empty, have symbols, ...

    It contains a drnlog library, that we could use in peer-observer for real-time log template extraction. We can save the templates and build a grammar out of them. It "learns" about new log messages automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedlog-extractor₿OSS-project

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions