How to get the summary of nodes used in node-red?

#1

Hi,

I saw in one of your posts posting summary of nodes used(Showing number of them are used).

Then I got curious how to do that because I am doing stream analytics using node-red with MQTT and data is coming form OPC.

I have couple of flows like more than 400 to 500 MQTT nodes. So this will be helpful information for me to know how many exactly am I using.

Is there any function I can execute in console to get the summary of nodes used in node-red or that info will be available in exported JSON flow file?

#2

Sorry, I can't remember who first came up with this, I just copied it. Don't forget to change the filename to your own flows file. Mine is in a non-standard location and has a non-standard name.

[
    {
        "id": "c34db4d4.2863a8",
        "type": "file in",
        "z": "9974253c.de8db8",
        "name": "",
        "filename": "/home/pi//node/nrlive/.data/flows.json",
        "format": "utf8",
        "chunk": false,
        "sendError": false,
        "x": 330,
        "y": 480,
        "wires": [
            [
                "113a5dd3.0310f2"
            ]
        ]
    },
    {
        "id": "113a5dd3.0310f2",
        "type": "json",
        "z": "9974253c.de8db8",
        "name": "",
        "pretty": false,
        "x": 550,
        "y": 480,
        "wires": [
            [
                "213eb35d.27e87c"
            ]
        ]
    },
    {
        "id": "213eb35d.27e87c",
        "type": "change",
        "z": "9974253c.de8db8",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload^(type) {\t    \"TOTAL\": $count($$.payload),\t    $substringBefore(type, \":\"): $count([$])\t}",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 720,
        "y": 480,
        "wires": [
            [
                "a8fa7ea8.800bf"
            ]
        ]
    },
    {
        "id": "a8fa7ea8.800bf",
        "type": "debug",
        "z": "9974253c.de8db8",
        "name": "",
        "active": true,
        "console": "false",
        "complete": "false",
        "x": 910,
        "y": 480,
        "wires": []
    },
    {
        "id": "16fe06b3.a34209",
        "type": "inject",
        "z": "9974253c.de8db8",
        "name": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 100,
        "y": 480,
        "wires": [
            [
                "c34db4d4.2863a8"
            ]
        ]
    },
    {
        "id": "43a5f911.e2c248",
        "type": "comment",
        "z": "9974253c.de8db8",
        "name": "How Many Nodes in my flow?",
        "info": "",
        "x": 160,
        "y": 440,
        "wires": []
    }
]
```
2 Likes
#3

or install node-red-contrib-flow-statistics

1 Like
#4

@TotallyInformation and @cflurin Thanks for the information.

This are my current stats: :joy::rofl::joy:

{
"TOTAL":2358,
"CassandraDatabase":1,
"cassandra":1,
"catch":12,
"change":1,
"comment":300,
"debug":102,
"delay":19,
"file":37,
"file in":1,
"function":1025,
"http request":44,
"inject":72,
"json":1,
"mqtt in":712,
"mqtt-broker":12,
"switch":2,
"tab":15,
"ui_base":1
}

#5

Both solutions work. But can't accept multiple as solution.

1 Like
#6

It's up to you, you always have a choice. Anyway node-red-contrib-flow-statistics takes less then 1 seconds to do the job.

1 Like