# I'm trying to get xewriter to deliver MSSQL logfiles to my elasticsearch

**URL:** <https://discuss.elastic.co/t/im-trying-to-get-xewriter-to-deliver-mssql-logfiles-to-my-elasticsearch/340826>\
**Category:** Logstash\
**Created:** [August 15, 2023, 10:43am UTC](https://discuss.elastic.co/t/im-trying-to-get-xewriter-to-deliver-mssql-logfiles-to-my-elasticsearch/340826 "2023-08-15T10:43:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![fribse](https://avatars.discourse-cdn.com/v4/letter/f/c67d28/32.png) [@fribse](https://discuss.elastic.co/u/fribse)\
**Post date:** [August 15, 2023, 10:43am UTC](https://discuss.elastic.co/t/im-trying-to-get-xewriter-to-deliver-mssql-logfiles-to-my-elasticsearch/340826/1 "2023-08-15T10:43:02Z")

</div>

In my logstash I have this to handle different logfiles with different index names:

```auto
output {
  elasticsearch {
    hosts => "https://elasticsearch:9200"
      index => "%{[fields][logtype]}-%{[@metadata][version]}-%{+YYYY.MM}"
      document_type => "%{[@metadata][type]}"
      cacert => "/usr/share/logstash/config/certs/ca/ca.crt"
      user => user
#logstash_internal
      password => password
  }
}

```

This works for all sorts of beats etc.  
xewriter uses tcp input, and I've tried getting that to name the indexes properly as well, but so far without luck.

The index name is not filled in, instead the index looks like this:

 ![billede](https://us1.discourse-cdn.com/elastic/original/3X/2/7/273432d42f03d23650722eb726f615abc3391fa4.png)  
How do I get this to name them correctly?  
As this is the only tcp-input I have I even tried using mutate to set the fields:

```auto
filter {
  if "tcp-input" in [type] {
    mutate {
      add_field => {
        "fields.logtype" => "sqllogs"
      }
    }
  }
}

```

And that made the 'fields.logtype' but it still didn't give the index a proper name  
Do I need to manipulate @metadata and version as well?

---

<div class="post-metadata">

**Author:** ![Rios](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rios/32/95745_2.png) [@Rios](https://discuss.elastic.co/u/Rios)\
**Post date:** [August 15, 2023, 1:16pm UTC](https://discuss.elastic.co/t/im-trying-to-get-xewriter-to-deliver-mssql-logfiles-to-my-elasticsearch/340826/2 "2023-08-15T13:16:30Z")

</div>

It seems you fields are empty. Have you converted the message to JSON?

> [@fribse](#):
>
> ```auto
> mutate {
> add_field => {
> "fields.logtype" => "sqllogs"
> }
> }
> 
> ```

You have a wrong nested field. Should be:

```
    "[fields][logtype]" => "sqllogs"

```

Which version of ELK are you using?

> - for elasticsearch clusters 8.x: no value will be used;
> - for elasticsearch clusters 7.x: the value of _\_doc_ will be used;
> - for elasticsearch clusters 6.x: the value of _doc_ will be used;

---

<div class="post-metadata">

**Author:** ![fribse](https://avatars.discourse-cdn.com/v4/letter/f/c67d28/32.png) [@fribse](https://discuss.elastic.co/u/fribse)\
**Post date:** [August 16, 2023, 7:15am UTC](https://discuss.elastic.co/t/im-trying-to-get-xewriter-to-deliver-mssql-logfiles-to-my-elasticsearch/340826/3 "2023-08-16T07:15:21Z")

</div>

Hi @Rios  
Thankyou for helping out.  
No, I didn't get the filter done, and I remembered this last night, so after adding that, bam, everything works 🙂  
I'm using 7.17.6 as far as I remember.  
So you were absolutely right!

---

<div class="post-metadata">

**Author:** ![Rios](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rios/32/95745_2.png) [@Rios](https://discuss.elastic.co/u/Rios)\
**Post date:** [August 16, 2023, 2:13pm UTC](https://discuss.elastic.co/t/im-trying-to-get-xewriter-to-deliver-mssql-logfiles-to-my-elasticsearch/340826/4 "2023-08-16T14:13:32Z")

</div>

So have you solved or not? If still have problems pls provide full message as text.

---

<div class="post-metadata">

**Author:** ![fribse](https://avatars.discourse-cdn.com/v4/letter/f/c67d28/32.png) [@fribse](https://discuss.elastic.co/u/fribse)\
**Post date:** [August 17, 2023, 9:21am UTC](https://discuss.elastic.co/t/im-trying-to-get-xewriter-to-deliver-mssql-logfiles-to-my-elasticsearch/340826/5 "2023-08-17T09:21:18Z")

</div>

It's solved, it was the JSON filter that solved it

---

<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:** [September 14, 2023, 9:21am UTC](https://discuss.elastic.co/t/im-trying-to-get-xewriter-to-deliver-mssql-logfiles-to-my-elasticsearch/340826/6 "2023-09-14T09:21:28Z")

</div>

Closed on September 14, 2023, 9:21am UTC

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