10.6 introduced a new CLI feature in NwConsole that allowed reporting with topquery. This neat command allows the parsing of the /var/log/messages file for query commands on brokers, concentrators and archivers to report on query performance. The is a very helpful command to dig into general analyst performance (best practices, poor syntax, optimization opportunities etc.) and hunt down slowness in the NetWitness Suite.
CLI: Commands used for Troubleshooting
Command Line Interface for version 10.6.4
This is a sample line from the output of topquery
- # Dec 3 13:43:46 loki NwConcentrator[15854]: [SDK-Values] [audit] User admin (session 54557, 10.105.45.109:49552) has f
- inished values (channel 55739, queued 00:00:00, execute 00:25:13): fieldName=event.cat.name id1=491506493860 id2=7516691
- 19298 threshold=100000 size=20 flags=sessions,sort-total,order-descending,ignore-cache where="time=\"2015-12-03 11:39:00
- \"-\"2015-12-03 17:38:59\""
- /sdk values fieldName=event.cat.name id1=491506493860 id2=751669119298 threshold=100000 size=20 flags=sessions,sort-tota
- l,order-descending,ignore-cache where="time=\"2015-12-03 11:39:00\"-\"2015-12-03 17:38:59\""
Each query is represented twice (the second starts at /sdk).
- You can see the user that ran the query 'User admin'. Depending on where the query was run from this may be the actual user logged in (investigation drills) or it may be the service account that was used to connect the RE service to all the components (and RE rules or ESA rules).
- You are able to see how long the query ran for (execute) and how long it might have waited to execute (queued)
- You can see the metakey that was use to drill onto in this case from investigator - navigate it was on event.cat.name
- the timeframe for the query is also displayed
- the ordering of the data is also shown (order-descending)
- the default size of 20 values is also used to load on the drill ( a give away that this is the investigate view and default settings)
There are lots of options to topquery and it can be very handy to run this during monthly reviews of the platform to review query operations and make sure bad habits arent creeping into the analyst workflows. One to be especially careful of is Investigate - advanced queries where the times are taking longer than normal to execute - check for queries on non index-values keys as this can create a major performance hit on the system.
Here is the help menu output from NwConsole - Topquery
- Usage: topQuery [days=#] [hours=#] [time1=
]
- [time2=
] [user=
] [top=N]
- [match=
] [input=
]
- [delimiter=","] [append=<0,1>] [dateRegex=
]
- [regex=
] [show] [distribution] [canceled]
- Returns the top N longest running queries from the audit log (either a file or
- from the log API)
-
- days - Indicates the time range to query logs. hours/days is how
- far back from NOW.
- hours - Indicates the time range to query logs. hours/days is how
- far back from NOW.
- time1 - Indicates the starting time range to query logs
- time2 - Indicates the ending time range to query logs
- user - The user who submitted the query, by default searches all
- users, use (admin|user1|user2) for multiple
- top - The top N queries to display, by default shows the longest
- executing 100 queries in the time range
- match - The types of queries to match, default is:
- values,query,timeline
- input - Parse a log file for the queries
- output - The optional output path where the logs will be saved,
- otherwise logs are written to console
- append - If 1, will append to existing file, zero overwrites
- (default)
- dateRegex - If passed in, this will be used to parse the date (syslog
- only) instead of the default
- regex - If passed in, this will be used to parse the complete log
- instead of the default
- show - Shows all the regex expressions that are used by default
- distribution - Groups query execution times into the provided distribution.
- Must be a comma separated list of increasing seconds.
- Example: distribution=10,20,30,60,300
- canceled - If true, it will analyze canceled queries instead of queries
- that finished
Want to see who is downloading pcap files from the decoders and how long it took?
- [loki.netwitness.local:50005] /> topquery match=packets top=10
- # 177682836 audit 2016-Feb-19 16:15:20 SDK-Packets User administrator (session 216639, 10.105.33.127:65256) has finished packets (channel 216675, queued 00:00:00, execute 00:00:01): sessions=26197520000-26197520010 op=start
- /sdk packets sessions=26197520000-26197520010 op=start
-
- # 177682848 audit 2016-Feb-19 16:15:37 SDK-Packets User administrator (session 216639, 10.105.33.127:65256) has finished packets (channel 216699, queued 00:00:00, execute 00:00:00): sessions=26197520015-26197520020 op=start
- /sdk packets sessions=26197520015-26197520020 op=start
-
- 2 queries were analyzed that match the specified criteria
- 2 (100.0%) queries executed <= 5 seconds
- 0 (0.0%) queries executed <= 10 seconds
- 0 (0.0%) queries executed <= 20 seconds
- 0 (0.0%) queries executed <= 30 seconds
- 0 (0.0%) queries executed <= 60 seconds
- 0 (0.0%) queries executed <= 120 seconds
- 0 (0.0%) queries executed <= 300 seconds
- 0 (0.0%) queries executed <= 600 seconds
- 0 (0.0%) queries executed <= 1200 seconds
- 0 (0.0%) queries executed <= 3600 seconds
- 0 (0.0%) queries executed > 3600 seconds
Want to change the distribution of the time buckets for the query results to something other than default?
- > login loki.netwitness.local:50005 administrator
-
- Password: *******************
- Successfully logged in as session 12102