bugy / script-server

Web UI for your scripts with execution management
Other
1.55k stars 246 forks source link

History search #572

Open baniczar opened 2 years ago

baniczar commented 2 years ago

Hi,

Would it be possible to add search field to the history view so I could limit the number of displayed logs? I have to search the logs for a certain information which I now do with grep from the linux command line. Would be great to add possibility to the users to put a text inside search field so the number of logs will be limited to those having that text inside.

Thanks, Baniczar

bugy commented 1 year ago

Hi @baniczar, unfortunately, I won't have time to implement it. But you can try to implement it yourself and submit a PR

gpsinghsandhu commented 1 year ago

@baniczar I submitted a pull request #577 (now merged) which allows you to search on the 'user' and 'script' field. If this feature satisfies your requirement, then we can close this issue. cc: @bugy

baniczar commented 1 year ago

@gpsinghsandhu I use just few scripts and one user so this is not an issue in my case. I'm looking to have a possibility to search through the python script logs. E.g. I have some order numbers in the script log reported. From time to time someone is asking to check the log for a certain order number (any text in general) but I don't know which script schedule took care of that order number. So I have to go to the linux shell and browse the log files (in the log directory) for that number "grep -rnw ./ -e 'OrderNo 99999' and check the listed files using one of the shell text editors. So having a search box/field in the GUI which can do grep and list only logs/iterations containing this search text is what I'm looking for.

Thanks anyway for your contribution!

MNeill73 commented 1 year ago

You can do this with a script in the script server. You already have the command, just replace the order number with ${1}, change those single quotes to double so the variable gets expanded, and done.

You could even parse the grep results, split off the filename, pipe it to "|sort|uniq" to get the filenames, extract the run numbers from the filenames, and then create links in the script to "https://yourURL/index.html#/history/00000" where you can view those logs through the script-server UI.

MNeill73 commented 1 year ago

Here's a quickie I did against my own logs directory, I'm looking for any script that ran against se_lab_XXX, where I pass XXX as the single parameter:

[ec2-user@control ~]$ cat find-lab-logs.sh
#!/bin/bash
#
for i in `grep se_lab_${1} /opt/script-server/logs/processes/*|cut -d: -f1|sort|uniq`; do
    runID=`egrep "^id" ${i}|cut -d: -f2`
    echo "${runID} --> ${i}<BR>"
    echo "&nbsp;&nbsp;&nbsp;&nbsp;"
    echo "<A HREF=\"/index.html#/history/${runID}\" TARGET=\"_blank\">Run ${runID}</A><BR><BR>"
done

Script output: Screen Shot 2022-11-16 at 1 37 44 PM

And the links that are created by the script, i.e., the "Run 76", ar as such: https://myScriptServerSite.com:5000/index.html#/history/76

baniczar commented 1 year ago

@MNeill73 Nice idea. Will try this.