aggregate detectors
curl --request POST \
--url https://api.example.com/api/v1/detector/aggregation \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"agg": [
{
"func": [
"count",
"1"
]
}
],
"where": "field1='value' and field2<>'value2'",
"groupBy": [
"<string>"
],
"sort": [
{
"field": "timestamp"
}
],
"from": 0,
"size": 10
}
EOFimport requests
url = "https://api.example.com/api/v1/detector/aggregation"
payload = {
"agg": [{ "func": ["count", "1"] }],
"where": "field1='value' and field2<>'value2'",
"groupBy": ["<string>"],
"sort": [{ "field": "timestamp" }],
"from": 0,
"size": 10
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
agg: [{func: ['count', '1']}],
where: 'field1=\'value\' and field2<>\'value2\'',
groupBy: ['<string>'],
sort: [{field: 'timestamp'}],
from: 0,
size: 10
})
};
fetch('https://api.example.com/api/v1/detector/aggregation', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v1/detector/aggregation",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'agg' => [
[
'func' => [
'count',
'1'
]
]
],
'where' => 'field1=\'value\' and field2<>\'value2\'',
'groupBy' => [
'<string>'
],
'sort' => [
[
'field' => 'timestamp'
]
],
'from' => 0,
'size' => 10
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/detector/aggregation"
payload := strings.NewReader("{\n \"agg\": [\n {\n \"func\": [\n \"count\",\n \"1\"\n ]\n }\n ],\n \"where\": \"field1='value' and field2<>'value2'\",\n \"groupBy\": [\n \"<string>\"\n ],\n \"sort\": [\n {\n \"field\": \"timestamp\"\n }\n ],\n \"from\": 0,\n \"size\": 10\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/v1/detector/aggregation")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"agg\": [\n {\n \"func\": [\n \"count\",\n \"1\"\n ]\n }\n ],\n \"where\": \"field1='value' and field2<>'value2'\",\n \"groupBy\": [\n \"<string>\"\n ],\n \"sort\": [\n {\n \"field\": \"timestamp\"\n }\n ],\n \"from\": 0,\n \"size\": 10\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/detector/aggregation")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"agg\": [\n {\n \"func\": [\n \"count\",\n \"1\"\n ]\n }\n ],\n \"where\": \"field1='value' and field2<>'value2'\",\n \"groupBy\": [\n \"<string>\"\n ],\n \"sort\": [\n {\n \"field\": \"timestamp\"\n }\n ],\n \"from\": 0,\n \"size\": 10\n}"
response = http.request(request)
puts response.read_body[
"<unknown>"
]Detector Route
aggregate detectors
!!!IMPORTANT!!! Use with caution, because usage with JOIN can require aggregate with ‘distinct’
POST
/
api
/
v1
/
detector
/
aggregation
aggregate detectors
curl --request POST \
--url https://api.example.com/api/v1/detector/aggregation \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"agg": [
{
"func": [
"count",
"1"
]
}
],
"where": "field1='value' and field2<>'value2'",
"groupBy": [
"<string>"
],
"sort": [
{
"field": "timestamp"
}
],
"from": 0,
"size": 10
}
EOFimport requests
url = "https://api.example.com/api/v1/detector/aggregation"
payload = {
"agg": [{ "func": ["count", "1"] }],
"where": "field1='value' and field2<>'value2'",
"groupBy": ["<string>"],
"sort": [{ "field": "timestamp" }],
"from": 0,
"size": 10
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
agg: [{func: ['count', '1']}],
where: 'field1=\'value\' and field2<>\'value2\'',
groupBy: ['<string>'],
sort: [{field: 'timestamp'}],
from: 0,
size: 10
})
};
fetch('https://api.example.com/api/v1/detector/aggregation', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v1/detector/aggregation",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'agg' => [
[
'func' => [
'count',
'1'
]
]
],
'where' => 'field1=\'value\' and field2<>\'value2\'',
'groupBy' => [
'<string>'
],
'sort' => [
[
'field' => 'timestamp'
]
],
'from' => 0,
'size' => 10
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/detector/aggregation"
payload := strings.NewReader("{\n \"agg\": [\n {\n \"func\": [\n \"count\",\n \"1\"\n ]\n }\n ],\n \"where\": \"field1='value' and field2<>'value2'\",\n \"groupBy\": [\n \"<string>\"\n ],\n \"sort\": [\n {\n \"field\": \"timestamp\"\n }\n ],\n \"from\": 0,\n \"size\": 10\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/v1/detector/aggregation")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"agg\": [\n {\n \"func\": [\n \"count\",\n \"1\"\n ]\n }\n ],\n \"where\": \"field1='value' and field2<>'value2'\",\n \"groupBy\": [\n \"<string>\"\n ],\n \"sort\": [\n {\n \"field\": \"timestamp\"\n }\n ],\n \"from\": 0,\n \"size\": 10\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/detector/aggregation")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"agg\": [\n {\n \"func\": [\n \"count\",\n \"1\"\n ]\n }\n ],\n \"where\": \"field1='value' and field2<>'value2'\",\n \"groupBy\": [\n \"<string>\"\n ],\n \"sort\": [\n {\n \"field\": \"timestamp\"\n }\n ],\n \"from\": 0,\n \"size\": 10\n}"
response = http.request(request)
puts response.read_body[
"<unknown>"
]Authorizations
Authentication
Body
application/json
Aggregation functions with fields to aggregate. Represent SQL 'select' in 'group by' query. !!!IMPORTANT!!! Use with caution, because usage with JOIN can require aggregate with 'distinct'
Minimum array length:
1Show child attributes
Show child attributes
Example:
[{ "func": ["count", "1"] }]
Query string to search for data. Represent SQL 'where'
Example:
"field1='value' and field2<>'value2'"
Group by parameter for aggregation query
Sorting for the search
Show child attributes
Show child attributes
Starting document offset
Required range:
x >= 0Example:
0
The number of hits to return
Required range:
0 <= x <= 10000Example:
10
Response
200 - application/json
OK
⌘I