import requests
url = "https://platform.ankra.app/api/v1/clusters/{cluster_id}/kubernetes/logs/query"
payload = {
"start": "<string>",
"end": "<string>",
"since": "<string>",
"search": "<string>",
"raw_query": "<string>",
"direction": "<string>",
"namespaces": ["<string>"],
"pods": ["<string>"],
"containers": ["<string>"],
"source": "auto",
"limit": 123,
"include_record": False
}
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({
start: '<string>',
end: '<string>',
since: '<string>',
search: '<string>',
raw_query: '<string>',
direction: '<string>',
namespaces: ['<string>'],
pods: ['<string>'],
containers: ['<string>'],
source: 'auto',
limit: 123,
include_record: false
})
};
fetch('https://platform.ankra.app/api/v1/clusters/{cluster_id}/kubernetes/logs/query', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://platform.ankra.app/api/v1/clusters/{cluster_id}/kubernetes/logs/query \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"start": "<string>",
"end": "<string>",
"since": "<string>",
"search": "<string>",
"raw_query": "<string>",
"direction": "<string>",
"namespaces": [
"<string>"
],
"pods": [
"<string>"
],
"containers": [
"<string>"
],
"source": "auto",
"limit": 123,
"include_record": false
}
'{
"provider": "<string>",
"source": "<string>",
"note": "<string>",
"entries": [
{
"timestamp": "<string>",
"line": "<string>",
"labels": {},
"record": {}
}
],
"total_hits": 123,
"total_hits_relation": "eq",
"truncated": true,
"start": "<string>",
"end": "<string>",
"cluster_attribution": {}
}{
"detail": "<string>",
"error_code": "<string>"
}Search cluster logs
Searches the cluster’s log history in its connected log store or Ankra hosted logs, filtered by time, namespaces, pods, containers and text. Hosted reads stay pinned to the organisation and cluster. Requires kubernetes.logs on the cluster.
import requests
url = "https://platform.ankra.app/api/v1/clusters/{cluster_id}/kubernetes/logs/query"
payload = {
"start": "<string>",
"end": "<string>",
"since": "<string>",
"search": "<string>",
"raw_query": "<string>",
"direction": "<string>",
"namespaces": ["<string>"],
"pods": ["<string>"],
"containers": ["<string>"],
"source": "auto",
"limit": 123,
"include_record": False
}
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({
start: '<string>',
end: '<string>',
since: '<string>',
search: '<string>',
raw_query: '<string>',
direction: '<string>',
namespaces: ['<string>'],
pods: ['<string>'],
containers: ['<string>'],
source: 'auto',
limit: 123,
include_record: false
})
};
fetch('https://platform.ankra.app/api/v1/clusters/{cluster_id}/kubernetes/logs/query', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://platform.ankra.app/api/v1/clusters/{cluster_id}/kubernetes/logs/query \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"start": "<string>",
"end": "<string>",
"since": "<string>",
"search": "<string>",
"raw_query": "<string>",
"direction": "<string>",
"namespaces": [
"<string>"
],
"pods": [
"<string>"
],
"containers": [
"<string>"
],
"source": "auto",
"limit": 123,
"include_record": false
}
'{
"provider": "<string>",
"source": "<string>",
"note": "<string>",
"entries": [
{
"timestamp": "<string>",
"line": "<string>",
"labels": {},
"record": {}
}
],
"total_hits": 123,
"total_hits_relation": "eq",
"truncated": true,
"start": "<string>",
"end": "<string>",
"cluster_attribution": {}
}{
"detail": "<string>",
"error_code": "<string>"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The cluster.
Body
Read auto (connected source first, hosted only when no source is connected), connected only, or Ankra hosted logs only. An explicit choice never switches on empty results or failure and does not alter the saved connection.
auto, connected, ankra_hosted Also return each entry's record: the application's own structured line as stored, without the log shipper's envelope (Kubernetes metadata, stream, cluster and tenant fields). Elasticsearch/OpenSearch and VictoriaLogs only; long values are cut.
Response
Scoped log search results.