Read a PostgreSQL instance now
Runs the hourly read of a PostgreSQL connection immediately: database sizes and activity, role query time, and COMMENT ON DATABASE and COMMENT ON ROLE labels, then re-splits the last 35 days of the instance’s bill. Use it after changing a label so the split picks it up without waiting for the next hourly read. A read that fails is not an error response: the returned connection has status error and the reason in last_sync_error, as after a scheduled read, and warnings lists what is unavailable. A read still running after 45 seconds answers 202 and finishes in the background; the connection list shows the result. Answers 409 when a read of the connection is already running or reporting is paused, and 429 when too many reads are running at once.
curl --request POST \
--url https://api.costgraph.ai/api/v1/integrations/connections/{id}/postgres/sync \
--header 'Authorization: <api-key>'import requests
url = "https://api.costgraph.ai/api/v1/integrations/connections/{id}/postgres/sync"
headers = {"Authorization": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: '<api-key>'}};
fetch('https://api.costgraph.ai/api/v1/integrations/connections/{id}/postgres/sync', 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.costgraph.ai/api/v1/integrations/connections/{id}/postgres/sync",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.costgraph.ai/api/v1/integrations/connections/{id}/postgres/sync"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "<api-key>")
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.costgraph.ai/api/v1/integrations/connections/{id}/postgres/sync")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.costgraph.ai/api/v1/integrations/connections/{id}/postgres/sync")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"message": "some message",
"status": "success",
"data": {
"connection_id": "<string>",
"connection_modes": [
"cost"
],
"created_at": "<string>",
"display_name": "<string>",
"has_metrics_source": true,
"history": {
"days_remaining": 123,
"window_days": 123,
"loaded_through": "2023-12-25"
},
"hosted": true,
"id": "<string>",
"in_jobs": 123,
"ingest_mode": "pull",
"last_sync_error": "<string>",
"last_synced_at": "<string>",
"needs_service_token": true,
"provider": "<string>",
"provider_account_id": "<string>",
"recommendations_checked_at": "<string>",
"recommendations_status": "<string>",
"sandbox_provider": "<string>",
"status": "<string>",
"tenant_id": "<string>",
"trialing_jobs": 123,
"updated_at": "<string>",
"warnings": [
"<string>"
]
}
}{
"message": "some message",
"status": "success",
"data": "<unknown>"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}Was this page helpful?
curl --request POST \
--url https://api.costgraph.ai/api/v1/integrations/connections/{id}/postgres/sync \
--header 'Authorization: <api-key>'import requests
url = "https://api.costgraph.ai/api/v1/integrations/connections/{id}/postgres/sync"
headers = {"Authorization": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: '<api-key>'}};
fetch('https://api.costgraph.ai/api/v1/integrations/connections/{id}/postgres/sync', 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.costgraph.ai/api/v1/integrations/connections/{id}/postgres/sync",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.costgraph.ai/api/v1/integrations/connections/{id}/postgres/sync"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "<api-key>")
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.costgraph.ai/api/v1/integrations/connections/{id}/postgres/sync")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.costgraph.ai/api/v1/integrations/connections/{id}/postgres/sync")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"message": "some message",
"status": "success",
"data": {
"connection_id": "<string>",
"connection_modes": [
"cost"
],
"created_at": "<string>",
"display_name": "<string>",
"has_metrics_source": true,
"history": {
"days_remaining": 123,
"window_days": 123,
"loaded_through": "2023-12-25"
},
"hosted": true,
"id": "<string>",
"in_jobs": 123,
"ingest_mode": "pull",
"last_sync_error": "<string>",
"last_synced_at": "<string>",
"needs_service_token": true,
"provider": "<string>",
"provider_account_id": "<string>",
"recommendations_checked_at": "<string>",
"recommendations_status": "<string>",
"sandbox_provider": "<string>",
"status": "<string>",
"tenant_id": "<string>",
"trialing_jobs": 123,
"updated_at": "<string>",
"warnings": [
"<string>"
]
}
}{
"message": "some message",
"status": "success",
"data": "<unknown>"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}