Access to filter values in script kibana

In kibana want to use filter bar value in my script (Advance section). Is there a way or a function to access the filter value in script? or any solution ?

Hi, where are you putting in this script? What "Advanced section" is this about? Can you provide a screenshot or an example of what you are trying to do with the search?

Hi. Thanks for your reply.
I mean when a want to create visualization like area plot(in kibana) in the right menu there is advance option witch can used for scripting. beside, in the filter bar on the top of page, we can apply the specific filter. I want to access the value of filter bar(witch user enter lately) for scripting in advance option. is there a variable or function or anything else to access filter value in scripting ???

Hi

  1. "Is there a way or a function to access the filter value in script" - i think no
  2. "or any solution ?" - if you provide more information about task, may be....

task i mean what do you want get, or what problem you solve...

Hi. Thanks for your replay and attention.
I have two filed for ip range. one filed show start range and another show end of range. when the user enter a ip value in the filter bar, i want to show documents witch support the ip(the ip value be in between two fields ip )

Oh...
If I had such a task, I would do the following:
If its possible...

  1. create index with mapping ip_range:
    PUT my-index { "mappings": { "properties": { "ip_range": { "type": "ip_range" } } } }
  2. Using bash or another tool get CIDR from start ip + end ip and reindex docs to new index.
  3. Search with kibana like this
    ip_range: "192.168.1.34"

Thanks for your time.
Actually i have already CIDR but the problem is that kibana do not fully support of ip
-range and cant comper ip(from filter) with a value of ip_range fild. the only way i find is add keyword type to ip_range type which becoming text and not supported ip type for compering.

What version Elasticsearch, Kibana you use?
If i right undestand problem....
I test in 7.11.1

PUT my-index
{
  "mappings": {
    "properties": {
      "ip_range": {
        "type": "ip_range"
      }
    }
  }
}

PUT my-index/_doc/1
{
  "ip_range": "192.168.1.0/24"
}

PUT my-index/_doc/2
{
  "ip_range": "192.168.1.0/30"
}

PUT my-index/_doc/3
{
  "ip_range": "10.1.1.1/24"
}

Check with query:

GET my-index/_search
{
  "query": {
    "term": {
      "ip_range": {
        "value": "192.168.1.3"
      }
    }
  }
}

Ok return 2 hits:

"hits" : [
  {
    "_index" : "my-index",
    "_type" : "_doc",
    "_id" : "1",
    "_score" : 1.0,
    "_source" : {
      "ip_range" : "192.168.1.0/24"
    }
  },
  {
    "_index" : "my-index",
    "_type" : "_doc",
    "_id" : "2",
    "_score" : 1.0,
    "_source" : {
      "ip_range" : "192.168.1.0/30"
    }
  }
]

Then i add index pattern and use filter on panel:

and i understand... may be...))
You need use only this button??
image
Why not text filter as in the first screenshot...

Hi.
I am so thankful for your time and kindness.
you right its completely works. but in kibana the problem arise..
in kibana when i want to create "index pattern" from this index the type of "ip_range" will be unknown and when i want to visualize, couldn't see ip_range field in metric or bucket sections. apparently until now kibana doesn't support ip_range type.
thanks so much

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