Query Kubernetes pod metrics
curl --request POST \
--url https://appsignal.com/api/v2/kubernetes/pods \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"site_id": "abc123",
"from": "2024-01-01T00:00:00Z",
"to": "2024-01-01T01:00:00Z",
"namespaces": [
"default",
"kube-system"
],
"state": "Running"
}
'import requests
url = "https://appsignal.com/api/v2/kubernetes/pods"
payload = {
"site_id": "abc123",
"from": "2024-01-01T00:00:00Z",
"to": "2024-01-01T01:00:00Z",
"namespaces": ["default", "kube-system"],
"state": "Running"
}
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({
site_id: 'abc123',
from: '2024-01-01T00:00:00Z',
to: '2024-01-01T01:00:00Z',
namespaces: ['default', 'kube-system'],
state: 'Running'
})
};
fetch('https://appsignal.com/api/v2/kubernetes/pods', 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://appsignal.com/api/v2/kubernetes/pods",
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([
'site_id' => 'abc123',
'from' => '2024-01-01T00:00:00Z',
'to' => '2024-01-01T01:00:00Z',
'namespaces' => [
'default',
'kube-system'
],
'state' => 'Running'
]),
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://appsignal.com/api/v2/kubernetes/pods"
payload := strings.NewReader("{\n \"site_id\": \"abc123\",\n \"from\": \"2024-01-01T00:00:00Z\",\n \"to\": \"2024-01-01T01:00:00Z\",\n \"namespaces\": [\n \"default\",\n \"kube-system\"\n ],\n \"state\": \"Running\"\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://appsignal.com/api/v2/kubernetes/pods")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"site_id\": \"abc123\",\n \"from\": \"2024-01-01T00:00:00Z\",\n \"to\": \"2024-01-01T01:00:00Z\",\n \"namespaces\": [\n \"default\",\n \"kube-system\"\n ],\n \"state\": \"Running\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://appsignal.com/api/v2/kubernetes/pods")
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 \"site_id\": \"abc123\",\n \"from\": \"2024-01-01T00:00:00Z\",\n \"to\": \"2024-01-01T01:00:00Z\",\n \"namespaces\": [\n \"default\",\n \"kube-system\"\n ],\n \"state\": \"Running\"\n}"
response = http.request(request)
puts response.read_body[
{
"timestamp": "2023-11-07T05:31:56Z",
"pod_name": "<string>",
"pod_namespace": "<string>",
"node_name": "<string>",
"cpu_usage_nano_cores": 123,
"cpu_usage_core_nano_seconds": 123,
"memory_rss_bytes": 123,
"memory_usage_bytes": 123,
"memory_working_set_bytes": 123,
"memory_page_faults": 123,
"memory_major_page_faults": 123,
"ephemeral_storage_used_bytes": 123,
"ephemeral_storage_capacity_bytes": 123,
"network_rx_bytes": 123,
"network_tx_bytes": 123,
"process_count": 123,
"phase": "Running",
"state": "Unknown",
"containers": [
{
"name": "<string>",
"status": "Running",
"exit_code": 123,
"reason": "<string>"
}
],
"pod_restart_count": 1,
"pod_uptime_seconds": 1
}
]{
"error": "<string>",
"message": "<string>",
"details": "<unknown>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>",
"suggestion": "<string>"
}{
"error": "<string>"
}Authorizations
Authorization: Bearer <token>
Body
Query for fetching detailed Kubernetes pod metrics.
Site identifier to query pods for.
Start of the time range (inclusive).
End of the time range (exclusive).
Optional namespace filter. Empty means all namespaces.
Optional substring of the pod name to match. Empty means all pods.
Optional node name filter. Empty means all nodes.
Optional pod state filter, applied to every snapshot in the time range rather than only the latest.
Unknown, Pending, Running, Succeeded, Failed Response
One row per pod, ordered by namespace and pod name.
Timestamp of the metrics snapshot.
Name of the pod.
Kubernetes namespace the pod belongs to.
Name of the node this pod is running on.
CPU usage in nanocores.
Cumulative CPU usage in core-nanoseconds.
Resident set size (RSS) memory in bytes.
Total memory usage in bytes.
Working set memory in bytes.
Number of page faults.
Number of major page faults.
Ephemeral storage used in bytes.
Ephemeral storage capacity in bytes.
Network bytes received.
Network bytes transmitted.
Number of running processes.
Current phase of the pod lifecycle.
Running, Succeeded, Pending, Failed, Unknown Derived pod state based on phase and container statuses.
Unknown, Pending, Running, Succeeded, Failed Containers running in this pod.
Show child attributes
Show child attributes
Total number of container restarts for this pod.
x >= 0Pod uptime in seconds.
x >= 0Was this page helpful?
curl --request POST \
--url https://appsignal.com/api/v2/kubernetes/pods \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"site_id": "abc123",
"from": "2024-01-01T00:00:00Z",
"to": "2024-01-01T01:00:00Z",
"namespaces": [
"default",
"kube-system"
],
"state": "Running"
}
'import requests
url = "https://appsignal.com/api/v2/kubernetes/pods"
payload = {
"site_id": "abc123",
"from": "2024-01-01T00:00:00Z",
"to": "2024-01-01T01:00:00Z",
"namespaces": ["default", "kube-system"],
"state": "Running"
}
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({
site_id: 'abc123',
from: '2024-01-01T00:00:00Z',
to: '2024-01-01T01:00:00Z',
namespaces: ['default', 'kube-system'],
state: 'Running'
})
};
fetch('https://appsignal.com/api/v2/kubernetes/pods', 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://appsignal.com/api/v2/kubernetes/pods",
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([
'site_id' => 'abc123',
'from' => '2024-01-01T00:00:00Z',
'to' => '2024-01-01T01:00:00Z',
'namespaces' => [
'default',
'kube-system'
],
'state' => 'Running'
]),
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://appsignal.com/api/v2/kubernetes/pods"
payload := strings.NewReader("{\n \"site_id\": \"abc123\",\n \"from\": \"2024-01-01T00:00:00Z\",\n \"to\": \"2024-01-01T01:00:00Z\",\n \"namespaces\": [\n \"default\",\n \"kube-system\"\n ],\n \"state\": \"Running\"\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://appsignal.com/api/v2/kubernetes/pods")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"site_id\": \"abc123\",\n \"from\": \"2024-01-01T00:00:00Z\",\n \"to\": \"2024-01-01T01:00:00Z\",\n \"namespaces\": [\n \"default\",\n \"kube-system\"\n ],\n \"state\": \"Running\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://appsignal.com/api/v2/kubernetes/pods")
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 \"site_id\": \"abc123\",\n \"from\": \"2024-01-01T00:00:00Z\",\n \"to\": \"2024-01-01T01:00:00Z\",\n \"namespaces\": [\n \"default\",\n \"kube-system\"\n ],\n \"state\": \"Running\"\n}"
response = http.request(request)
puts response.read_body[
{
"timestamp": "2023-11-07T05:31:56Z",
"pod_name": "<string>",
"pod_namespace": "<string>",
"node_name": "<string>",
"cpu_usage_nano_cores": 123,
"cpu_usage_core_nano_seconds": 123,
"memory_rss_bytes": 123,
"memory_usage_bytes": 123,
"memory_working_set_bytes": 123,
"memory_page_faults": 123,
"memory_major_page_faults": 123,
"ephemeral_storage_used_bytes": 123,
"ephemeral_storage_capacity_bytes": 123,
"network_rx_bytes": 123,
"network_tx_bytes": 123,
"process_count": 123,
"phase": "Running",
"state": "Unknown",
"containers": [
{
"name": "<string>",
"status": "Running",
"exit_code": 123,
"reason": "<string>"
}
],
"pod_restart_count": 1,
"pod_uptime_seconds": 1
}
]{
"error": "<string>",
"message": "<string>",
"details": "<unknown>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>",
"suggestion": "<string>"
}{
"error": "<string>"
}