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:

logscale
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_management2
accounting1
ai1
analytics1
applications2
audit1
automation2
billing2
board1
brand1
business_operations1
channel1
controllers1
corporate1
customer_success3
customer_support1
data_science1
database2
design1
devops1
digital1
diversity_inclusion1
employee_relations1
engineering7
enterprise1
enterprise_systems1
events2
executive4
... 

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:

logscale
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 GroupCount
it11
engineering7
finance7
marketing7
operations7
sales7
product5
executive4
hr4
legal4

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.