# Parsing Wazuh archives.json file with Logstash

**URL:** <https://discuss.elastic.co/t/parsing-wazuh-archives-json-file-with-logstash/169935>\
**Category:** Logstash\
**Created:** [February 26, 2019, 3:56am UTC](https://discuss.elastic.co/t/parsing-wazuh-archives-json-file-with-logstash/169935 "2019-02-26T03:56:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![HaranKumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/harankumar/32/87594_2.png) [@HaranKumar](https://discuss.elastic.co/u/HaranKumar)\
**Post date:** [February 26, 2019, 3:56am UTC](https://discuss.elastic.co/t/parsing-wazuh-archives-json-file-with-logstash/169935/1 "2019-02-26T03:56:43Z")

</div>

Hello Team,

Might be json codec would have been discussed in the past , i tried googling and did not find relevant solution . so posting my query to get direct assistance from experts.

I have a file alerts.json and it gets parsed smoothly with codec=json. [Notable: I have a index template as wazuh-alerts-\*]

then I wanted to parse another json file archives.json which is generated by wazuh events.  
I am parsing archives.json with codec = json and using [Type] to segregate both alerts and archives so that i can get it in different indices.  
but below configuration gives me parsing error with Json. I get error as **":Json::ParserError: Unexpected character ('' (code 92)): was expecting double-quote to start field name"**

what am i missing ? Is it related to json file or indexing template/document type ? or something else ? I am new to logstash parsing.

# Wazuh - Logstash configuration file

## Local Wazuh Manager - JSON file input

input {  
file {  
type =\> "wazuh-alerts"  
path =\> "/var/ossec/logs/alerts/alerts.json"  
codec =\> "json"  
}  
file {  
type =\> "windows-events"  
path =\> "/var/ossec/logs/archives/archives.json"  
codec =\> "json"  
}  
}  
filter {  
if [data][srcip] {  
mutate {  
add\_field =\> ["@src\_ip", "%{[data][srcip]}" ]  
}  
}  
if [data][aws][sourceIPAddress] {  
mutate {  
add\_field =\> ["@src\_ip", "%{[data][aws][sourceIPAddress]}" ]  
}  
}  
}  
filter {  
geoip {  
source =\> "@src\_ip"  
target =\> "GeoLocation"  
fields =\> ["city\_name", "country\_name", "region\_name", "location"]  
}  
date {  
match =\> ["timestamp", "ISO8601"]  
target =\> "@timestamp"  
}  
mutate {  
remove\_field =\> ["timestamp", "beat", "input\_type", "tags", "count", "@version", "log", "offset", "type", "@src\_ip", "host"]  
}  
}  
output {  
if [type] == "wazuh-alerts"  
{  
elasticsearch {  
hosts =\> ["localhost:9200"]  
index =\> "wazuh-alerts-3.x-%{+YYYY.MM.dd}"  
document\_type =\> "wazuh"  
}  
} else {  
elasticsearch {  
hosts =\> ["localhost:9200"]  
index =\> "windows-events-%{+YYYY.MM.dd}"  
document\_type =\> "wazuh"  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [February 26, 2019, 12:27pm UTC](https://discuss.elastic.co/t/parsing-wazuh-archives-json-file-with-logstash/169935/2 "2019-02-26T12:27:48Z")

</div>

> [@HaranKumar](#):
>
> what am i missing ? Is it related to json file

Yes, it is saying the file does not contain valid JSON.

---

<div class="post-metadata">

**Author:** ![HaranKumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/harankumar/32/87594_2.png) [@HaranKumar](https://discuss.elastic.co/u/HaranKumar)\
**Post date:** [February 26, 2019, 12:43pm UTC](https://discuss.elastic.co/t/parsing-wazuh-archives-json-file-with-logstash/169935/3 "2019-02-26T12:43:58Z")

</div>

Thanks Badger. I created a custom index template contain index pattern for both [wazuh-alerts and windows-events] from wazuh index template.json

And then the logstash was able to parse it.

Not sure how. Now logs are parsed and visualised in Kibana with index i created.

---

<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:** [March 26, 2019, 12:43pm UTC](https://discuss.elastic.co/t/parsing-wazuh-archives-json-file-with-logstash/169935/4 "2019-03-26T12:43:59Z")

</div>

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