Integrations
Update the Grafana connection
Changes how CostGraph reads the tenant’s Grafana and checks the connection again with a test query; warnings says how many hosts that name the connection have no series. Leave token or username empty to keep the stored one; a new address or auth mode needs both again. On a Grafana Cloud cost connection the token is the one stored with that connection: a token here is refused, and a new address does not need one. The connection name is changed through PATCH /api/v1/integrations/connections/. Cached metrics read through the old settings are not reused.
PATCH
/
api
/
v1
/
integrations
/
connections
/
{id}
/
grafana
Update the Grafana connection
curl --request PATCH \
--url https://api.costgraph.ai/api/v1/integrations/connections/{id}/grafana \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "<string>",
"datasource_uid": "<string>",
"extra_matchers": "<string>",
"label_filters": {},
"token": "<string>",
"username": "<string>"
}
'import requests
url = "https://api.costgraph.ai/api/v1/integrations/connections/{id}/grafana"
payload = {
"url": "<string>",
"datasource_uid": "<string>",
"extra_matchers": "<string>",
"label_filters": {},
"token": "<string>",
"username": "<string>"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: '<string>',
datasource_uid: '<string>',
extra_matchers: '<string>',
label_filters: {},
token: '<string>',
username: '<string>'
})
};
fetch('https://api.costgraph.ai/api/v1/integrations/connections/{id}/grafana', 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}/grafana",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'url' => '<string>',
'datasource_uid' => '<string>',
'extra_matchers' => '<string>',
'label_filters' => [
],
'token' => '<string>',
'username' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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://api.costgraph.ai/api/v1/integrations/connections/{id}/grafana"
payload := strings.NewReader("{\n \"url\": \"<string>\",\n \"datasource_uid\": \"<string>\",\n \"extra_matchers\": \"<string>\",\n \"label_filters\": {},\n \"token\": \"<string>\",\n \"username\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "<api-key>")
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.patch("https://api.costgraph.ai/api/v1/integrations/connections/{id}/grafana")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\",\n \"datasource_uid\": \"<string>\",\n \"extra_matchers\": \"<string>\",\n \"label_filters\": {},\n \"token\": \"<string>\",\n \"username\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.costgraph.ai/api/v1/integrations/connections/{id}/grafana")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"<string>\",\n \"datasource_uid\": \"<string>\",\n \"extra_matchers\": \"<string>\",\n \"label_filters\": {},\n \"token\": \"<string>\",\n \"username\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"message": "some message",
"status": "success",
"data": {
"source": {
"auth_mode": "basic",
"connection_id": "<string>",
"connection_modes": [
"cost"
],
"datasource_uid": "<string>",
"extra_matchers": "<string>",
"label_filters": {},
"public_id": "<string>",
"scrape_config": {
"alloy": "<string>",
"prometheus": "<string>"
},
"updated_at": "<string>",
"url": "<string>",
"username": "<string>"
},
"warnings": [
"<string>"
]
}
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}Authorizations
Enter "Bearer {token}"
Path Parameters
Connection id from the id field of the connection list, not the fpc_ connection_id
Body
application/json
Grafana connection
Was this page helpful?
⌘I
Update the Grafana connection
curl --request PATCH \
--url https://api.costgraph.ai/api/v1/integrations/connections/{id}/grafana \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "<string>",
"datasource_uid": "<string>",
"extra_matchers": "<string>",
"label_filters": {},
"token": "<string>",
"username": "<string>"
}
'import requests
url = "https://api.costgraph.ai/api/v1/integrations/connections/{id}/grafana"
payload = {
"url": "<string>",
"datasource_uid": "<string>",
"extra_matchers": "<string>",
"label_filters": {},
"token": "<string>",
"username": "<string>"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: '<string>',
datasource_uid: '<string>',
extra_matchers: '<string>',
label_filters: {},
token: '<string>',
username: '<string>'
})
};
fetch('https://api.costgraph.ai/api/v1/integrations/connections/{id}/grafana', 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}/grafana",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'url' => '<string>',
'datasource_uid' => '<string>',
'extra_matchers' => '<string>',
'label_filters' => [
],
'token' => '<string>',
'username' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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://api.costgraph.ai/api/v1/integrations/connections/{id}/grafana"
payload := strings.NewReader("{\n \"url\": \"<string>\",\n \"datasource_uid\": \"<string>\",\n \"extra_matchers\": \"<string>\",\n \"label_filters\": {},\n \"token\": \"<string>\",\n \"username\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "<api-key>")
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.patch("https://api.costgraph.ai/api/v1/integrations/connections/{id}/grafana")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\",\n \"datasource_uid\": \"<string>\",\n \"extra_matchers\": \"<string>\",\n \"label_filters\": {},\n \"token\": \"<string>\",\n \"username\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.costgraph.ai/api/v1/integrations/connections/{id}/grafana")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"<string>\",\n \"datasource_uid\": \"<string>\",\n \"extra_matchers\": \"<string>\",\n \"label_filters\": {},\n \"token\": \"<string>\",\n \"username\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"message": "some message",
"status": "success",
"data": {
"source": {
"auth_mode": "basic",
"connection_id": "<string>",
"connection_modes": [
"cost"
],
"datasource_uid": "<string>",
"extra_matchers": "<string>",
"label_filters": {},
"public_id": "<string>",
"scrape_config": {
"alloy": "<string>",
"prometheus": "<string>"
},
"updated_at": "<string>",
"url": "<string>",
"username": "<string>"
},
"warnings": [
"<string>"
]
}
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}