Logs
Post querylogs
Search for logs matching the provided query.
POST
/
query
/
logs
cURL
curl --request POST \
--url https://us-east.metoro.io/api/v1/query/logs \
--header 'Content-Type: application/json' \
--data '
{
"query": "count(logs{log_level=\"error\", service.name=\"/k8s/default/redis-test-app\"})",
"startTime": 1750147200000,
"endTime": 1750150800000,
"limit": 1000
}
'import requests
url = "https://us-east.metoro.io/api/v1/query/logs"
payload = {
"query": "count(logs{log_level=\"error\", service.name=\"/k8s/default/redis-test-app\"})",
"startTime": 1750147200000,
"endTime": 1750150800000,
"limit": 1000
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
query: 'count(logs{log_level="error", service.name="/k8s/default/redis-test-app"})',
startTime: 1750147200000,
endTime: 1750150800000,
limit: 1000
})
};
fetch('https://us-east.metoro.io/api/v1/query/logs', 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://us-east.metoro.io/api/v1/query/logs",
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([
'query' => 'count(logs{log_level="error", service.name="/k8s/default/redis-test-app"})',
'startTime' => 1750147200000,
'endTime' => 1750150800000,
'limit' => 1000
]),
CURLOPT_HTTPHEADER => [
"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://us-east.metoro.io/api/v1/query/logs"
payload := strings.NewReader("{\n \"query\": \"count(logs{log_level=\\\"error\\\", service.name=\\\"/k8s/default/redis-test-app\\\"})\",\n \"startTime\": 1750147200000,\n \"endTime\": 1750150800000,\n \"limit\": 1000\n}")
req, _ := http.NewRequest("POST", url, payload)
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://us-east.metoro.io/api/v1/query/logs")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"count(logs{log_level=\\\"error\\\", service.name=\\\"/k8s/default/redis-test-app\\\"})\",\n \"startTime\": 1750147200000,\n \"endTime\": 1750150800000,\n \"limit\": 1000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://us-east.metoro.io/api/v1/query/logs")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"count(logs{log_level=\\\"error\\\", service.name=\\\"/k8s/default/redis-test-app\\\"})\",\n \"startTime\": 1750147200000,\n \"endTime\": 1750150800000,\n \"limit\": 1000\n}"
response = http.request(request)
puts response.read_body{
"count": 2,
"logs": [
{
"timestamp": 1750147200000,
"log_level": "error",
"message": "Error connecting to Redis",
"attributes": {
"service.name": "/k8s/default/redis",
"container.id": "/k8s/default/redis-test-app-7f76f54f-2k8vx/redis-test-app",
"environment": "production",
"custom.attribute": "value"
}
},
{
"timestamp": 1750147260000,
"log_level": "error",
"message": "Terminating Redis connection",
"attributes": {
"service.name": "/k8s/default/redis",
"container.id": "/k8s/default/redis-test-app-7f76f54f-2k8vx/redis-test-app",
"environment": "production",
"custom.attribute": "value"
}
}
]
}{
"error": "Invalid alert configuration: missing required field"
}{
"error": "Invalid alert configuration: missing required field"
}{
"error": "Invalid alert configuration: missing required field"
}Body
application/json
Query to execute to retrieve logs
Request to query logs
MetoroQL query to execute to retrieve logs.
Unix timestamp in milliseconds to start querying logs from, inclusive. Shorter time ranges will lead to faster responses.
Unix timestamp in milliseconds to stop querying logs at, inclusive. Shorter time ranges will lead to faster responses.
Maximum number of logs to return. Defaults to 100 if not provided. Must be between 1 and 1000.
Was this page helpful?
⌘I
cURL
curl --request POST \
--url https://us-east.metoro.io/api/v1/query/logs \
--header 'Content-Type: application/json' \
--data '
{
"query": "count(logs{log_level=\"error\", service.name=\"/k8s/default/redis-test-app\"})",
"startTime": 1750147200000,
"endTime": 1750150800000,
"limit": 1000
}
'import requests
url = "https://us-east.metoro.io/api/v1/query/logs"
payload = {
"query": "count(logs{log_level=\"error\", service.name=\"/k8s/default/redis-test-app\"})",
"startTime": 1750147200000,
"endTime": 1750150800000,
"limit": 1000
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
query: 'count(logs{log_level="error", service.name="/k8s/default/redis-test-app"})',
startTime: 1750147200000,
endTime: 1750150800000,
limit: 1000
})
};
fetch('https://us-east.metoro.io/api/v1/query/logs', 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://us-east.metoro.io/api/v1/query/logs",
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([
'query' => 'count(logs{log_level="error", service.name="/k8s/default/redis-test-app"})',
'startTime' => 1750147200000,
'endTime' => 1750150800000,
'limit' => 1000
]),
CURLOPT_HTTPHEADER => [
"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://us-east.metoro.io/api/v1/query/logs"
payload := strings.NewReader("{\n \"query\": \"count(logs{log_level=\\\"error\\\", service.name=\\\"/k8s/default/redis-test-app\\\"})\",\n \"startTime\": 1750147200000,\n \"endTime\": 1750150800000,\n \"limit\": 1000\n}")
req, _ := http.NewRequest("POST", url, payload)
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://us-east.metoro.io/api/v1/query/logs")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"count(logs{log_level=\\\"error\\\", service.name=\\\"/k8s/default/redis-test-app\\\"})\",\n \"startTime\": 1750147200000,\n \"endTime\": 1750150800000,\n \"limit\": 1000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://us-east.metoro.io/api/v1/query/logs")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"count(logs{log_level=\\\"error\\\", service.name=\\\"/k8s/default/redis-test-app\\\"})\",\n \"startTime\": 1750147200000,\n \"endTime\": 1750150800000,\n \"limit\": 1000\n}"
response = http.request(request)
puts response.read_body{
"count": 2,
"logs": [
{
"timestamp": 1750147200000,
"log_level": "error",
"message": "Error connecting to Redis",
"attributes": {
"service.name": "/k8s/default/redis",
"container.id": "/k8s/default/redis-test-app-7f76f54f-2k8vx/redis-test-app",
"environment": "production",
"custom.attribute": "value"
}
},
{
"timestamp": 1750147260000,
"log_level": "error",
"message": "Terminating Redis connection",
"attributes": {
"service.name": "/k8s/default/redis",
"container.id": "/k8s/default/redis-test-app-7f76f54f-2k8vx/redis-test-app",
"environment": "production",
"custom.attribute": "value"
}
}
]
}{
"error": "Invalid alert configuration: missing required field"
}{
"error": "Invalid alert configuration: missing required field"
}{
"error": "Invalid alert configuration: missing required field"
}