Print out from specific string to rest of line in text file - grep

I have a log file. The file consists of several total times recorded, "TOTAL TIME TAKEN: 84848" at the end of a script run. I am trying to pull out this specific piece of information so I can see which script is taking the longest to run. This portion also is how the line ends. There is nothing after the number. So the desired output would be the following:
TOTAL TIME TAKEN: xxxxx
TOTAL TIME TAKEN: xxx
TOTAL TIME TAKEN: xxxx
and so on...
Using grep I am able to print to screen all the lines containing the above string. But I am only interested in the above part. Using '-o' option, I only get 'TOTAL TIME TAKEN:' portion without the number. So my question is, is there a way to print to screen everything from the desired string ("TOTAL TIME TAKEN:") to the rest of the line.
Thanks in advance! :)

grep -o 'TIME TAKEN: [0-9]{1,}' logFile

Related

Retrieving reports from Data Parameters

Please I have 2 unbound text boxes namely start date and end date and a command button that generates the report after the 2 dates are inputted.
Now I want a query that matches code to generate report when start and end dates are inputted to produce a report.
Thank you

Splunk panel showing graph for a specific time range

I am working with splunk. I want to pull logs for an api call for a specific range of time 9.30pm to 12:00 am on daily basis. Also, the average time taken for the call duraing that specific duration.
index="index_a" sourcetype="pqr" source="prq_source" "Success in api response"
Can someone guide me how to handle this how we can fetch for that particular duration for atleast 7 days.
Something like this should work (so long as you have the automatic field date_hour created by Splunk):
index="index_a" sourcetype="pqr" source="prq_source" "Success in api response" earliest=-7d
| where (date_hour>=21 AND date_minute>=30) OR date_hour>=22
| stats avg(call_duration) as avg_call by success_id
If date_hour & date_minute aren't being automatically supplied by Splunk, you can create them yourself with strftime:
| eval date_hour=strftime(_time,"%H"), date_minute=strftime(_time,"%M")

How do i append today's date after the file name in Automation Anywhere?

I am trying to rename a file in the format like-
"FileName" $date$ ".xlsx"
However, the filename is saved with random numbers like, 24.xlsx.
I have tried changing the date format from the variables manager screen and set it to mm/dd/yyyy, but still no luck.
Any assist on this ?
The code in automation anywhere looks something like this:
Rename Files C\Users\<username>\Documents\query.xlsx to "FileName $Date$ .xlsx"
enter image description here
enter image description here
Expected result be something like : Filename 09152019.xlsx
Actual Result : 24.xlsx
Filename can't have / or :
To rename the file as mentioned in the post use $Month$$Day$$Year$ if day or month less than 10, for example, 09/15/2019 it will be 9152019.
So, to make it two numbers based you will need to use if condition to check the day and month values separately if less than 10 you will do variable operation to add 0 to the left.

How to show "33 minutes ago" on Grafana dashboard with InfluxDB?

I have recently set up Grafana with InfluxDB. I'd like to show a panel that indicates how long it has been since an event took place.
Examples:
Server last reported in: 33 minutes ago
Last user sign up: 17 minutes ago
I can get a single metric pretty easily with the following code:
SELECT time, last("duration") as last_duration FROM custom_events ORDER BY time DESC
But I can't seem to get Grafana to do what I want with the time field.
Any suggestions?
Since Grafana(4.6.0) this is now possible with singlestat panels.
GoTo the Options-Tab
Select Value -> Stat -> Time of last point
Select Value -> Stat -> Unit -> Date & time -> From Now
Its currently(4.0.3) not possible to show the last timestamp in singlestat panels. But there is an issue for supporting this. Hopefully we will find time to implement this in the future.
In 8.4.0 There is a unit selection that allows you to do this, make sure your timestamp is in milliseconds since the epoch and select From Now as the unit in the dropdown menu
singlestat pannel expressing time since

How to format a duration as HH:mm?

In the new Google sheets there's a way of formatting a number as a duration. Format -> Number -> Duration.
1 is formatted as 24:00:00
1.2 is formatted as 28:48:00
1.5 is formatted as 36:00:00
0.03125 is formatted as 0:45:00.
I don't need the seconds in the duration representation, because they bloat my timesheet.
How can I format a duration as HH:mm (without using a formula to calculate hours and minutes and concatenate that with a colon). Is there a way of using the TEXT formula.
This is how I would like it:
1 is formatted as 24:00
1.2 is formatted as 28:48
1.5 is formatted as 36:00 (I don't need 12:00 which datetime-formatting would accomplish)
0.03125 is formatted as 0:45
There is no need to use formulas for that, you can define your own custom formats.
Just go to Format -> Number -> More formats -> More date and time formats. It will open a window with several date and time formats to choose from. You can define your own as well, using the upper text area:
Click on the small arrow on the left, and select the first element you want to add: elapsed hours. Notice there are two different "hours", one for time and another for durations.
Type your separator text :
Click on the arrow again and add the second element: Elapsed Minutes.
Finally, click on each element you added, to determine the correct format (trailing zeros or not, for example).
The answer from Hot Licks and spex worked for me in Google sheets - enclosing the h in [] , as in TEXT(A2,"[h]:mm:ss"), allows a duration larger than 24 hours. Without the [], 28 hours shows up as 4, with the [h], 28 hours shows as 28.
In Excel it's "Custom" then [hh]:mm.
(I'm not quite sure how I figured this out, but it's in a spreadsheet I've been using for a year or so.)
Select Format > Number > More Formats > Custom number format.
Enter [h]:mm and click Apply.
Basically Menu choices are:
Format > Number > Custom Date and time
Then, choose duration properties putting commas between them
TRY THIS
To display 1.00 [Hrs] when you enter 1 ...
Navigate to: Format > Number > Custom number format
In the formula bar use the following:    #,##0.00 "[Hrs]"
"[Hrs]" can be replaced with anything, just make sure you keep the "double quotes"
You should get the following displayed
1    =>   1.00 [Hrs]
1.5   =>   1.50 [Hrs]
15.2 => 15.20 [Hrs]

Resources