regular expression help for parsing in alteryx - alteryx

I have a string (without doble qoutes) "2022-12-15 21:23:22 - a123456 (Remarks) 2022-12-15 22:12:22 - a123456 (Remarks) User acknowledgement time"
There are 2 date/time stamps in this string in need the date/time stamp appearing before User acknowledgement time. I am using regex (\.*\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}.*User acknowledgement time) my regex is capturing very first time stamp showing up in string but I need date/time stamp right before User acknowledgement time. Please help.
(\.*\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}.*User acknowledgement time)
I am expecting result as 2022-12-15 22:12:22 - a123456 (Remarks) User acknowledgement time
but I am getting result 2022-12-15 21:23:22 - a123456 (Remarks) User acknowledgement time

I think your group just needs to move. Group 1 is what you are after:
.*(\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}).*User acknowledgement time
regex101

Related

How to alert on increased "counter" value with 10 minutes alert interval

So, I have monitoring on error log file(mtail). It's just count number of error lines. And mtail sums number of new lines in file.
I want to send alerts when new error(s) occured each 10 minutes only. Not for every single error.
Please, can you provide exact values for these lines:
expr: increase(php_fpm_errors_total[10m]) > 0
for: 10m
I would appreciate if you provide me some doc links or explanation.
The way you have it, it will alert if you have new errors every time it evaluates (default=1m) for 10 minutes and then trigger an alert. There is also a property in alertmanager called group_wait (default=30s) which after the first triggered alert waits and groups all triggered alerts in the past time into 1 notification. You can remove the for: 10m and set group_wait=10m if you want to send notification even if you have 1 error but just don't want to have 1000 notifications for every single error

Azure OMS - Heartbeat Test - If the server is down for more than a day, no alerts will be generated

There is an issue with the current Heartbeat query we are using. The query works perfectly, however I have observed an issue while setting up the alert.
Breakdown of the query:
Type=Heartbeat Computer in $ComputerGroups[NON-PROD_Group] |
measure max(TimeGenerated) as LastCall by Computer | where LastCall < NOW-5MINUTE
Query checks for Heartbeat of computer in the group ‘NON-PROD_Group’
Measure max(TimeGenerated) as LastCall by Computer: will check for the time of last occurrence of Heartbeat from all the server and assign the value to a variable ‘LastCall’. ‘LastCall’ now has the time of last heartbeat
Where LastCall < NOW-5MINUTES: this section will check if the last heartbeat was before 5 minutes from ‘NOW’. Alert is triggered based on that.
I have given TIME WINDOW as 24 hour. The issue here is alert is generated for all the occurrences between ‘NOW-5MINUTES’ and 24 HOURS. There are no alerts generated if the LastCall falls outside the time window.
If the server is down for more than a day, no alerts will be generated.
For Instance, if Friday evening One of the server goes down, alert notifications will come in until Saturday evening(24 Hours is maximum time allowed) after that the alert clears and no more notifications are generated.
Monday morning, the alert would be cleared and will report everything is working fine.
Heartbeat
| summarize LastHeartbeat=max(TimeGenerated) by Computer, OSType, ResourceGroup, Resource, ResourceProvider, ResourceType
| where LastHeartbeat < ago(5m)
// If you are looking for any specific resource group, you may add in where condition like ResourceGroup == 'ecom'

NWS - Temperature per hour

I'm looking into the National Weather Service's API and trying to get the temperature per hour for the certain location in the next 24 hours.
I'm using the test client to generate the requests:
http://graphical.weather.gov/xml/SOAP_server/ndfdXML.htm
Input
From: 2015-06-29T15:00:00
To: 2015-06-30T15:00:00
Product: Time series
Variables: Hourly temperatures, Dewpoint temperature, Apparent temperature
Unit: US standard
<time-layout time-coordinate="local" summarization="none">
<layout-key>k-p3h-n9-1</layout-key>
<start-valid-time>2015-06-29T17:00:00-04:00</start-valid-time>
<start-valid-time>2015-06-29T20:00:00-04:00</start-valid-time>
<start-valid-time>2015-06-29T23:00:00-04:00</start-valid-time>
<start-valid-time>2015-06-30T02:00:00-04:00</start-valid-time>
<start-valid-time>2015-06-30T05:00:00-04:00</start-valid-time>
<start-valid-time>2015-06-30T08:00:00-04:00</start-valid-time>
<start-valid-time>2015-06-30T11:00:00-04:00</start-valid-time>
<start-valid-time>2015-06-30T14:00:00-04:00</start-valid-time>
<start-valid-time>2015-06-30T17:00:00-04:00</start-valid-time>
</time-layout>
<parameters applicable-location="point1">
<temperature type="hourly" units="Fahrenheit" time-layout="k-p3h-n9-1">
<name>Temperature</name>
<value>83</value>
<value>79</value>
<value>72</value>
<value>70</value>
<value>69</value>
<value>74</value>
<value>82</value>
<value>87</value>
<value>87</value>
</temperature>
<temperature type="dew point" units="Fahrenheit" time-layout="k-p3h-n9-1">
<name>Dew Point Temperature</name>
<value>56</value>
<value>59</value>
<value>61</value>
<value>63</value>
<value>64</value>
<value>67</value>
<value>68</value>
<value>68</value>
<value>67</value>
</temperature>
<temperature type="apparent" units="Fahrenheit" time-layout="k-p3h-n9-1">
<name>Apparent Temperature</name>
<value>82</value>
<value>79</value>
<value>72</value>
<value>70</value>
<value>69</value>
<value>74</value>
<value>85</value>
<value>91</value>
<value>90</value>
</temperature>
The temperatures displayed are in 3hour periods. I figured to change the period parameter to 'Weather at a glance'. Indeed I got a time period of 24 hours, but the only parameter displayed in that period was 'Hazards'.
Obviously, each parameter is tied to a time period, but is it possible to get temperature in a 1hour time period instead of 3hour somehow?
If you are open for json then there are plenty of ways to do it.
I would recommend one service named apixu.com. They offer hour by hour weather and they also have a libraries in different programming languages.
https://github.com/apixu?tab=repositories
Indeed there is a NWS web service that displays data per hour. Just took some time to find it.
http://forecast.weather.gov/MapClick.php?lat=42.357700&lon=-71.060500&FcstType=digitalDWML

