50 lines
1010 B
Plaintext
50 lines
1010 B
Plaintext
// This file is autogenerated, DO NOT EDIT
|
|
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
|
|
|
[source, js]
|
|
----
|
|
const response = await client.asyncSearch.submit({
|
|
index: "my-data-stream",
|
|
runtime_mappings: {
|
|
"source.ip": {
|
|
type: "ip",
|
|
script:
|
|
"\n String sourceip=grok('%{IPORHOST:sourceip} .*').extract(doc[ \"message\" ].value)?.sourceip;\n if (sourceip != null) emit(sourceip);\n ",
|
|
},
|
|
},
|
|
query: {
|
|
bool: {
|
|
filter: [
|
|
{
|
|
range: {
|
|
"@timestamp": {
|
|
gte: "now-2y/d",
|
|
lt: "now/d",
|
|
},
|
|
},
|
|
},
|
|
{
|
|
range: {
|
|
"source.ip": {
|
|
gte: "192.0.2.0",
|
|
lte: "192.0.2.255",
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
},
|
|
fields: ["*"],
|
|
_source: false,
|
|
sort: [
|
|
{
|
|
"@timestamp": "desc",
|
|
},
|
|
{
|
|
"source.ip": "desc",
|
|
},
|
|
],
|
|
});
|
|
console.log(response);
|
|
----
|