Tagging rarely reloaded Qlik Sense apps
Using Ctrl-Q NR it is possible to first identify which apps in a client-managed Qlik Sense environment that have not reloaded for a long time, then tag those apps with a suitable tag. The apps can then be easily identified in the QMC.
Let's say you are responsible for a client-managed Qlik Sense environment that has been around for some time and that has more than a handful of users.
You want to keep things tidy and need a way to quickly filter out all apps that have not been reloaded during the last year.
This can be solved in various ways. Using the filtering function of the QMC works for the simple scenarios, but let's say you want to collect all apps that were reloaded in 2017 in one group, and apps last reloaded in 2018 in another group.
Solution
The Node-RED flow below uses various Ctrl-Q NR nodes to do the following:
- Create two tags (if they don't already exist): reload2017 and reload2018.
- Get metadata for all apps. A single Node-RED message will contain metadata for all apps on the Sense server.
- Break apart that large JSON into separate messages, one for each app.
- Check if apps were last reloaded in 2017. If so, tag app with "reload2017". Rate limit the app update to one update/second, to avoid spamming the Sense server.
- Same as step 4, but for 2018.
- Delete the tags to clean up and get back to the state before the demo.
The flow has plenty of debug outputs that can be enabled to examine what messages pass through.
Here is the flow JSON that can be imported into your own Node-RED environment. A dummy Sense server is used in the nodes' configuration.
[{"id":"addca4409d45dede","type":"inject","z":"08e35e43abf2bf6e","name":"Get all apps","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":150,"y":140,"wires":[["e7a26eb84ddfa942"]]},{"id":"b2323f5a91ef9325","type":"debug","z":"08e35e43abf2bf6e","name":"Result (single JSON for all apps)","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":750,"y":80,"wires":[]},{"id":"7489e369e3d94944","type":"debug","z":"08e35e43abf2bf6e","name":"Result (one msg for each app)","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":710,"y":240,"wires":[]},{"id":"c543403ade92bcd8","type":"switch","z":"08e35e43abf2bf6e","name":"Last reload was during ...","property":"payload.lastReloadTime","propertyType":"msg","rules":[{"t":"btwn","v":"2017-01-01","vt":"str","v2":"2017-12-31","v2t":"str"},{"t":"btwn","v":"2018-01-01","vt":"str","v2":"2018-12-31","v2t":"str"}],"checkall":"true","repair":false,"outputs":2,"x":690,"y":280,"wires":[["f5da1d245d99d24b"],["8f6ec9f05477f230"]]},{"id":"4b4b4e937ad48d94","type":"debug","z":"08e35e43abf2bf6e","name":"lastReloadTime","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.lastReloadTime","targetType":"msg","statusVal":"","statusType":"auto","x":220,"y":640,"wires":[]},{"id":"2027f341ea9b8c28","type":"comment","z":"08e35e43abf2bf6e","name":"Find and tag rarely reloaded apps","info":"","x":150,"y":40,"wires":[]},{"id":"20ea0e8eeb571856","type":"qseow-app","z":"08e35e43abf2bf6e","name":"Get apps","server":"5e42d0533190acfb","op":"r","appId":"","appSource1":"predefined","x":700,"y":140,"wires":[["b2323f5a91ef9325","87879e9733e4b69c"]]},{"id":"10539b9ff6ff1ed9","type":"split","z":"08e35e43abf2bf6e","name":"Split into one msg per app","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":430,"y":260,"wires":[["7489e369e3d94944","c543403ade92bcd8"]]},{"id":"87879e9733e4b69c","type":"change","z":"08e35e43abf2bf6e","name":"Create array of found apps","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.app","tot":"msg","dc":true}],"action":"","property":"","from":"","to":"","reg":false,"x":180,"y":260,"wires":[["10539b9ff6ff1ed9"]]},{"id":"565c364cd2e4f40f","type":"debug","z":"08e35e43abf2bf6e","name":"2018","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":190,"y":600,"wires":[]},{"id":"614616a610b07844","type":"debug","z":"08e35e43abf2bf6e","name":"lastReloadTime","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.lastReloadTime","targetType":"msg","statusVal":"","statusType":"auto","x":220,"y":460,"wires":[]},{"id":"7b4cf47bbdacfae8","type":"debug","z":"08e35e43abf2bf6e","name":"2017","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":190,"y":420,"wires":[]},{"id":"4bb4982715b7c1c4","type":"change","z":"08e35e43abf2bf6e","name":"Prepare \"reload2017\" tag update","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t \"app\": [\t {\t \"id\": payload.id\t }\t\t ],\t \"newData\": {\t \"tag\": [\t \"reload2017\"\t ]\t }\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":380,"wires":[["f0d99bd04edb573c"]]},{"id":"10672611189b3a64","type":"debug","z":"08e35e43abf2bf6e","name":"Debug","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":380,"wires":[]},{"id":"f0d99bd04edb573c","type":"delay","z":"08e35e43abf2bf6e","name":"Rate limit to 1 msg every second","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":580,"y":380,"wires":[["10672611189b3a64","6e2eb3c35d7cdf0b"]]},{"id":"6e2eb3c35d7cdf0b","type":"qseow-app","z":"08e35e43abf2bf6e","name":"Update","server":"5e42d0533190acfb","op":"u","appId":"\n\nad61b901-3343-4bbf-b3e6-aa3ee333abef\n\n7e5866aa-dd2b-42aa-81fc-3765e0d7cf4b\n7e5866aa-dd2b-42aa-81fc-3765e0d7cf4c\n","appSource1":"msg-in","appSource2":"msg-in","x":640,"y":420,"wires":[["dc056b06e62cad64"]]},{"id":"dc056b06e62cad64","type":"debug","z":"08e35e43abf2bf6e","name":"Result 2017","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":830,"y":420,"wires":[]},{"id":"f5da1d245d99d24b","type":"link out","z":"08e35e43abf2bf6e","name":"2017 out","mode":"link","links":["4a9df579ba2bf47c"],"x":915,"y":260,"wires":[]},{"id":"4a9df579ba2bf47c","type":"link in","z":"08e35e43abf2bf6e","name":"2017 in","links":["f5da1d245d99d24b"],"x":75,"y":380,"wires":[["7b4cf47bbdacfae8","614616a610b07844","4bb4982715b7c1c4"]]},{"id":"8f6ec9f05477f230","type":"link out","z":"08e35e43abf2bf6e","name":"2018 out","mode":"link","links":["7fb4bc9bd7b52146"],"x":915,"y":300,"wires":[]},{"id":"7fb4bc9bd7b52146","type":"link in","z":"08e35e43abf2bf6e","name":"2018 in","links":["8f6ec9f05477f230"],"x":75,"y":560,"wires":[["565c364cd2e4f40f","4b4b4e937ad48d94","ae7d14b419b38538"]]},{"id":"ae7d14b419b38538","type":"change","z":"08e35e43abf2bf6e","name":"Prepare \"reload2018\" tag update","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t \"app\": [\t {\t \"id\": payload.id\t }\t\t ],\t \"newData\": {\t \"tag\": [\t \"reload2018\"\t ]\t }\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":560,"wires":[["214ca4e55ea0e193"]]},{"id":"cabe3436c16feca9","type":"debug","z":"08e35e43abf2bf6e","name":"Debug","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":560,"wires":[]},{"id":"214ca4e55ea0e193","type":"delay","z":"08e35e43abf2bf6e","name":"Rate limit to 1 msg every second","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":580,"y":560,"wires":[["cabe3436c16feca9","e0cb190ffe47c7f8"]]},{"id":"e0cb190ffe47c7f8","type":"qseow-app","z":"08e35e43abf2bf6e","name":"Update","server":"5e42d0533190acfb","op":"u","appId":"\n\nad61b901-3343-4bbf-b3e6-aa3ee333abef\n\n7e5866aa-dd2b-42aa-81fc-3765e0d7cf4b\n7e5866aa-dd2b-42aa-81fc-3765e0d7cf4c\n","appSource1":"msg-in","appSource2":"msg-in","x":640,"y":600,"wires":[["88b130661be1185d"]]},{"id":"88b130661be1185d","type":"debug","z":"08e35e43abf2bf6e","name":"Result 2018","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":830,"y":600,"wires":[]},{"id":"a3429397ece248fb","type":"qseow-tag","z":"08e35e43abf2bf6e","name":"","server":"5e42d0533190acfb","op":"d","tagName":"","tagSource":"msg-in","x":430,"y":740,"wires":[["70a703f6922de3cf"]]},{"id":"70a703f6922de3cf","type":"debug","z":"08e35e43abf2bf6e","name":"Result","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":630,"y":740,"wires":[]},{"id":"2546188df9093c30","type":"inject","z":"08e35e43abf2bf6e","name":"Delete \"reload2018\" tag","props":[{"p":"payload.tagName","v":"[\"reload2018\"]","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":200,"y":780,"wires":[["a3429397ece248fb"]]},{"id":"245e5142cdf52b0c","type":"inject","z":"08e35e43abf2bf6e","name":"Delete \"reload2017\" tag","props":[{"p":"payload.tagName","v":"[\"reload2017\"]","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":200,"y":740,"wires":[["a3429397ece248fb"]]},{"id":"8e337ef00929c5f2","type":"inject","z":"08e35e43abf2bf6e","name":"Reset","props":[{"p":"reset","v":"1","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":370,"y":340,"wires":[["f0d99bd04edb573c"]]},{"id":"3deb4f74dc61d10e","type":"inject","z":"08e35e43abf2bf6e","name":"Reset","props":[{"p":"reset","v":"1","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":370,"y":520,"wires":[["214ca4e55ea0e193"]]},{"id":"79f7ac99452cf30c","type":"inject","z":"08e35e43abf2bf6e","name":"Get tag count","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":150,"y":80,"wires":[["fd7bb42cba4b9dd6"]]},{"id":"67109ab9b9155fe3","type":"debug","z":"08e35e43abf2bf6e","name":"Tag count","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload.tag.length","targetType":"msg","statusVal":"payload","statusType":"auto","x":480,"y":80,"wires":[]},{"id":"fd7bb42cba4b9dd6","type":"qseow-tag","z":"08e35e43abf2bf6e","name":"","server":"5e42d0533190acfb","op":"r","tagName":"","tagSource":"predefined","x":330,"y":80,"wires":[["67109ab9b9155fe3"]]},{"id":"e7a26eb84ddfa942","type":"qseow-tag","z":"08e35e43abf2bf6e","name":"Create tags \"reload2017\", \"reload2018\"","server":"5e42d0533190acfb","op":"c","tagName":"# Create these tags\nreload2017\nreload2018","tagSource":"predefined","x":420,"y":140,"wires":[["20ea0e8eeb571856"]]},{"id":"6520c9dd5c1959a9","type":"inject","z":"08e35e43abf2bf6e","name":"Get tag count","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":820,"wires":[["79f931296e210f9a"]]},{"id":"6f5c670ee2e0a174","type":"debug","z":"08e35e43abf2bf6e","name":"Tag count","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload.tag.length","targetType":"msg","statusVal":"payload","statusType":"auto","x":640,"y":820,"wires":[]},{"id":"79f931296e210f9a","type":"qseow-tag","z":"08e35e43abf2bf6e","name":"","server":"5e42d0533190acfb","op":"r","tagName":"","tagSource":"predefined","x":430,"y":820,"wires":[["6f5c670ee2e0a174"]]},{"id":"5e42d0533190acfb","type":"qseow-sense-server","name":"Dummy Qlik Sense server","protocol":"https","host":"my.qlikserver.com","port":"4242","authType":"cert","certFile":"c:\\secret\\client.pem","keyFile":"c:\\secret\\client_key.pem","certCaFile":"","jwt":""}]