import requests
url = "https://platform.ankra.app/api/v1/org/clusters/imported/{cluster_id}/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,
"cursor": "<string>",
"levels": [],
"exclude": {
"pods": ["<string>"],
"levels": [],
"words": ["<string>"]
}
}
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,
cursor: '<string>',
levels: [],
exclude: {pods: ['<string>'], levels: [], words: ['<string>']}
})
};
fetch('https://platform.ankra.app/api/v1/org/clusters/imported/{cluster_id}/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/org/clusters/imported/{cluster_id}/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,
"cursor": "<string>",
"levels": [],
"exclude": {
"pods": [
"<string>"
],
"levels": [],
"words": [
"<string>"
]
}
}
'{
"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": {},
"next_cursor": "<string>",
"kept_days": 123
}Search cluster log history in the selected store
Historical search of the cluster’s logs. An explicit source never replaces a saved connection or changes shipping. Hosted reads remain pinned to the organisation and cluster.
This is the API-token route. It requires kubernetes.logs on the cluster, and a token’s scopes narrow it.
import requests
url = "https://platform.ankra.app/api/v1/org/clusters/imported/{cluster_id}/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,
"cursor": "<string>",
"levels": [],
"exclude": {
"pods": ["<string>"],
"levels": [],
"words": ["<string>"]
}
}
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,
cursor: '<string>',
levels: [],
exclude: {pods: ['<string>'], levels: [], words: ['<string>']}
})
};
fetch('https://platform.ankra.app/api/v1/org/clusters/imported/{cluster_id}/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/org/clusters/imported/{cluster_id}/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,
"cursor": "<string>",
"levels": [],
"exclude": {
"pods": [
"<string>"
],
"levels": [],
"words": [
"<string>"
]
}
}
'{
"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": {},
"next_cursor": "<string>",
"kept_days": 123
}Authorizations
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 Keep only the lines of these level classes, each line in the class the volume counts it under (a severity field, or a level stated in the line's JSON or logfmt text; a line without a recognised severity is other). Empty or absent keeps every class. Refused with 400 for a class not listed here, beside raw_query, or when Loki is the store and the classes are not next to each other in the order error, warn, info, debug, other: Loki's line filters cannot say or.
100error, warn, info, debug, other Response
Scoped log search results