# Type string in a multiple input Http\_Poller for different Grok pattern

**URL:** <https://discuss.elastic.co/t/type-string-in-a-multiple-input-http-poller-for-different-grok-pattern/211481>\
**Category:** Logstash\
**Created:** [December 11, 2019, 2:38pm UTC](https://discuss.elastic.co/t/type-string-in-a-multiple-input-http-poller-for-different-grok-pattern/211481 "2019-12-11T14:38:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kamalesh](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@kamalesh](https://discuss.elastic.co/u/kamalesh)\
**Post date:** [December 11, 2019, 2:38pm UTC](https://discuss.elastic.co/t/type-string-in-a-multiple-input-http-poller-for-different-grok-pattern/211481/1 "2019-12-11T14:38:36Z")

</div>

Hi All,

I am trying to using multiple Url's for the http\_poller and need to use a different Grok patterns for each of the Url's  
I am aware that i can make use of type string in the Input plugins and make Grok patterns using 'If' condition , if it matches the type.  
I tried to built with the below sample file ,Provide me help on building it .

```auto
input {
    http_poller {
    urls => {
    url1 => "https://hedeededededje"
    type[url1] => "JVM_Memory"
    }
    }
    http_poller {
    urls => {
    url2 => "https://wwdwjjwhewkjek"
    type[url2] => "GC"
    }
    }
    request_timeout => 60
    user => "tttttt"
    password => "yyyyyy"
    request_timeout => 60
    schedule => { cron => "*/5 * * * *"}
    	codec => "json"
    	metadata_target => "http_metadata"

    }
    }
    filter {
    if type[url1] == "JVM_Memory"{
    split {
    terminator => "\n"
    field => "message"
    remove_field => "tags"
    }
    }
    if type[url2] == "GC" {
    split {
    terminator => "\n"
    field => "message"
    remove_field => "tags"
    }
    }
    }

```

---

<div class="post-metadata">

**Author:** ![yaauie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yaauie/32/23363_2.png) [@yaauie](https://discuss.elastic.co/u/yaauie)\
**Post date:** [December 11, 2019, 9:52pm UTC](https://discuss.elastic.co/t/type-string-in-a-multiple-input-http-poller-for-different-grok-pattern/211481/2 "2019-12-11T21:52:09Z")

</div>

I think you have two options.

1. Use a single http\_poller input, and use the request metadata from each event (e.g., the name of the url used to generate the event) later in processing to determine which grok patterns to apply
2. Use separate http\_poller inputs for your separate data sources, tagging events created by each with a type, using the type of each event later in processing to determine which grok patterns to apply

## Single Input

If all of your URLs share credentials, pass back data that can be handled by the same codec, and should run on the same schedule, you may be best suited to share a single input.

The `name` of the URL is added to the metadata of the resulting event, and you can use this in your pipeline:

```auto
input {
  http_poller {
    urls => {
      "JVM_Memory" => "https://hedeededededje"
      "GC" => "https://wwdwjjwhewkjek"
    }
    user => "tttttt"
    password => "yyyyyy"
    request_timeout => 60
    schedule => { every => "5m"}
    metadata_target => "http_metadata"
  }
}
filter {
  if [http_metadata][name] == "JVM_Memory" {
    # ...
  } else if [http_metadata][name] == "GC" {
    # ...
  }
}

```

## Multiple Inputs

If the results _cannot_ be processed by the same codec, or if you want to run them at different schedules or require separate credentials, you can use multiple inputs, tagging each with the `type`, and then use the event's `type` later in the pipeline:

```auto
input {
  http_poller {
    type => "JVM_Memory"
    urls => { "JVM Memory" => "https://hedeededededje" }
    user => "tttttt"
    password => "yyyyyy"
    request_timeout => 60
    schedule => { every => "5m"}
    metadata_target => "http_metadata"
  }
  http_poller {
    type => "GC"
    urls => { "GC" => "https://wwdwjjwhewkjek" }
    user => "tttttt"
    password => "yyyyyy"
    request_timeout => 60
    schedule => { every => "5m"}
    metadata_target => "http_metadata"
  }
}
filter {
  if [type] == "JVM_Memory" {
    # ...
  } else if [type] == "GC" {
    # ...
  }
}

```

---

<div class="post-metadata">

**Author:** ![kamalesh](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@kamalesh](https://discuss.elastic.co/u/kamalesh)\
**Post date:** [December 23, 2019, 10:25am UTC](https://discuss.elastic.co/t/type-string-in-a-multiple-input-http-poller-for-different-grok-pattern/211481/3 "2019-12-23T10:25:50Z")

</div>

> [@yaauie](#):
>
> [http\_metadata][name]

Can you please let me know what i need add or replace with '[name]' provided above

Regards,  
Kamaleshwar

---

<div class="post-metadata">

**Author:** ![yaauie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yaauie/32/23363_2.png) [@yaauie](https://discuss.elastic.co/u/yaauie)\
**Post date:** [January 9, 2020, 5:10pm UTC](https://discuss.elastic.co/t/type-string-in-a-multiple-input-http-poller-for-different-grok-pattern/211481/4 "2020-01-09T17:10:10Z")

</div>

> [@yaauie](#):
>
> `metadata_target => "http_metadata"`

In the http\_poller input, you can specify _where_ the metadata is placed (in my example I placed it in a key `http_metadata`). The input is also configured to hit one or more named URLs with a `urls` directive (e.g., `"JVM_Memory" => "https://hedeededededje"` and `"GC" => "https://wwdwjjwhewkjek"`)

Once the http\_poller input has been configured as such, each event that it generates will include several useful subkeys, including `[http_metadata][name]` with the name of the URL (in this case `JVM_Memory` or `GC`).

---

<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:** [February 6, 2020, 5:10pm UTC](https://discuss.elastic.co/t/type-string-in-a-multiple-input-http-poller-for-different-grok-pattern/211481/5 "2020-02-06T17:10:11Z")

</div>

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