Integrations
Use a Grafana Cloud cost connection for metrics
Lets an existing Grafana Cloud cost connection also serve Mac metrics, reusing the token stored with it, so no second token is entered. The settings are the same as for connecting Grafana, without a token, and are checked the same way: the connection is refused when the token cannot read metrics or host metrics cannot be read. Nothing changes when the check fails. On success metrics is added to the connection’s connection_modes and cost stays on.
POST
/
api
/
v1
/
integrations
/
grafana
/
from-connection
/
{id}
Use a Grafana Cloud cost connection for metrics
curl --request POST \
--url https://api.costgraph.ai/api/v1/integrations/grafana/from-connection/{id} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "<string>",
"datasource_uid": "<string>",
"extra_matchers": "<string>",
"label_filters": {},
"username": "<string>"
}
'import requests
url = "https://api.costgraph.ai/api/v1/integrations/grafana/from-connection/{id}"
payload = {
"url": "<string>",
"datasource_uid": "<string>",
"extra_matchers": "<string>",
"label_filters": {},
"username": "<string>"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: '<string>',
datasource_uid: '<string>',
extra_matchers: '<string>',
label_filters: {},
username: '<string>'
})
};
fetch('https://api.costgraph.ai/api/v1/integrations/grafana/from-connection/{id}', 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/grafana/from-connection/{id}",
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([
'url' => '<string>',
'datasource_uid' => '<string>',
'extra_matchers' => '<string>',
'label_filters' => [
],
'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/grafana/from-connection/{id}"
payload := strings.NewReader("{\n \"url\": \"<string>\",\n \"datasource_uid\": \"<string>\",\n \"extra_matchers\": \"<string>\",\n \"label_filters\": {},\n \"username\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.costgraph.ai/api/v1/integrations/grafana/from-connection/{id}")
.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 \"username\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.costgraph.ai/api/v1/integrations/grafana/from-connection/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.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 \"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
Metrics settings
Was this page helpful?
⌘I
Use a Grafana Cloud cost connection for metrics
curl --request POST \
--url https://api.costgraph.ai/api/v1/integrations/grafana/from-connection/{id} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "<string>",
"datasource_uid": "<string>",
"extra_matchers": "<string>",
"label_filters": {},
"username": "<string>"
}
'import requests
url = "https://api.costgraph.ai/api/v1/integrations/grafana/from-connection/{id}"
payload = {
"url": "<string>",
"datasource_uid": "<string>",
"extra_matchers": "<string>",
"label_filters": {},
"username": "<string>"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: '<string>',
datasource_uid: '<string>',
extra_matchers: '<string>',
label_filters: {},
username: '<string>'
})
};
fetch('https://api.costgraph.ai/api/v1/integrations/grafana/from-connection/{id}', 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/grafana/from-connection/{id}",
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([
'url' => '<string>',
'datasource_uid' => '<string>',
'extra_matchers' => '<string>',
'label_filters' => [
],
'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/grafana/from-connection/{id}"
payload := strings.NewReader("{\n \"url\": \"<string>\",\n \"datasource_uid\": \"<string>\",\n \"extra_matchers\": \"<string>\",\n \"label_filters\": {},\n \"username\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.costgraph.ai/api/v1/integrations/grafana/from-connection/{id}")
.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 \"username\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.costgraph.ai/api/v1/integrations/grafana/from-connection/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.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 \"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"
}