I'm trying to parse email date field to Logstash #timestamp field:
Example email date filed: Mon, 28 May 2018 15:53:54 +0100
Logstash config: filter {date {match => ["date", "E, d MMMM yyyy HH:mm:ss Z"]}
Result #timestamp: May 28th 2018, 14:53:54 +0000
As you can see Logstash haven't added +0100.
Could you please tell me where I have done wrong?
Related
I'm trying to have a single (if possible) event or multiple events linked to each other with multiple dates and hours. So that the user can have a delete all option related to this event(s).
Original hours in postman body:
"start": {
"dateTime": "2022-09-01T09:00:00+02:00",
"timeZone": "Europe/Brussels"
},
"end": {
"dateTime": "2022-09-01T17:00:00+02:00",
"timeZone": "Europe/Brussels"
},
"Recurring" hours:
2022 09 02 10:00:00 → 2022 09 02 15:00:00
2022 09 03 10:00:00 → 2022 09 03 19:00:00
I tried to use the recurrence with RDATE;VALUE=DATE:20220902T100000/20220902T150000,20220903T100000/20220903T190000, tried to use some combination of UNTILL and the previous value but this will always take the original hours.
Then I found the related-to documentation but I'm unable to link the first event to the rest as the documentation uses an email and not an id which is what I would expect.
The following is an example of this property:
RELATED-TO:jsmith.part7.19960817T083000.xyzMail#example.com
RELATED-TO:19960401-080045-4000F192713-0052#example.com
Is there a way to have a single event with multiple dates and multiple hours or are multiple events the only way?
How would I begin "linking" them together so the user can have the delete all option?
Ok so I have this moment object I'm looking at in Developer Tools:
amoment: Moment
_a: (7) [2017, 4, 21, 20, 15, 0, 0]
_d: Sun May 21 2017 15:15:00 GMT-0500 (Central Daylight Time) {}
_f: "MM/DD/YYYY h:mm A"
_i: "5/21/2017 8:15:00 PM"
_isAMomentObject: true
_isUTC: true
_isValid: true
_locale: Locale {_calendar: {…}, _longDateFormat: {…}, _invalidDate: "Invalid date", ordinal: ƒ, _dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/, …}
_offset: -180
_pf: {empty: false, unusedTokens: Array(0), unusedInput: Array(1), overflow: -1, charsLeftOver: 3, …}
_strict: false
_z: Zone {name: "America/Halifax", abbrs: Array(229), untils: Array(229), offsets: Array(229), population: 390000}
__proto__: Object
As you can see, the text representation is 5/21/2017 8:15:00 pm. This is the correct time in UTC and I notice "_isUTC" is "true".
The _d property shows that datetime in CDT, where I am now.
The _z property shows a Zone object set to "America/Halifax"--this is dynamically set elsewhere, but also correct.
I would like to return a moment reading "5/21/2017 5:15:00 pm" because that's what that datetime is in "America/Halifax."
There are so many moment.js functions I haven't found the right way to do this.
All of the fields that begin with underscores (_) are meant to be internal to Moment. You should not be using them at all. More on this here, and here.
To output a string in a particular format from a moment object, use the format function. For example:
yourMomentObject.format("M/D/YYYY h:mm:ss a") //=> "5/21/2017 5:17:00 pm"
I ended up doing new Date(amoment.format('YYYY-MM-DDTHH:mm:ss+00:00')); which worked for my purposes. The zone kept wanting to render the date in that zone, so I just had to omit it.
I have the following data in a file :
Message-ID: <123.juii#jkk>
Date: Wed, 9 Mar 2002 16:12:51 -0800 (CST)
From: jennifer.mcquade#enron.com
To: abc#ron.com, def#ron.com, ghi#ron.com,
gty#ron.com, mkl#ron.com
Subject: Sales details
Please find attached the latest sales information
let me know what you can do.
Thanks,
jLian
I want to extract the contents of the e-mail only. So I tried to extract the lines which don't have ":" character. I am not able to find any other way. But this will result in :
gty#ron.com, mkl#ron.com
Please find attached the latest sales information and
let me know what you can do.
Thanks,
jLian
Where only 2nd line is the message content.
library("stringr")
rawData = file("mail1","r")
while(TRUE){
line = readLines(rawData,n=1)
if(length(line)==0){
break
}
if(!(str_detect(line,":")))
print(line)
}
See if this here works:
data:
mail<-
'Message-ID: <123.juii#jkk>
Date: Wed, 9 Mar 2002 16:12:51 -0800 (CST)
From: jennifer.mcquade#enron.com
To: abc#ron.com, def#ron.com, ghi#ron.com,
gty#ron.com, mkl#ron.com
Subject: Sales details
Please find attached the latest sales information
let me know what you can do.
Thanks,
jLian'
code:
cat(
sub(".*Subject:.*?\n\n","",mail)
)
result:
#Please find attached the latest sales information
#let me know what you can do.
#Thanks,
#jLian
In order to use my solution effectively, read every Mail as a multiline string to list element.
listOfMails <- list(mail, mail, mail) #as many as you have.
fun1<-
function(m) { sub(".*Subject:.*?\n\n","",m) }
onlyContent<-
lapply(listOfMails,fun1)
I want to change the default timestamp format on rsyslog. Currently I am running on RHEL7.2. Syslog version 7.4.7. Now the default format is the following:
Mar 23 09:35:30 localhost DEB [9125:<console>.<module>:2] debug info
Inside rsyslog.conf I have define the following template:
$template Mytemplate,"%timegenerated% %HOSTNAME% %syslogseverity-text:0:3:uppercase% %msg%\n"
How can I change the format to this YYYY-MM-dd H:i:s ?
The modification is the following:
$template Mytemplate,"%$year%-%$month%-%$day% %timegenerated:12:19:date-rfc3339% %HOSTNAME% %syslogseverity-text:0:3:uppercase% %msg%\n"
I'm not sure if you guys test like this, but I'm a TDD guy and keep stumbling into wierd stuff. The timestamps are converted somehow by DJ, or the time zone... I don't know. Test example follows
I'm using delayed_job 2.0.3
data = {:value => 0.856, :timestamp => Time.zone.now}
job = MyMailer.send_later :send_values, data, emails
MyMailer.expects(:send_values).with(data, emails).once
job.payload_object.perform
class MyMailer
def self.send_values(data, emails)
end
end
OK, test expectation failure
unexpected invocation: MyMailer.send_values({:value => 0.856576407208833, :timestamp => Thu Nov 11 22:01:00 UTC 2010 (1289512860.94962 secs)}, ..
unsatisfied expectations:
- expected exactly once, not yet invoked: MyMailer.send_values({:value => 0.856576407208833, :timestamp => Thu, 11 Nov 2010 23:01:00 CET +01:00}...
with datetime it's similar, DateTime.now instead of Time.zone.now
got :timestamp => Thu Nov 11 23:13:33 +0100 2010 (1289513613.0 secs)
expected :timestamp => 2010-11-11T23:13:33+01:00
What's happening? How can I control it (do I want to)?
I thought I had the answer to this when I first saw the question. But I don't anymore, so here is a guess:
Since Time.zone.now, DateTime.now and Time.now are slightly different from each other, and Zone is something Rails has created (I think), could it be that ruby somewhere in your testing framework misses out on the zone-thingy? Time.zone.now.to_datetime has rescued me from similar stuff before. It lets you use zone, and you get the same format as DateTime.now witch lacks DateTime.zone.now.
Try: data = {:value => 0.856, :timestamp => Time.zone.now.to_datetime}