Finalizing an Event Set
When writing a query, especially if the output is going to be used as part of a widget or visualization, the result may require additional processing to format and update field names, values, formatting, and/or the order of the data.
This processing can be done within LogScale as part of the query, but processing and formatting of this information should be performed after the primary filtering, count, and aggregation has occurred.
For example, given an event set with a list of permissions against a specific filetype, we might use a query like this:
cmd = /.exe$/
| splitString(by=",",field=perms,as=_perms)
| split(_perms)
| groupBy([_perms],function=count(as=_cnt))This splits up the permissions, aggregates the detail, and then calculates the count of the matching items. The resulting table might look like this:
| _perms | _cnt |
|---|---|
| account_management | 2 |
| accounting | 1 |
| ai | 1 |
| analytics | 1 |
| applications | 2 |
| audit | 1 |
| automation | 2 |
| billing | 2 |
| board | 1 |
| brand | 1 |
| business_operations | 1 |
| channel | 1 |
| controllers | 1 |
| corporate | 1 |
| customer_success | 3 |
| customer_support | 1 |
| data_science | 1 |
| database | 2 |
| design | 1 |
| devops | 1 |
| digital | 1 |
| diversity_inclusion | 1 |
| employee_relations | 1 |
| engineering | 7 |
| enterprise | 1 |
| enterprise_systems | 1 |
| events | 2 |
| executive | 4 |
| ... | Â |
For displaying as part of a dashboard there are a few issues with this output:
The field names are not descriptive, nor is it clear what they are displaying.
The list is sorted alphabetically, but sorting based on the count of results would be more meaningful.
There are too many results.
These are all examples of data formatting and finalization that need to be performed as part of the process. LogScale includes functions to modify all of these elements to finalize the data, so that the information is ready to be displayed within a widget or dashboard.
Adding some finalization to the query can tidy it up for display. For example, this query is designed to refine the result:
cmd = /.exe$/
| splitString(by=",",field=perms,as=_perms)
| split(_perms)
| groupBy([_perms],function=count(as=_cnt))
| sort(_cnt,limit=10)
| rename([["_perms","Permission Group"],["_cnt","Count"]])After the query has concluded, the result looks like this:
| Permission Group | Count |
|---|---|
| it | 11 |
| engineering | 7 |
| finance | 7 |
| marketing | 7 |
| operations | 7 |
| sales | 7 |
| product | 5 |
| executive | 4 |
| hr | 4 |
| legal | 4 |
This formatting and finalization of the content is a critical part of making the results of a query accessible for use within a widget. For more information, see Widgets.