Date timezone conversion socket.io

I'm writing a chat program using node.js and socket.io. When a user sends a message, I'd like the time at which they sent it to be emitted. Instead of the Date data being in the timezone of the person who sent it, however, I'd like it to be converted to the timezones of the respective recievers. Will JavaScript take care of this automatically, or is it something I need to fix?
socket.emit('chat', {
message: 'message',
date: new Date()
}
You can simply send the UTC value from the Date back to your server and up to another client. Even if they have different time zones, the local client will convert from the UTC value to that time zone when the Date is displayed.
It is important that the date is sent as UTC and not in the local time zone.
This can be an integer number (which will be milliseconds since 1/1/1970 UTC), obtained from .getTime(). All browsers support this, but it's not a very human readable format.
It can also be a string in ISO8601/RFC3339 format at UTC, such as 2013-06-26T15:40:00Z, which can be obtained by .toISOString().
What you can't do is just pass a Date object directly, as you showed in your sample. Socket.io will just call .toString() on it. That will end up sending a human readable RFC822 formatted string with the local time zone - not the UTC value that you want.
Javascript date object in different locale and timezone
This answer looks good. Store all your dates as UTC and then translate to receivers time zone.

Reminder Service in C#.Net 4.0 using UTC Time

I have a Windows Service that runs on my
Texas origin Server Central Time.
This will check for all active reminders and compares the reminder time that user wants and send out reminder if it matches with user required time.
Scenarios
User is from EST
User set up a reminder for *1:25 PM * using UI via my website
On submit, my C# business logic converts this time to UTC before storing in my database. That will become '18:25:00'
My Business logic will pull all Active reminders from DB
And checks for reminder time if current UTC time and Reminder setup time diffrence is less then 5 mins, then it will send notification to that customer.
this is how my logic written
DateTime CurrentDate = DateTime.Now.ToUniversalTime();
TimeSpan currentTime = DateTime.Now.ToUniversalTime().TimeOfDay;
if (Reminder.DailyReminders.Any(x => currentTime.Subtract(x.ReminderTime).TotalMinutes < 5
&& currentTime.Subtract(x.ReminderTime).TotalMinutes > 0))
{
if (Reminder.ReminderMedhodID.Equals(1))
_email.ComposeEmail(Reminder);
}
My Problem is
*currentTime* is always 1 hour behind to user requested reminder time SO my reminders are going out 1 hour late.
Note : currentTime is from below
TimeSpan currentTime = DateTime.Now.ToUniversalTime().TimeOfDay;
I am not sure if this is the best way to handle this requirement. considering this is one of the way, can any on help how to fix this issue?
Thanks to peter's answer
Can any one help me how to take user input time with Daylight consideration
This what i have so far
public TimeSpan ConvertToUTCTime(string dateStr)
{
DateTime localDateTime = DateTime.Parse(dateStr); // Local .NET timeZone.
DateTime utcDateTime = localDateTime.ToUniversalTime();
string clTimeZoneKey = TimeZone.CurrentTimeZone.StandardName;
TimeZoneInfo clTimeZone = TimeZoneInfo.FindSystemTimeZoneById(clTimeZoneKey);
DateTime clDateTime = TimeZoneInfo.ConvertTimeFromUtc(utcDateTime, clTimeZone);
if (clTimeZone.IsDaylightSavingTime(localDateTime))
{
// Get DayLight local time in UTC
// Yet to be implemented
}
return clDateTime.TimeOfDay;
}
I got this worked using this
http://msdn.microsoft.com/en-us/library/system.globalization.daylighttime.aspx
Ummm...we are currently using Daylight Saving Time in most of the U.S. (though there are some portions of Indiana that did/do use EST?) Since EDT is one hour ahead of EST, your logic is correct. It is the input (EST) that is incorrect.

Resources