Confluence will be unusable 23-July-2024 at 06:00 due to a Crowd upgrade.
qlog is a wrapper script around the Loki logcli application used for querying control system logs from the command line. It should work on any of the dev or production accelerator side machines, including the ACR OPIs.
When not run with any options, qlog will default to the following:
Get the last line of log output as json
$ qlog --limit 1 --output json --quiet { "accelerator": "LCLS", "origin": "ioc-in20-pp01", "user": "", "facility": "IOC", "severity": "", "text": "log_prefixEIP error during scan list completion for 172.27.12.55:44818", "timestamp": "2023-10-26T23:55:12.0042-07:00" }
Get the last 5 lines from a specific accelerator and format the output as a table:
$ qlog -a FACET --limit 5 --table Timestamp Accelerator Origin Facility Text =========================================================================================================== 2023-09-22 11:48:58 FACET V103 MPSC Timeout waiting for AP09 events - CHECK ETHERNET 2023-09-22 11:48:58 FACET V060 OPS BPMSAMPL - None of requested micros have hardware online 2023-09-22 11:48:58 FACET V060 BPMO Cannot satisfy BPM request; beam code 10 has no rate 2023-09-22 11:49:01 FACET facet-daemon1 lasr PV: PMTR:LA20:10:QUERYSTATDATA Active scan count exceeded! 2023-09-22 11:49:02 FACET opi20 EDM name='MGNT:LI11:1:BENDCTRL' old='0' new='9' dsp=':0'
Also filter by origin and facility:
$ qlog -a LCLS --origin ioc-li25-cv01 --facility IOC --limit 3 --table Timestamp Accelerator Origin Facility Text =========================================================================================================== 2023-09-22 11:52:28 LCLS ioc-li25-cv01 IOC save_restore:write_it - unable to open file '/data/autosave/info_positions.sav' [230922-115212] 2023-09-22 11:52:28 LCLS ioc-li25-cv01 IOC ../save_restore.c(1615): [0x5]=write_it:I/O error 2023-09-22 11:52:28 LCLS ioc-li25-cv01 IOC save_restore:write_save_file: Can't write save file. [230922-115212]
To find all log lines with a specific string in it, just pass that exact string to the --regex option. Here we search for any line containing KLYS
$ qlog --regex KLYS --limit 5 --table Timestamp Accelerator Origin Facility Text =========================================================================================================== 2023-09-22 11:55:54 LCLS ioc-li27-cv01 IOC Record KLYS:LI27:21:PIOP_MSGSUB: Battery Failure: 2023-09-22 11:56:39 FACET V016 OPS KLYSTRON TRIM request sent to 11 enabled micros 2023-09-22 11:57:15 LCLS ioc-li27-cv01 IOC Record KLYS:LI27:21:PIOP_MSGSUB: NO RF DRIVE : 2023-09-22 11:57:20 LCLS ioc-li27-cv01 IOC Record KLYS:LI27:21:PIOP_MSGSUB: Battery Failure: 2023-09-22 11:57:49 LCLS lcls-daemon1 temp KLYS:LI24:31 RF low. Lowering KLYS:LI24:31:DL_WG_TEMP low alarm limits: LOLO=102.0 degF, LOW=102.1 degF
Multiple regular expressions can be chained together, this time just using the shorter -r option:
$ qlog -r KLYS -r [0-9]{2}:[0-9]{2} --limit 5 --table Timestamp Accelerator Origin Facility Text =========================================================================================================== 2023-09-22 12:14:12 LCLS mccas0 dpKlys PVname = KLYS:LI28:11 2023-09-22 12:14:12 LCLS mccas0 dpKlys Status PVname = KLYS:LI28:11:BEAMCODE1_STAT 2023-09-22 12:14:12 LCLS mccas0 dpKlys Doing INT Channel.getChannel on : KLYS:LI28:11:BEAMCODE1_STAT 2023-09-22 12:14:49 LCLS lcls-daemon1 temp KLYS:LI27:61 RF on. Restoring KLYS:LI27:61:DL_WG_TEMP low alarm limits: LOLO=110.6 degF, LOW=111.0 degF 2023-09-22 12:14:54 LCLS lcls-daemon1 temp KLYS:LI27:61 RF low. Lowering KLYS:LI27:61:DL_WG_TEMP low alarm limits: LOLO=100.6 degF, LOW=101.0 degF
And specific strings or expressions can be excluded as well using the --exclude option. This is largely a convenience option, exclusion can also be done using the --regex option with regular expression syntax. But this saves the trouble of having to lookup/remember how to do more complicated negations in regex. Here we just exclude any line containing the word alarm (along with the previous regular expressions from above):
$ qlog -r KLYS -r [0-9]{2}:[0-9]{2} --exclude alarm --limit 5 --table Timestamp Accelerator Origin Facility Text =========================================================================================================== 2023-09-22 12:19:29 LCLS mccas0 dpKlys Query = KLYS:LI28:11//TACT : Device Name = KLYS:LI28:11 2023-09-22 12:19:29 LCLS mccas0 dpKlys PVname = KLYS:LI28:11 2023-09-22 12:19:29 LCLS mccas0 dpKlys Status PVname = KLYS:LI28:11:BEAMCODE1_STAT 2023-09-22 12:19:29 LCLS mccas0 dpKlys Doing INT Channel.getChannel on : KLYS:LI28:11:BEAMCODE1_STAT 2023-09-22 12:19:39 LCLS ioc-li27-cv01 IOC Record KLYS:LI27:51:PIOP_MSGSUB: PIOP Processor Crashed. Reset Required
To specify the time range to query against, use either the --since option, or the --from and --to option. --since is the lookback period in hours, so if --since 24h is used, the query will run against the last 24 hours of log lines. If there is a specific range of time that needs to be queried, the --from and --to options should be used, as in the following examples:
# Get lines containing the word error from 2 days ago to 1 day ago $ qlog -r "(?i)error" --from -2d --to -1d --table # Specify a specific date/time using RFC3339Nano without timezone $ qlog --from 2023-09-20T10:00:00Z --to 2023-09-21T10:00:00Z
Finally, one particularly useful option is --tail, or -t. Adding this to any query will allow you to tail log results in real time, with the display updating as new results flow in. All non-time filtering options described above will work with tailing as well.
# The same query from above to retrieve lines that contain the word error, but now we tail the results to watch them in real time $ qlog -r "(?i)error" --tail
Using the --help option will bring up a usage guide that will include the current options for use with qlog.