Timestamp manipulation

This support forum board is for support questions relating to Nagios Log Server, our solution for managing and monitoring critical log data.
Locked
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

Timestamp manipulation

Post by SteveBeauchemin »

My IIS logs in NLS are using the log scrape "date" and the @timestamp is not using the date and time from the log line. It is using the collection time. It is not using the true event time.

The date field is like this 2019-07-08
The time field is like this 17:03:43

I am trying to use this filter

Code: Select all

  mutate {
    add_field => ["ts", "%{date} %{time}"]
  }
  date {
    match => ["ts", "yyyy-MM-dd HH:mm:ss"]
    target => "@timestamp"
  }
  mutate {
    remove_field => ["ts", "date", "time", "EventReceivedTime"]
  }
When I do this, the IIS data just stops coming in.
If I remove the date {} section it shows up again.

Is there a preferred syntax for date?

Please advise.

Thanks

Steve B
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

Re: Timestamp manipulation

Post by SteveBeauchemin »

Strange but true...

If I mutate / convert the date to a 'string' the @timestamp works properly.

I took 2 fields and combined them to create a pseudo time stamp. To convert it to the real @timestamp it needs to be a string first.

So this fixed it.

Code: Select all

  mutate {
    add_field => ["ts", "%{date} %{time}"]
  }
  mutate {
    convert => { "ts" => "string" }
  }
  date {
    match => ["ts", "yyyy-MM-dd HH:mm:ss"]
    target => "@timestamp"
  }
This can be closed.

Thanks

Steve B
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Timestamp manipulation

Post by cdienger »

What does the input configuration look like? Are there any other filters for this data? Behavior like this is usually due to a parsing issue, but the config you provided looks good.

You can enable debug logging by editing /etc/init.d/logstash and changing line 64 from:

Code: Select all

DAEMON_OPTS="agent -f ${LS_CONF_DIR} -l ${LS_LOG_FILE} ${LS_OPTS}"
to:

Code: Select all

DAEMON_OPTS="agent -f ${LS_CONF_DIR} -l ${LS_LOG_FILE} ${LS_OPTS} --debug"
and then restart the service:

Code: Select all

systemctl daemon-reload
service logstash restart
Let it run this way just long enough to allow events to come in and hit this filter, then disable debugging, and gather the /var/logstash/logstash.log.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

Re: Timestamp manipulation

Post by SteveBeauchemin »

So, my timestamp problem is okay now. Once I turned it into a string.

But. I am having some trouble getting ruby to work in a filter.
I am not so sure that the new config is getting read properly after an update is committed.

I say that because I have a line that removes 4 unused fields. Not in ruby. The previous version of config removed 3 of them. I added to the same line a 4th. Yet the 3 are removed but the 4th is not.

So, I'm still trying to get a good understanding of how it all works. If I update a config, it updates on all 4 servers. And then I see the effect in the GUI sometimes. Not always. As in this case where I am expecting 4 fields to be removed but only 3 are gone.

So. You just now provided a way to debug. I will start using that tomorrow and see if I can get this squared away.

I am also logging in to only one specific server of the 4 to do this work.

Thanks

Steve B
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Timestamp manipulation

Post by cdienger »

Sounds good. Keep us posted.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

Re: Timestamp manipulation

Post by SteveBeauchemin »

We should close this. I'll start a new thread for my other items. The timestamps are good now.

Thanks

Steve B
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Timestamp manipulation

Post by scottwilkerson »

SteveBeauchemin wrote:We should close this. I'll start a new thread for my other items. The timestamps are good now.

Thanks

Steve B
Great!

Locking
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked