GET logstash-ramesh-2020.09.16/_search
{
"query": {
"bool": {
"must_not": [
{
"regexp": {
"src_ip.raw": {
"value": "^(?:10|127|172\\.(?:1[6-9]|2[0-9]|3[01])|192\\.168)\\..*"
}
}
}
]
}
},
"_source": [
"src_ip"
]
}
How to fetch only Public or Private IP?
Thanks in Advance !
warkolm
(Mark Walkom)
September 15, 2020, 9:02pm
2
Thanks for your quick response.
But I need to filter only public IP
eg.,
GET logstash-ramesh-2020.09.16/_search
{
"query": {
"bool": {
"must_not": [
{
"regexp": {
"src_ip.raw": {
"value": "^(?:10|127|172\\.(?:1[6-9]|2[0-9]|3[01])|192\\.168)\\..*"
}
}
}
]
}
},
"_source": [
"src_ip"
]
}
spinscale
(Alexander Reelsen)
September 16, 2020, 9:53am
4
You can also try to use the ip
data type, if your queries can be expressed using CIDR
DELETE my-index
PUT my-index
{
"mappings": {
"properties": {
"ip_addr": {
"type": "ip"
}
}
}
}
PUT my-index/_bulk?refresh
{"index":{}}
{"ip_addr":"192.168.1.1"}
{"index":{}}
{"ip_addr":"1.1.1.1"}
{"index":{}}
{"ip_addr":"10.5.6.7"}
GET my-index/_search
{
"query": {
"terms": {
"ip_addr": [
"192.168.0.0/16",
"127.16.0.0/16",
"10.0.0.0/8"
]
}
}
}
2 Likes
system
(system)
Closed
October 14, 2020, 10:28am
6
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.