# Create two timestamp

**URL:** https://discuss.elastic.co/t/create-two-timestamp/124932
**Category:** Logstash
**Created:** [March 21, 2018, 8:31am UTC](https://discuss.elastic.co/t/create-two-timestamp/124932 "2018-03-21T08:31:27Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![tharu85](https://avatars.discourse-cdn.com/v4/letter/t/e95f7d/32.png) [@tharu85](https://discuss.elastic.co/u/tharu85)
#### Post date: [March 21, 2018, 8:31am UTC](https://discuss.elastic.co/t/create-two-timestamp/124932/1 "2018-03-21T08:31:27Z")

</div>

I have following parse log and it has 2 types of log time and I need to build 2 timestamp using them.

```
{
"log_timestamp" => 2018-03-21T01:29:45.000Z,
         "year" => "2018",
          "day" => "Wed",
     "monthday" => "21",     
   "@timestamp" => 2018-03-21T06:59:45.482Z,
        "month" => "Mar",
         "time" => "06:59:45",
}

```

I tried to build a separate timestamp using "year", "month", "day" and "time" as below.

```
mutate {
	    add_field => ["trigger_timestamp", "%{year}-%{month}-%{day} %{time}"]
}

```

Finally I need to format that "trigger\_timestamp in to standard ISO8601 time and I do following format configuration.

```
 date {
	match => ["trigger_timestamp", "YYYY-MM-dd HH:mm:ss", "YYYY-MM-dd HH:mm:ss.ZZZ"]
	target => "trigger_timestamp"
}

```

And my full filter script is as below after grok pattern match.

```
   mutate {
	    add_field => ["trigger_timestamp", "%{year}-%{month}-%{day} %{time}"]
	}
	
	date {
		match => ["trigger_timestamp", "YYYY-MM-dd HH:mm:ss", "YYYY-MM-dd HH:mm:ss.ZZZ"]
		target => "trigger_timestamp"
	}
	
	date {
		match => ["log_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss"]
		target => "log_timestamp"
	}

```

When I execute above script I received following error.

```
[2018-03-21T13:41:36,666][ERROR][logstash.filters.date] Invalid setting for date 

```

filter plugin:

```
filter {
date {
  # This setting must be a string
  # Expected string, got ["log_timestamp", "trigger_timestamp"]
  target => ["log_timestamp", "trigger_timestamp"]
  ...
}
}
[2018-03-21T13:41:36,687][ERROR][logstash.agent] Cannot load an invalid 
configuration {:reason=>"Something is wrong with your configuration."}
[

```

Is this raise due to 2 date timestamps format config ?. Any idea to keep these 2 timestamp and fix this issue

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [April 18, 2018, 8:31am UTC](https://discuss.elastic.co/t/create-two-timestamp/124932/2 "2018-04-18T08:31:37Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
