ChatGPT & Advanced Reporting in Cloud

Pro Tips with Esben #40

Reporting in Lansweeper Cloud is easier to start with. But what if you need more complex operations? Well, today I'll cover some of the tricks I've learned as I have started building reports in Lansweeper Cloud, including how you can use ChatGPT to help build your reports.

Lansweeper Cloud's basic reporting is great for when you want to create simple reports, but many existing Lansweeper customers as well as new ones might not be familiar with writing queries for MongoDB. As someone who has worked with SQL for many years I faced those same issues when making the switch, here are some of my tips on how you can get started quickly with more advanced reporting in the new cloud report builder.

Understanding the Field Selector

Selecting the right data might already be a challenge, the example below shows me looking for the domain field. Since Lansweeper scans tons of data from different assets, components, and sources, there are quite a few domain fields. Knowledge of the on-premise database will help you here as many of the collection names are similar. If you're not familiar with the on-premise database, I would recommend bookmarking the Lansweeper Classic database documentation.

One collection you'll probably use a lot is the "ROOT" collection, this is comparable with the on-premise tblassets table. It contains most of the general data fields for assets which you usually see on the asset summary page. In the list of collections on the left-hand side, you'll find it listed as "Assets".

Use Steps

The steps that you use in MongoDB uses to create reports should be used, not only does it make reports easier, it also makes it easier to understand if you split up complex filters in multiple steps. Using two steps instead of one can also greatly simplify your report so if you're struggling trying to get something done, try getting it done in two steps instead.

For example, when creating a report for 20 computer models from a specific manufacturer, you would have to create a very big filter if you only use one step. You would filter on model 1 and the manufacturer, then model 2 and the manufacturer, model 3 and the manufacturer. The easier method would be to use the first filter step to filter on all 20 models and use a second filter step to filter on the manufacturer. This prevents you from repeating the manufacturer filter for each model.

Duplicate, Duplicate, Duplicate.

I cannot emphasize enough how important it is to learn this button. Lansweeper has a ton of reports, all of which are basically templates for you to start, or steal from. I rarely create a report from scratch because I know there are reports there that have parts I can re-use with minor tweaking. I also often duplicate a report just to look how it was created. Even if I don't steal any of the code, knowing how specific conditions are created can be useful.

ChatGPT

One of the most useful tools in my path to learning MongoDB querying has been ChatGPT. It is great at both giving examples and explaining code. Once you duplicate a report, attempt to understand what all the custom code does, simply take a party of it and paste it into ChatGPT to learn what it does.

On the other hand, need a specific functionality, ask ChatGPT how to do it in MongoDB. Just pay attention to how the Lansweeper code puts everything between quotes. You'll likely need to add quotes around variables and functions you take from ChatGPT. I have noticed that if you give ChatGPT an example from a Lansweeper report that it can adjust, it will take over the quotes correctly, saving you some time.

Some examples:

Lastly, you can also use ChatGPT to write code you already know how to write. For example when there was a vulnerability in 20 specific laptop models, I simply gave ChatGPT an example of my code, and asked it to add the whole list of models into that code. That way I don't have to copy-paste and adjust manually.

Notepad++

When working with longer parts of custom code, scrolling in the small code boxes in the report builder isn't the most comfortable. Therefore I personally just copy paste code into Notepad++ to read and edit it more easily.

Documentation

If you're looking for something specific or wonder why something ChatGPT gave you isn't working, you might want to check the documentation. It lists exactly which functions you can use in the custom code, and it also has a list of which data you can find. Aside from using the Cloud report documentation, using the Lansweeper Classic documentation can also help a lot since most of the data fields in Cloud inherits their name from the Classic SQL tables.

Esben from Lansweeper

About Esben

Technical Product Evangelist at Lansweeper

Maximizing IT Asset Management proficiency by empowering end-users to take full advantage of their toolset.

You may also like...

Try Lansweeper for Free

Learn why Lansweeper is used by thousands of enterprises worldwide.‚Äč