# \_split\_type\_failure

**URL:** https://discuss.elastic.co/t/split-type-failure/256959
**Category:** Logstash
**Created:** [November 28, 2020, 5:52pm UTC](https://discuss.elastic.co/t/split-type-failure/256959 "2020-11-28T17:52:31Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![salma\_widiarti](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/salma_widiarti/32/78306_2.png) [@salma\_widiarti](https://discuss.elastic.co/u/salma_widiarti)
#### Post date: [November 28, 2020, 5:52pm UTC](https://discuss.elastic.co/t/split-type-failure/256959/1 "2020-11-28T17:52:31Z")

</div>

Hi all, i have config logstash like this

```auto
input {
    http_poller {
        urls => {
            users => {
                method => GET
                user => "user@gmail.com"
                password => "password"
                url => "https://api.id/api/report/product"
                headers => {
                    "Content-Type" => "application/json"
                    Authorization => "bearer token"
                }
            }   
        }
        request_timeout => 60
        schedule => { every => "20s"}
        codec => "json" 
        type => "Http_poller"  
    }
}

filter {
    split {
        field => "[result][data][products]"
    }
    split {
        field => "[result][data][products][loctypes]"
    }
}

output {
    elasticsearch {
        hosts => ["localhost:9200"]
        index => "products"
    }
    stdout {
        codec => rubydebug 
    }
}

```

and the result in discover kibana like this

 ![tes1](https://us1.discourse-cdn.com/elastic/original/3X/c/a/ca76dded701f8ce46bcf5355dfc0da0c2dd66fdf.jpeg)

Any one can help me?

---

<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: [November 28, 2020, 6:19pm UTC](https://discuss.elastic.co/t/split-type-failure/256959/2 "2020-11-28T18:19:40Z")

</div>

Only arrays and strings can be operated on by a split filter. So one or both of "[result][data][products]" and "[result][data][products][loctypes]" are of some other type. The logstash log will have messages to tell you that.

The event contains a [message] field which contains the text "error", which suggests your http\_poller is not working the way you expect.

---

<div class="post-metadata">

### Author: ![salma\_widiarti](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/salma_widiarti/32/78306_2.png) [@salma\_widiarti](https://discuss.elastic.co/u/salma_widiarti)
#### Post date: [November 28, 2020, 6:37pm UTC](https://discuss.elastic.co/t/split-type-failure/256959/3 "2020-11-28T18:37:28Z")

</div>

This is the data source form my API

```auto
"message": "success",
    "result": {
        "data": {
            "products": [
                {
                    "id": "id",
                    "code": "Code",
                    "brand": "Brand",
                    "loctypes": [
                        {
                            "description": "AD"
                        }
                    ],
                    "desc": "ADD",
                    "purchasecontractd": null,
                    "pods": [
                         {
                            "qty": 1
                        }
                    ],
                    "transferservice": null,
                    "balanceservice": null,
                    "prequisitionds": [
                        {
                            "qty": 1
                        }
                    ],
                    "categories": [
                        {
                            "desc": "ADS"
                        }
                    ],
                    "units": [],
                    "qty": 1,
                    "productattrs": [
                        {
                            "groupattr": 1
                        }
                    ],
                    "items": [],
                    "money": 10000,
                    "status": "available",
                    "createdAt": "2020-11-08T01:59:02.381Z",
                    "updatedAt": "2020-11-25T07:26:32.404Z"
                },

```

If i use the config it would be error.

```auto
filter {
    split {
        field => "[result][data][products]"
    }
    split {
        field => "[result][data][products][loctypes]"
    }
}

```

How to split the data to be like this?

```auto
                    "id": "id",
                    "code": "Code",
                    "brand": "Brand",
                    "loctypes": "AD"
                    "desc": "ADD",
                    "purchasecontractd": null,
                    "pods": 1
                    "transferservice": null,
                    "balanceservice": null,
                    "prequisitionds": 1
                    "categories": "ADS"
                    "units": "BC",
                    "qty": 1,
                    "productattrs": 1
                    "items": "items",
                    "money": 10000,
                    "status": "available",
                    "createdAt": "2020-11-08T01:59:02.381Z",
                    "updatedAt": "2020-11-25T07:26:32.404Z"

```

---

<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: [November 28, 2020, 6:50pm UTC](https://discuss.elastic.co/t/split-type-failure/256959/4 "2020-11-28T18:50:24Z")

</div>

> [@salma\_widiarti](#):
>
> This is the data source form my API
> 
> ```auto
> "message": "success",
> 
> ```

No, it is not. Look at the screen shot you posted. The message field contains "error", not "success".

If the response from the API looked the way you think it should then your split filters would work. You would then have to move things around with mutate filters like

```
    mutate {
        rename => {
            "[result][data][products][productattrs][0][groupattr]" => "[result][data][products][productattrs]"
            "[result][data][products][prequisitionds][0][qty]" => "[result][data][products][prequisitionds]"
        }
    }

```

---

<div class="post-metadata">

### Author: ![salma\_widiarti](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/salma_widiarti/32/78306_2.png) [@salma\_widiarti](https://discuss.elastic.co/u/salma_widiarti)
#### Post date: [November 30, 2020, 2:16am UTC](https://discuss.elastic.co/t/split-type-failure/256959/5 "2020-11-30T02:16:59Z")

</div>

Hello badger, i do your solution

> [@Badger](#):
>
> ```auto
> mutate {
> rename => {
> "[result][data][products][productattrs][0][groupattr]" => "[result][data][products][productattrs]"
> "[result][data][products][prequisitionds][0][qty]" => "[result][data][products][prequisitionds]"
> }
> }
> 
> ```

and the result like this

 ![resukt](https://us1.discourse-cdn.com/elastic/original/3X/b/9/b9e0ea6cd6689e413c5c1108062b31de42eaa2d1.png)

the message is succes, but why the tags is \_split\_type\_failure?

---

<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: [November 30, 2020, 3:26pm UTC](https://discuss.elastic.co/t/split-type-failure/256959/6 "2020-11-30T15:26:32Z")

</div>

Does the [result][date][products] field exist?

---

<div class="post-metadata">

### Author: ![salma\_widiarti](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/salma_widiarti/32/78306_2.png) [@salma\_widiarti](https://discuss.elastic.co/u/salma_widiarti)
#### Post date: [December 1, 2020, 4:03am UTC](https://discuss.elastic.co/t/split-type-failure/256959/7 "2020-12-01T04:03:44Z")

</div>

Hello Badger, i have 8 table API. But the table product not include to index pattern. And other tables are include to index pattern, the tags change to \_split\_type\_failure. I only use 1 index pattern to 8 table API, it is true or wrong?

---

<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: [December 29, 2020, 4:03am UTC](https://discuss.elastic.co/t/split-type-failure/256959/8 "2020-12-29T04:03:58Z")

</div>

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