Create a data source
curl --request POST \
--url https://sreagent.app/api/v1/config/data_sources \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"type": "<string>",
"auth_credentials": {},
"regions": [
"<string>"
],
"url": "<string>"
}
'import requests
url = "https://sreagent.app/api/v1/config/data_sources"
payload = {
"name": "<string>",
"type": "<string>",
"auth_credentials": {},
"regions": ["<string>"],
"url": "<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({
name: '<string>',
type: '<string>',
auth_credentials: {},
regions: ['<string>'],
url: '<string>'
})
};
fetch('https://sreagent.app/api/v1/config/data_sources', 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://sreagent.app/api/v1/config/data_sources",
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([
'name' => '<string>',
'type' => '<string>',
'auth_credentials' => [
],
'regions' => [
'<string>'
],
'url' => '<string>'
]),
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://sreagent.app/api/v1/config/data_sources"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"type\": \"<string>\",\n \"auth_credentials\": {},\n \"regions\": [\n \"<string>\"\n ],\n \"url\": \"<string>\"\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://sreagent.app/api/v1/config/data_sources")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"type\": \"<string>\",\n \"auth_credentials\": {},\n \"regions\": [\n \"<string>\"\n ],\n \"url\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sreagent.app/api/v1/config/data_sources")
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 \"name\": \"<string>\",\n \"type\": \"<string>\",\n \"auth_credentials\": {},\n \"regions\": [\n \"<string>\"\n ],\n \"url\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"error": "<string>",
"message": "<string>"
}data_sources
Create a data source
Create a data source (prometheus, loki, grafana, cloudwatch_metrics, cloudwatch_logs, cloudtrail, xray, datadog_metrics, datadog_logs, newrelic_metrics, newrelic_logs, elasticsearch). For AWS assume-role the organization's ExternalId is applied automatically; pass role_arn in auth_credentials. For AWS you may pass regions (a list) instead of url. cloudwatch_metrics, cloudwatch_logs, cloudtrail and xray share one account's role: connecting any one of them is enough for reads of all four, so a second row is only needed for a different account or a precise route. For a Prometheus source whose auth_type is an AWS one, the URL must be an AMP workspace URL (aps-workspaces.<region>.amazonaws.com/workspaces/<id>) OR the regions list must be supplied, because the SigV4 signature is region-bound.
POST
/
data_sources
Create a data source
curl --request POST \
--url https://sreagent.app/api/v1/config/data_sources \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"type": "<string>",
"auth_credentials": {},
"regions": [
"<string>"
],
"url": "<string>"
}
'import requests
url = "https://sreagent.app/api/v1/config/data_sources"
payload = {
"name": "<string>",
"type": "<string>",
"auth_credentials": {},
"regions": ["<string>"],
"url": "<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({
name: '<string>',
type: '<string>',
auth_credentials: {},
regions: ['<string>'],
url: '<string>'
})
};
fetch('https://sreagent.app/api/v1/config/data_sources', 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://sreagent.app/api/v1/config/data_sources",
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([
'name' => '<string>',
'type' => '<string>',
'auth_credentials' => [
],
'regions' => [
'<string>'
],
'url' => '<string>'
]),
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://sreagent.app/api/v1/config/data_sources"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"type\": \"<string>\",\n \"auth_credentials\": {},\n \"regions\": [\n \"<string>\"\n ],\n \"url\": \"<string>\"\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://sreagent.app/api/v1/config/data_sources")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"type\": \"<string>\",\n \"auth_credentials\": {},\n \"regions\": [\n \"<string>\"\n ],\n \"url\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sreagent.app/api/v1/config/data_sources")
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 \"name\": \"<string>\",\n \"type\": \"<string>\",\n \"auth_credentials\": {},\n \"regions\": [\n \"<string>\"\n ],\n \"url\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"error": "<string>",
"message": "<string>"
}Authorizations
An sre_ak_* API key holding the api:admin scope (or api:config_read, which every write refuses with read_only_key).
Body
application/json
How the source authenticates.
Available options:
none, basic, bearer, api_key, datadog_keys, aws_access_keys, aws_assume_role, aws_instance AWS regions this source covers, e.g. ["us-east-1"]
Response
Created.

