API Grafana Cloud
API Grafana Cloud, иногда называемый API Grafana.com или API GCOM, позволяет программно взаимодействовать с ресурсами вашего стека Grafana Cloud.
Ниже приведён список утверждённых статических конечных точек и вызовов для общего использования. Любые другие пути могут изменяться и не поддерживаются для общего использования пользователями.
Note
Если вам нужно управлять ресурсами вашего экземпляра Grafana или получать к ним доступ — например, к дашбордам, алертам, источникам данных, пользователям и так далее — вместо этого обратитесь к HTTP API.
Аутентификация
Для использования Cloud API необходимо создать политику доступа (Cloud Access Policy) и токен. Как создать Grafana Cloud Access Policy, см. в разделе Создание политики доступа.
Запросы к API аутентифицируются с помощью заголовка Authorization:
Authorization: Bearer <CLOUD ACCESS POLICY TOKEN>
Политики доступа и токены
Note
Ограничение частоты запросов на конечной точке Grafana Cloud API для политик доступа — 600 в час.
Политики доступа и токены используют ресурсы access policy, token, scope, realm, labelselector и conditions.
Дополнительные сведения об этих ресурсах см. в разделе Политики доступа Grafana Cloud.
Note
Политики доступа и токены должны иметь уникальное сочетание имени, ID организации и региона.
Все запросы к API должны указывать токен в заголовке Authorization запроса.
Этот API опирается на ID стека и организации, а также на регион:
- Stack ID: получается с конечной точки
https://grafana.com/api/orgs/{org}/instances - Org ID: получается с конечной точки
https://grafana.com/api/orgs/{org} - Region: регион вашего стека можно получить с конечной точки
https://grafana.com/api/orgs/{org}/instances, а список всех доступных регионов — с конечной точкиhttps://grafana.com/api/stack-regions
Конечные точки с постраничной выдачей опционально принимают параметры запроса pageSize и pageCursor.
Если опустить параметр pageCursor или передать пустое значение pageCursor, вы получите первую страницу.
URL следующей страницы можно получить из свойства metadata.pagination.nextPage текущей страницы.
Если это поле равно null, вы достигли последней страницы и записей больше не осталось.
Создание политики доступа
Создайте политику доступа методом POST.
POST https://www.grafana.com/api/v1/accesspolicies
Параметры
Тело запроса
Realm
LabelPolicy
Conditions
Пример запроса:
{
"name": "stack-readers",
"displayName": "Stack Readers",
"scopes": ["metrics:read", "logs:read", "traces:read", "alerts:read"],
"realms": [
{
"type": "stack",
"identifier": "123",
"labelPolicies": [
{
"selector": "{env != \"dev\"}"
}
]
}
],
"conditions": {
"allowedSubnets": ["192.168.0.0/24", "10.1.2.99/32"]
}
}
Ответы
Могут быть возвращены следующие ответы.
Пример ответа:
{
"id": "c45485b6-8321-4cf2-bcec-12006df755ff",
"orgId": "1",
"name": "stack-readers",
"displayName": "Stack Readers",
"scopes": ["metrics:read", "logs:read", "traces:read", "alerts:read"],
"realms": [
{
"type": "stack",
"identifier": "123",
"labelPolicies": [
{
"selector": "{env != \"dev\"}"
}
]
}
],
"conditions": {
"allowedSubnets": ["192.168.0.0/24", "10.1.2.99/32"]
},
"createdAt": "2022-06-08T20:07:21.223Z",
"updatedAt": "2022-06-08T20:07:21.223Z"
}
Получение списка политик доступа
Получите список указанных политик доступа методом GET.
GET https://www.grafana.com/api/v1/accesspolicies
Параметры
Ответы
Могут быть возвращены следующие ответы.
Пример ответа:
{
"items": [
{
"id": "c45485b6-8321-4cf2-bcec-12006df755ff",
"orgId": "1",
"name": "stack-readers",
"displayName": "Stack Readers",
"scopes": ["metrics:read", "logs:read", "traces:read", "alerts:read"],
"realms": [
{
"type": "stack",
"identifier": "123",
"labelPolicies": [
{
"selector": "{env != \"dev\"}"
}
]
}
],
"conditions": {
"allowedSubnets": ["192.168.0.0/24", "10.1.2.99/32"]
},
"createdAt": "2022-06-08T16:47:46.151Z",
"updatedAt": "2022-06-08T16:47:46.151Z",
"status": "active"
}
],
"metadata": {
"pagination": {
"pageSize": 500,
"pageCursor": "ZDMyYzZhODktZjU1ZC00NGViLWJmYWEtMTEyYmE2NTFlNDJifDIwMjItMDQtMTFUMTI6NTQ6MDBa",
"nextPage": "/v1/accesspolicies?pageCursor=ZDMyYzZhODktZjU1ZC00NGViLWJmYWEtMTEyYmE2NTFlNDJifDIwMjItMDQtMTFUMTI6NTQ6MDBa"
}
}
}
Получение одной политики доступа
Получите одну политику доступа методом GET.
GET https://www.grafana.com/api/v1/accesspolicies/{accessPolicyID}
Параметры
Ответы
Могут быть возвращены следующие ответы.
Пример ответа:
{
"id": "c45485b6-8321-4cf2-bcec-12006df755ff",
"orgId": "1",
"name": "stack-readers",
"displayName": "Stack Readers",
"scopes": ["metrics:read", "logs:read", "traces:read", "alerts:read"],
"realms": [
{
"type": "stack",
"identifier": "123",
"labelPolicies": [
{
"selector": "{env != \"dev\"}"
}
]
}
],
"conditions": {
"allowedSubnets": ["192.168.0.0/24", "10.1.2.99/32"]
},
"createdAt": "2022-06-08T21:06:27.853Z",
"updatedAt": "2022-06-08T21:06:27.853Z",
"status": "active"
}
Обновление политики доступа
Обновите существующую политику доступа методом POST.
Note
Чтобы удалить диапазоны IP, выполните одно из следующих действий:
- задайте
allowedSubnetsкак пустой массив ([])- задайте
conditionsкакnullили как пустой объект ({}).
POST https://www.grafana.com/api/v1/accesspolicies/{accessPolicyId}
Параметры
Тело запроса
Тело запроса задаёт пересмотренную политику доступа.
Realm
LabelPolicy
Conditions
Пример запроса:
{
"displayName": "Stack Readers",
"scopes": ["metrics:read", "logs:read", "traces:read", "alerts:read"],
"realms": [
{
"type": "stack",
"identifier": "123",
"labelPolicies": [
{
"selector": "{env != \"dev\"}"
}
]
}
],
"conditions": {
"allowedSubnets": ["192.168.99.100/32"]
},
"status": "active"
}
Ответы
Могут быть возвращены следующие ответы.
Пример ответа:
{
"id": "c45485b6-8321-4cf2-bcec-12006df755ff",
"orgId": "1",
"name": "stack-readers",
"displayName": "Stack Readers",
"scopes": ["metrics:read", "logs:read", "traces:read", "alerts:read"],
"realms": [
{
"type": "stack",
"identifier": "123",
"labelPolicies": [
{
"selector": "{env != \"dev\"}"
}
]
}
],
"conditions": {
"allowedSubnets": ["192.168.99.100/32"]
},
"createdAt": "2022-06-08T21:10:37.011Z",
"updatedAt": "2022-06-08T21:10:37.011Z",
"status": "active"
}
Удаление политики доступа
Удалите политику доступа методом DELETE.
DELETE https://www.grafana.com/api/v1/accesspolicies/{accessPolicyId}
Параметры
Ответы
Могут быть возвращены следующие ответы.
Создание токена
Создайте токен методом POST.
POST https://www.grafana.com/api/v1/tokens
Параметры
Тело запроса
Тело запроса содержит сведения о создаваемом токене.
Пример запроса:
{
"accessPolicyId": "c45485b6-8321-4cf2-bcec-12006df755ff",
"name": "mytoken",
"displayName": "My Token",
"expiresAt": "2022-06-08T22:05:46.958Z"
}
Ответы
Могут быть возвращены следующие ответы.
Пример ответа:
{
"id": "c45485b6-8321-4cf2-bcec-12006df755ff",
"accessPolicyId": "c45485b6-8321-4cf2-bcec-12006df755ff",
"name": "mytoken",
"displayName": "My Token",
"expiresAt": "2022-06-08T22:05:46.959Z",
"firstUsedAt": "2022-06-08T22:05:46.959Z",
"lastUsedAt": "2022-06-08T22:05:46.959Z",
"createdAt": "2022-06-08T22:05:46.959Z",
"updatedAt": "2022-06-08T22:05:46.959Z",
"token": "glc_eyJrIjoiZjI0YzZkNGEwZDBmZmZjMmUzNTU2ODcxMmY0ZWZlNTQ1NTljMDFjOCIsIm4iOiJteXRva2VuIiwiaWQiOjF9"
}
Получение набора токенов
Получите набор токенов методом GET.
GET https://www.grafana.com/api/v1/tokens
Параметры
Ответы
Могут быть возвращены следующие ответы.
Пример ответа:
{
"items": [
{
"id": "c45485b6-8321-4cf2-bcec-12006df755ff",
"accessPolicyId": "c45485b6-8321-4cf2-bcec-12006df755ff",
"name": "mytoken",
"displayName": "My Token",
"expiresAt": "2022-06-08T22:11:05.614Z",
"firstUsedAt": "2022-06-08T22:11:05.614Z",
"lastUsedAt": "2022-06-08T22:11:05.614Z",
"createdAt": "2022-06-08T22:11:05.614Z",
"updatedAt": "2022-06-08T22:11:05.614Z"
}
],
"metadata": {
"pagination": {
"pageSize": 500,
"pageCursor": "ZDMyYzZhODktZjU1ZC00NGViLWJmYWEtMTEyYmE2NTFlNDJifDIwMjItMDQtMTFUMTI6NTQ6MDBa",
"nextPage": "/v1/accesspolicies?pageCursor=ZDMyYzZhODktZjU1ZC00NGViLWJmYWEtMTEyYmE2NTFlNDJifDIwMjItMDQtMTFUMTI6NTQ6MDBa"
}
}
}
Получение одного токена
Получите указанный токен методом GET.
GET https://www.grafana.com/api/v1/tokens/{tokenId}
Параметры
Ответы
Могут быть возвращены следующие ответы.
Пример ответа:
{
"id": "c45485b6-8321-4cf2-bcec-12006df755ff",
"accessPolicyId": "c45485b6-8321-4cf2-bcec-12006df755ff",
"name": "mytoken",
"displayName": "My Token",
"expiresAt": "2022-06-09T04:31:23.559Z",
"firstUsedAt": "2022-06-09T04:31:23.559Z",
"lastUsedAt": "2022-06-09T04:31:23.559Z",
"createdAt": "2022-06-09T04:31:23.559Z",
"updatedAt": "2022-06-09T04:31:23.559Z"
}
Обновление токена
Обновите указанный токен методом POST.
POST https://www.grafana.com/api/v1/tokens/{tokenId}
Параметры
Тело запроса
Тело запроса содержит обновлённые значения, применяемые к токену.
Пример запроса:
{
"displayName": "My token",
"expiresAt": "2022-06-09T04:43:16.296Z"
}
Ответы
Могут быть возвращены следующие ответы.
Пример ответа:
{
"id": "c45485b6-8321-4cf2-bcec-12006df755ff",
"accessPolicyId": "c45485b6-8321-4cf2-bcec-12006df755ff",
"name": "mytoken",
"displayName": "My token",
"expiresAt": "2022-06-09T04:43:16.296Z",
"firstUsedAt": "2022-06-09T04:43:16.296Z",
"lastUsedAt": "2022-06-09T04:43:16.296Z",
"createdAt": "2022-06-09T04:43:16.296Z",
"updatedAt": "2022-06-09T04:43:16.296Z"
}
Удаление токена
Удалите указанный токен методом DELETE.
DELETE https://www.grafana.com/api/v1/tokens/{tokenId}
Параметры
Ответы
Могут быть возвращены следующие ответы.
Стеки
Note
Grafana Cloud Free включает 1 стек, а Grafana Cloud Pro — до 3 стеков. Свяжитесь со службой поддержки, если хотите добавить в свой аккаунт дополнительные стеки в рамках договорного плана Grafana Cloud.
Получение списка стеков
GET https://grafana.com/api/orgs/<ORG_SLUG>/instances
Ответы
Могут быть возвращены следующие ответы.
Пример ответа:
{
"items": [
{
"id": 007303,
"orgId": 052992,
"orgSlug": "grafanacom",
"orgName": "grafanacom",
"type": "grafana",
"name": "cloudapistack.grafana.net",
"url": "https://cloudapistack.grafana.net",
"slug": "cloudapistack",
"version": "stable",
"description": "",
"status": "active",
"gateway": "istio",
"createdAt": "2023-01-04T06:43:24.000Z",
"createdBy": "foobar",
"updatedAt": null,
"updatedBy": "",
"trial": 0,
"trialExpiresAt": null,
"clusterId": 69,
"clusterSlug": "prod-us-central-0",
"clusterName": "prod-us-central-0",
"plan": "gcloud",
"planName": "Grafana Cloud",
"billingStartDate": "2023-01-04T06:43:23.000Z",
"billingEndDate": null,
"billingActiveUsers": 0,
"billingGrafanaActiveUsers": 0,
"billingOnCallActiveUsers": 0,
"currentActiveUsers": 0,
"currentActiveAdminUsers": 0,
"currentActiveEditorUsers": 0,
"currentActiveViewerUsers": 0,
"dailyUserCnt": 0,
"dailyAdminCnt": 0,
"dailyEditorCnt": 0,
"dailyViewerCnt": 0,
"dashboardCnt": 8,
"datasourceCnts": {},
"userQuota": 10,
"dashboardQuota": -1,
"alertQuota": -1,
"alertCnt": 0,
"ssl": true,
"customAuth": true,
"customDomain": true,
"support": true,
"runningVersion": "9.3.2-45365 (commit: ef5286dd77, branch: v9.3.x)",
"machineLearning": 0,
"incident": 0,
"hmInstancePromId": 715391,
"hmInstancePromUrl": "https://prometheus-us-central1.grafana.net",
"hmInstancePromName": "cloudapistack-prom",
"hmInstancePromStatus": "active",
"hmInstancePromCurrentUsage": 0,
"hmInstancePromCurrentActiveSeries": 0,
"hmInstanceGraphiteId": 715392,
"hmInstanceGraphiteUrl": "https://graphite-prod-10-prod-us-central-0.grafana.net",
"hmInstanceGraphiteName": "cloudapistack-graphite",
"hmInstanceGraphiteType": "graphite-v5",
"hmInstanceGraphiteStatus": "active",
"hmInstanceGraphiteCurrentUsage": 0,
"hlInstanceId": 356665,
"hlInstanceUrl": "https://logs-prod-017.grafana.net",
"hlInstanceName": "cloudapistack-logs",
"hlInstanceStatus": "active",
"hlInstanceCurrentUsage": 0,
"amInstanceId": 355647,
"amInstanceName": "cloudapistack-alerts",
"amInstanceUrl": "https://alertmanager-us-central1.grafana.net",
"amInstanceStatus": "active",
"amInstanceGeneratorUrl": "https://cloudapistack.grafana.net",
"amInstanceGeneratorUrlDatasource": "",
"htInstanceId": 353178,
"htInstanceUrl": "https://tempo-us-central1.grafana.net",
"htInstanceName": "cloudapistack-traces",
"htInstanceStatus": "active",
"regionId": 1,
"regionSlug": "us",
"links": [
{
"rel": "self",
"href": "/instances/cloudapistack"
},
{
"rel": "org",
"href": "/orgs/grafanacom"
},
{
"rel": "plugins",
"href": "/instances/cloudapistack/plugins"
}
]
}
],
"orderBy": "name",
"direction": "asc",
"total": 1,
"pages": 1,
"pageSize": 1000000,
"page": 1,
"links": [
{
"rel": "self",
"href": "/instances"
}
]
}
Получение сведений о подключении стека
GET https://grafana.com/api/instances/<STACK_SLUG>/connections
Ответы
Могут быть возвращены следующие ответы.
Пример ответа:
{
"privateConnectivityInfo": {
"tenants": [
{
"type": "prometheus",
"id": 1899232,
"info": {
"privateDNS": "cortex-prod-13-cortex-gw.us-east-2.vpce.grafana.net",
"serviceName": "com.amazonaws.vpce.us-east-2.vpce-svc-0d13a270cd91a0a3a"
},
"ipAllowListCNAME": "src-ips.prometheus-prod-13-prod-us-east-0.grafana.net"
},
{
"type": "graphite",
"id": 1899233,
"info": {
"privateDNS": "cortex-prod-13-cortex-gw.us-east-2.vpce.grafana.net",
"serviceName": "com.amazonaws.vpce.us-east-2.vpce-svc-0d13a270cd91a0a3a"
},
"ipAllowListCNAME": "src-ips.prometheus-prod-13-prod-us-east-0.grafana.net"
},
{
"type": "logs",
"id": 1048899,
"info": {
"privateDNS": "loki-prod-006-cortex-gw.us-east-2.vpce.grafana.net",
"serviceName": "com.amazonaws.vpce.us-east-2.vpce-svc-071e7d98821c1698b"
},
"ipAllowListCNAME": "src-ips.logs-prod-006.grafana.net"
},
{
"type": "traces",
"id": 1043214,
"info": {
"privateDNS": "tempo-prod-04-cortex-gw.us-east-2.vpce.grafana.net",
"serviceName": "com.amazonaws.vpce.us-east-2.vpce-svc-0a830aaea99ecfc91"
},
"ipAllowListCNAME": "src-ips.tempo-prod-04-prod-us-east-0.grafana.net"
},
{
"type": "profiles",
"id": 1091120,
"info": {
"privateDNS": "profiles-prod-001-cortex-gw.us-east-2.vpce.grafana.net",
"serviceName": "com.amazonaws.vpce.us-east-2.vpce-svc-079d447d0143b24e7"
},
"ipAllowListCNAME": "src-ips.profiles-prod-001.grafana.net"
},
{
"type": "alerts",
"id": 947554,
"ipAllowListCNAME": "src-ips.alertmanager-prod-us-east-0.grafana.net"
},
{
"type": "grafana",
"id": 1091120,
"ipAllowListCNAME": null
}
],
"otlp": {
"privateDNS": "prod-us-east-0-otlp-gateway.us-east-2.vpce.grafana.net",
"serviceName": "com.amazonaws.vpce.us-east-2.vpce-svc-0d36af67949f874c4"
},
"pdc": {
"api": {
"privateDNS": "private-datasource-connect-api.us-east-2.vpce.grafana.net",
"serviceName": "com.amazonaws.vpce.us-east-2.vpce-svc-0078cfdaab047fc37"
},
"gateway": {
"privateDNS": "private-datasource-connect.us-east-2.vpce.grafana.net",
"serviceName": "com.amazonaws.vpce.us-east-2.vpce-svc-032570426402bc97e"
}
}
},
"influxUrl": "https://influx-prod-13-prod-us-east-0.grafana.net",
"otlpHttpUrl": "https://otlp-gateway-prod-us-east-0.grafana.net",
"oncallApiUrl": "https://oncall-prod-us-east-0.grafana.net/oncall",
"appPlatform": {
"url": "https://app-platform-apiserver-prod-us-east-0.grafana.net",
"caData": "<SOME-VERY-LONG-PUBLIC-KEY>"
}
}
Эта конечная точка содержит способ подключения к различным тенантам, которые есть у стека, включая AWS PrivateLink, если регион находится в AWS.
Создание стека
Note
Этот запрос
POSTпринимает только строчные символы.
POST https://grafana.com/api/instances
Тело запроса
Note
Для собственного домена необходимо настроить запись
CNAME, указывающую на<STACK_SLUG>.grafana.net, прежде чем указывать домен.
Ответы
Могут быть возвращены следующие ответы.
Пример ответа:
{
"id": 507363,
"orgId": 652992,
"orgSlug": "grafanacom",
"orgName": "grafanacom",
"type": "grafana",
"name": "createcloudstack",
"url": "https://createcloudstack.grafana.net",
"slug": "createcloudstack",
"version": "stable",
"labels": {
"key": "value"
},
"description": "",
"status": "active",
"gateway": "istio",
"createdAt": "2023-01-04T08:20:07.000Z",
"createdBy": "testengineer",
"updatedAt": null,
"updatedBy": "",
"trial": 0,
"trialExpiresAt": null,
"clusterId": 69,
"clusterSlug": "prod-us-central-0",
"clusterName": "prod-us-central-0",
"plan": "gcloud",
"planName": "Grafana Cloud",
"billingStartDate": "2023-01-04T08:20:06.000Z",
"billingEndDate": null,
"billingActiveUsers": 0,
"billingGrafanaActiveUsers": 0,
"billingOnCallActiveUsers": 0,
"currentActiveUsers": 0,
"currentActiveAdminUsers": 0,
"currentActiveEditorUsers": 0,
"currentActiveViewerUsers": 0,
"dailyUserCnt": 0,
"dailyAdminCnt": 0,
"dailyEditorCnt": 0,
"dailyViewerCnt": 0,
"dashboardCnt": 0,
"datasourceCnts": {},
"userQuota": 10,
"dashboardQuota": -1,
"alertQuota": -1,
"alertCnt": 0,
"ssl": true,
"customAuth": true,
"customDomain": true,
"support": true,
"runningVersion": "",
"machineLearning": 0,
"incident": 0,
"deleteProtection": true,
"hmInstancePromId": 715511,
"hmInstancePromUrl": "https://prometheus-us-central1.grafana.net",
"hmInstancePromName": "createcloudstack-prom",
"hmInstancePromStatus": "active",
"hmInstancePromCurrentUsage": 0,
"hmInstancePromCurrentActiveSeries": 0,
"hmInstanceGraphiteId": 715512,
"hmInstanceGraphiteUrl": "https://graphite-prod-10-prod-us-central-0.grafana.net",
"hmInstanceGraphiteName": "createcloudstack-graphite",
"hmInstanceGraphiteType": "graphite-v5",
"hmInstanceGraphiteStatus": "active",
"hmInstanceGraphiteCurrentUsage": 0,
"hlInstanceId": 356725,
"hlInstanceUrl": "https://logs-prod-017.grafana.net",
"hlInstanceName": "createcloudstack-logs",
"hlInstanceStatus": "active",
"hlInstanceCurrentUsage": 0,
"amInstanceId": 355707,
"amInstanceName": "createcloudstack-alerts",
"amInstanceUrl": "https://alertmanager-us-central1.grafana.net",
"amInstanceStatus": "active",
"amInstanceGeneratorUrl": "https://createcloudstack.grafana.net",
"amInstanceGeneratorUrlDatasource": "",
"htInstanceId": 353238,
"htInstanceUrl": "https://tempo-us-central1.grafana.net",
"htInstanceName": "createcloudstack-traces",
"htInstanceStatus": "active",
"regionId": 1,
"regionSlug": "us",
"links": [
{
"rel": "self",
"href": "/instances/createcloudstack"
},
{
"rel": "org",
"href": "/orgs/grafanacom"
},
{
"rel": "plugins",
"href": "/instances/createcloudstack/plugins"
}
]
}
Обновление стека
Note
Этот запрос
POSTпринимает только строчные символы.
POST https://grafana.com/api/instances/<STACK_SLUG>
Тело запроса
Ответы
Могут быть возвращены следующие ответы.
Пример ответа:
{
"id": 507363,
"orgId": 652992,
"orgSlug": "grafanacom",
"orgName": "grafanacom",
"type": "grafana",
"name": "createcloudstack",
"url": "https://createcloudstack.grafana.net",
"slug": "createcloudstack",
"labels": {
"newkey": "newvalue"
},
"version": "stable",
"description": "",
"status": "active",
"gateway": "istio",
"createdAt": "2023-01-04T08:20:07.000Z",
"createdBy": "testengineer",
"updatedAt": null,
"updatedBy": "",
"trial": 0,
"trialExpiresAt": null,
"clusterId": 69,
"clusterSlug": "prod-us-central-0",
"clusterName": "prod-us-central-0",
"plan": "gcloud",
"planName": "Grafana Cloud",
"billingStartDate": "2023-01-04T08:20:06.000Z",
"billingEndDate": null,
"billingActiveUsers": 0,
"billingGrafanaActiveUsers": 0,
"billingOnCallActiveUsers": 0,
"currentActiveUsers": 0,
"currentActiveAdminUsers": 0,
"currentActiveEditorUsers": 0,
"currentActiveViewerUsers": 0,
"dailyUserCnt": 0,
"dailyAdminCnt": 0,
"dailyEditorCnt": 0,
"dailyViewerCnt": 0,
"dashboardCnt": 0,
"datasourceCnts": {},
"userQuota": 10,
"dashboardQuota": -1,
"alertQuota": -1,
"alertCnt": 0,
"ssl": true,
"customAuth": true,
"customDomain": true,
"support": true,
"runningVersion": "",
"machineLearning": 0,
"incident": 0,
"deleteProtection": true,
"hmInstancePromId": 715511,
"hmInstancePromUrl": "https://prometheus-us-central1.grafana.net",
"hmInstancePromName": "createcloudstack-prom",
"hmInstancePromStatus": "active",
"hmInstancePromCurrentUsage": 0,
"hmInstancePromCurrentActiveSeries": 0,
"hmInstanceGraphiteId": 715512,
"hmInstanceGraphiteUrl": "https://graphite-prod-10-prod-us-central-0.grafana.net",
"hmInstanceGraphiteName": "createcloudstack-graphite",
"hmInstanceGraphiteType": "graphite-v5",
"hmInstanceGraphiteStatus": "active",
"hmInstanceGraphiteCurrentUsage": 0,
"hlInstanceId": 356725,
"hlInstanceUrl": "https://logs-prod-017.grafana.net",
"hlInstanceName": "createcloudstack-logs",
"hlInstanceStatus": "active",
"hlInstanceCurrentUsage": 0,
"amInstanceId": 355707,
"amInstanceName": "createcloudstack-alerts",
"amInstanceUrl": "https://alertmanager-us-central1.grafana.net",
"amInstanceStatus": "active",
"amInstanceGeneratorUrl": "https://createcloudstack.grafana.net",
"amInstanceGeneratorUrlDatasource": "",
"htInstanceId": 353238,
"htInstanceUrl": "https://tempo-us-central1.grafana.net",
"htInstanceName": "createcloudstack-traces",
"htInstanceStatus": "active",
"regionId": 1,
"regionSlug": "us",
"links": [
{
"rel": "self",
"href": "/instances/createcloudstack"
},
{
"rel": "org",
"href": "/orgs/grafanacom"
},
{
"rel": "plugins",
"href": "/instances/createcloudstack/plugins"
}
]
}
Удаление стека
DELETE https://grafana.com/api/instances/<STACK_SLUG>
Ответы
Могут быть возвращены следующие ответы.
Caution
Если вы получили код ответа
409, это означает, что у стека включена защита от удаления. Сначала необходимо отключить флагdeleteProtectionдля стека, прежде чем его можно будет успешно удалить.
Пример ответа:
{
"id": 507366,
"orgId": 652992,
"orgSlug": "grafanacom",
"orgName": "grafanacom",
"type": "grafana",
"name": "createcloudstack",
"url": "https://createcloudstack.grafana.net",
"slug": "createcloudstack",
"version": "stable",
"description": "",
"status": "deleted",
"gateway": "istio",
"createdAt": "2023-01-04T08:22:00.000Z",
"createdBy": "ishanjain",
"updatedAt": "2023-01-04T08:30:36.066Z",
"updatedBy": "ishanjain",
"trial": 0,
"trialExpiresAt": null,
"clusterId": 69,
"clusterSlug": "prod-us-central-0",
"clusterName": "prod-us-central-0",
"plan": "gcloud",
"planName": "Grafana Cloud",
"billingStartDate": "2023-01-04T08:21:59.000Z",
"billingEndDate": "2023-01-04T08:30:36.066Z",
"billingActiveUsers": 0,
"billingGrafanaActiveUsers": 0,
"billingOnCallActiveUsers": 0,
"currentActiveUsers": 0,
"currentActiveAdminUsers": 0,
"currentActiveEditorUsers": 0,
"currentActiveViewerUsers": 0,
"dailyUserCnt": 0,
"dailyAdminCnt": 0,
"dailyEditorCnt": 0,
"dailyViewerCnt": 0,
"dashboardCnt": 0,
"datasourceCnts": {},
"userQuota": 10,
"dashboardQuota": -1,
"alertQuota": -1,
"alertCnt": 0,
"ssl": true,
"customAuth": true,
"customDomain": true,
"support": true,
"runningVersion": "9.3.2-45365 (commit: ef5286dd77, branch: v9.3.x)",
"machineLearning": 0,
"incident": 0,
"deleteProtection": false,
"hmInstancePromId": 715517,
"hmInstancePromUrl": "https://prometheus-us-central1.grafana.net",
"hmInstancePromName": "createcloudstack-prom",
"hmInstancePromStatus": "active",
"hmInstancePromCurrentUsage": 0,
"hmInstancePromCurrentActiveSeries": 0,
"hmInstanceGraphiteId": 715518,
"hmInstanceGraphiteUrl": "https://graphite-prod-10-prod-us-central-0.grafana.net",
"hmInstanceGraphiteName": "createcloudstack-graphite",
"hmInstanceGraphiteType": "graphite-v5",
"hmInstanceGraphiteStatus": "active",
"hmInstanceGraphiteCurrentUsage": 0,
"hlInstanceId": 356728,
"hlInstanceUrl": "https://logs-prod-017.grafana.net",
"hlInstanceName": "createcloudstack-logs",
"hlInstanceStatus": "active",
"hlInstanceCurrentUsage": 0,
"amInstanceId": 355710,
"amInstanceName": "createcloudstack1-alerts",
"amInstanceUrl": "https://alertmanager-us-central1.grafana.net",
"amInstanceStatus": "active",
"amInstanceGeneratorUrl": "https://createcloudstack.grafana.net",
"amInstanceGeneratorUrlDatasource": "",
"htInstanceId": 353241,
"htInstanceUrl": "https://tempo-us-central1.grafana.net",
"htInstanceName": "createcloudstack-traces",
"htInstanceStatus": "active",
"regionId": 1,
"regionSlug": "us",
"links": [
{
"rel": "self",
"href": "/instances/507366"
},
{
"rel": "org",
"href": "/orgs/grafanacom"
},
{
"rel": "plugins",
"href": "/instances/507366/plugins"
}
]
}
Перезапуск Grafana
POST https://grafana.com/api/instances/<STACK_SLUG>/restart
Ответы
Могут быть возвращены следующие ответы.
Пример ответа:
true
Создание ключей API размещённого экземпляра Grafana
POST https://grafana.com/api/instances/<STACK_SLUG>/api/auth/keys
Это создаёт ключи API, предназначенные специально для управления вашим размещённым экземпляром Grafana. Это отличается от ключей API Grafana Cloud, создаваемых для операций Grafana Cloud.
Эта конечная точка требует роли Admin.
Тело запроса
Ответы
Могут быть возвращены следующие ответы.
Пример ответа:
{
"id": 1,
"name": "testkey",
"key": "eyJrIjoiMWpSRVhRUVJHZlc3NW1laklzV3htQUt0cUxtS3RuWFUiLCJuIjoidGVzdGtleSIsImlkIjoxf"
}
Получение списка источников данных
GET https://grafana.com/api/instances/<STACK_SLUG>/datasources
Ответы
Могут быть возвращены следующие ответы.
Пример ответа:
{
"items": [
{
"id": 25744816,
"instanceId": 2860016,
"name": "grafanacloud-usage",
"type": "prometheus",
"access": "proxy",
"grafanaOrgId": 1,
"url": "https://billing.grafana.net/api/prom",
"password": "",
"user": "",
"database": "",
"basicAuth": 1,
"basicAuthUser": "65299211",
"withCredentials": 0,
"isDefault": 0,
"jsonData": {
"timeInterval": "60s",
"timeout": "150",
"prometheusVersion": "2.3.0",
"prometheusType": "Mimir"
},
"version": 1,
"editable": 1,
"delete": 0,
"createdAt": "2023-01-04T08:20:13.484927Z",
"updatedAt": null
},
{
"id": 25744915,
"instanceId": 2860016,
"name": "grafanacloud-createcloudstack-logs",
"type": "loki",
"access": "proxy",
"grafanaOrgId": 1,
"url": "https://logs-prod-017.grafana.net",
"password": "",
"user": "",
"database": "",
"basicAuth": 1,
"basicAuthUser": "3567215",
"withCredentials": 0,
"isDefault": 0,
"jsonData": {
"timeout": "300"
},
"version": 1,
"editable": 1,
"delete": 0,
"createdAt": "2023-01-04T08:20:13.625323Z",
"updatedAt": null
}
]
}
Плагины Grafana
API позволяет управлять плагинами, установленными в ваших размещённых экземплярах Grafana.
Найти плагины можно в каталоге плагинов Grafana.
Получение списка плагинов, установленных в экземпляре
GET https://grafana.com/api/instances/<STACK_SLUG>/plugins
Ответы
Могут быть возвращены следующие ответы.
Пример ответа:
{
"items": [
{
"id": 256529,
"instanceId": 507363,
"instanceUrl": "https://createcloudstack.grafana.net",
"pluginId": 663,
"pluginSlug": "grafana-github-datasource",
"pluginName": "GitHub",
"version": "1.3.1",
"latestVersion": "1.3.1",
"createdAt": "2023-01-04T09:33:55.000Z",
"updatedAt": null,
"links": [
{
"rel": "self",
"href": "/instances/507363/plugins/grafana-github-datasource"
},
{
"rel": "instance",
"href": "/instances/507363"
}
]
}
],
"orderBy": "pluginName",
"direction": "asc",
"links": [
{
"rel": "self",
"href": "/instances/createcloudstack/plugins"
}
]
}
Добавление плагина в экземпляр
POST https://grafana.com/api/instances/<STACK_SLUG>/plugins
Тело запроса
Ответы
Могут быть возвращены следующие ответы.
Пример ответа:
{
"id": 256519,
"instanceId": 507363,
"instanceUrl": "https://createcloudstack.grafana.net",
"instanceSlug": "createcloudstack",
"pluginId": 663,
"pluginSlug": "grafana-github-datasource",
"pluginName": "GitHub",
"version": "1.3.1",
"latestVersion": "1.3.1",
"createdAt": "2023-01-04T08:50:42.000Z",
"updatedAt": null,
"links": [
{
"rel": "self",
"href": "/instances/createcloudstack/plugins/grafana-github-datasource"
},
{
"rel": "instance",
"href": "/instances/createcloudstack"
}
]
}
Получение сведений об установленном плагине
GET https://grafana.com/api/instances/<STACK_SLUG>/plugins/<PLUGIN>
Ответы
Могут быть возвращены следующие ответы.
Пример ответа:
{
"id": 256519,
"instanceId": 507363,
"instanceUrl": "https://createcloudstack.grafana.net",
"instanceSlug": "createcloudstack",
"pluginId": 663,
"pluginSlug": "grafana-github-datasource",
"pluginName": "GitHub",
"version": "1.3.1",
"latestVersion": "1.3.1",
"createdAt": "2023-01-04T08:50:42.000Z",
"updatedAt": null,
"links": [
{
"rel": "self",
"href": "/instances/createcloudstack/plugins/grafana-github-datasource"
},
{
"rel": "instance",
"href": "/instances/createcloudstack"
}
]
}
Обновление версии установленного плагина
POST https://grafana.com/api/instances/<STACK_SLUG>/plugins/<PLUGIN>
Тело запроса
Ответы
Могут быть возвращены следующие ответы.
Пример ответа:
{
"id": 256519,
"instanceId": 507363,
"instanceUrl": "https://createcloudstack.grafana.net",
"instanceSlug": "createcloudstack",
"pluginId": 663,
"pluginSlug": "grafana-github-datasource",
"pluginName": "GitHub",
"version": "1.3.0",
"latestVersion": "1.3.1",
"createdAt": "2023-01-04T08:50:42.000Z",
"updatedAt": "2023-01-04T08:55:00.088Z",
"links": [
{
"rel": "self",
"href": "/instances/createcloudstack/plugins/grafana-github-datasource"
},
{
"rel": "instance",
"href": "/instances/createcloudstack"
}
]
}
Удаление установленного плагина
DELETE https://grafana.com/api/instances/<STACK_SLUG>/plugins/<PLUGIN>
Ответы
Могут быть возвращены следующие ответы.
Пример ответа:
{
"id": 256519,
"instanceId": 507363,
"instanceUrl": "https://createcloudstack.grafana.net",
"instanceSlug": "createcloudstack",
"pluginId": 663,
"pluginSlug": "grafana-github-datasource",
"pluginName": "GitHub",
"version": "1.3.1",
"latestVersion": "1.3.1",
"createdAt": "2023-01-04T08:50:42.000Z",
"updatedAt": "2023-01-04T08:59:20.794Z",
"links": [
{
"rel": "self",
"href": "/instances/createcloudstack/plugins/grafana-github-datasource"
},
{
"rel": "instance",
"href": "/instances/createcloudstack"
}
]
}
Регионы
Получение списка регионов
Используйте следующий вызов, чтобы получить список регионов, которые можно указать при создании стека.
GET https://grafana.com/api/stack-regions
Ответы
Могут быть возвращены следующие ответы.
Пример ответа:
{
"items": [
{
"id": 1,
"status": "active",
"slug": "us",
"name": "GCP US Central",
"description": "United States",
"provider": "gcp",
"createdAt": "2021-08-20T20:00:27.000Z",
"updatedAt": "2022-12-12T12:29:37.000Z"
},
{
"id": 2,
"status": "active",
"slug": "us-azure",
"name": "Azure US Central",
"description": "United States (Azure)",
"provider": "azure",
"createdAt": "2021-08-20T20:08:03.000Z",
"updatedAt": "2022-11-29T12:04:00.000Z"
},
{
"id": 3,
"status": "active",
"slug": "eu",
"name": "GCP Belgium",
"description": "Europe",
"provider": "gcp",
"createdAt": "2021-08-20T20:28:52.000Z",
"updatedAt": "2022-12-05T18:05:33.000Z"
},
{
"id": 4,
"status": "active",
"slug": "au",
"name": "GCP Australia",
"description": "Australia",
"provider": "gcp",
"createdAt": "2021-11-16T22:03:18.000Z",
"updatedAt": "2022-09-22T09:27:47.000Z"
}
],
"orderBy": "id",
"direction": "asc",
"total": 9,
"pages": 1,
"pageSize": 1000000,
"page": 1,
"links": [
{
"rel": "self",
"href": "/stack-regions"
}
]
}
Ключи API
Caution
Ключи Cloud API теперь устарели. Используйте вместо них политики доступа Cloud.
Получение списка ключей API
GET https://grafana.com/api/orgs/<ORG_SLUG>/api-keys
Ответы
Могут быть возвращены следующие ответы.
Пример ответа:
{
"items": [
{
"id": 5045812,
"orgId": 652945,
"orgSlug": "grafanacom",
"orgName": "grafanacom",
"instanceId": null,
"name": "SRE",
"role": "Admin",
"createdAt": "2023-01-04T06:43:51.000Z",
"updatedAt": null,
"firstUsed": "2023-01-04T06:44:26.000Z",
"links": [
{
"rel": "self",
"href": "/orgs/grafanacom/api-keys/SRE"
},
{
"rel": "org",
"href": "/orgs/grafanacom"
}
]
}
],
"orderBy": "name",
"direction": "asc",
"links": [
{
"rel": "self",
"href": "/orgs/grafanacom/api-keys"
}
]
}
Создание ключа API
POST https://grafana.com/api/orgs/<ORG_SLUG>/api-keys
Тело запроса
Ответы
Могут быть возвращены следующие ответы.
Пример ответа:
{
"id": 5046212,
"orgId": 652945,
"orgSlug": "grafanacom",
"orgName": "grafanacom",
"instanceId": null,
"name": "createapikey",
"role": "Admin",
"createdAt": "2023-01-04T07:50:54.000Z",
"updatedAt": null,
"firstUsed": null,
"token": "eyJrIjoiZmU5ZDlmY2JkODkzNTg4ZGUyYTJhNmJiZGJiMWYwNjQyMGM0MzBkNiIsIm4iOiJjcmVhdGVhcGlrZXkiLCJpZCI6NjUyOTkyf",
"links": [
{
"rel": "self",
"href": "/orgs/grafanacom/api-keys/createapikey"
},
{
"rel": "org",
"href": "/orgs/grafanacom"
}
]
}
Удаление ключа API
DELETE https://grafana.com/api/orgs/<ORG_SLUG>/api-keys/<API KEY NAME>
Ответы
Могут быть возвращены следующие ответы.
Пример ответа:
true
Оплачиваемое потребление
Этот API позволяет получать оплачиваемое потребление с разбивкой по стекам за указанные год и месяц.
Получение оплачиваемого потребления
GET https://grafana.com/api/orgs/<ORG_SLUG>/billed-usage?month=<MONTH>&year=<YEAR>
Параметры
Ответы
Могут быть возвращены следующие ответы.
Пример ответа:
{
"items": [
{
"id": 1111198068,
"dimensionId": "hl",
"dimensionName": "Logs",
"unit": "GB",
"includedUsage": 50,
"totalUsage": 251.02109133593612,
"overage": 201,
"orgRates": {
"tiers": [
{
"min": 50,
"rate": 0.5
}
]
},
"amountDue": 100.5,
"periodStart": "2024-09-01T00:00:00Z",
"periodEnd": "2024-09-30T23:59:59Z",
"description": "Hosted Logs Usage - September 2024",
"notes": "Per-instance Usage\n - example-logs - Usage: 251.021GB\n\nIncluded Usage: 50GB\nTotal Usage: 251.021GB\nUsage in excess of 50GB: 201GB @ $0.5/GB = $100.50\nTotal Usage Amount: $100.50",
"usages": [
{
"id": 1111163428,
"stackId": 111118,
"periodStart": "2024-09-01T00:00:00Z",
"periodEnd": "2024-09-30T23:59:59Z",
"totalUsage": 251.02109133593612,
"isProrated": false,
"ingestUsage": 251.02109133593612,
"queryUsage": 1255.8636820528654,
"stackName": "example.grafana.net",
"stackLabels": {}
}
]
},
{
"id": 2222297587,
"dimensionId": "hm",
"dimensionName": "Metrics",
"unit": "series",
"includedUsage": 10000,
"totalUsage": 129755.72,
"overage": 119756,
"orgRates": {
"tiers": [
{
"min": 10000,
"rate": 6.5
}
],
"includedDPM": 1
},
"amountDue": 778.41,
"periodStart": "2024-09-01T00:00:00Z",
"periodEnd": "2024-09-30T23:59:59Z",
"description": "Hosted Metrics Usage - September 2024",
"notes": "Per-instance Usage\n - example-prom - Series: 55937, DPM: 132364, Usage: 132364\n Usage pro-rated 2024-09-01 - 2024-09-30: 129756\n\nIncluded Usage: 10000\nTotal Usage: 129756\nUsage in excess of 10000: 119756 @ $6.50/1000 = $778.41\nTotal Usage Amount: $778.41",
"usages": [
{
"id": 1111162008,
"stackId": 111118,
"periodStart": "2024-09-01T00:00:00Z",
"periodEnd": "2024-09-30T23:59:59Z",
"totalUsage": 129755.72,
"isProrated": false,
"activeSeries": 55937,
"dpm": 132364,
"stackName": "example.grafana.net",
"stackLabels": {}
}
]
},
{
"id": 1111195084,
"dimensionId": "hg",
"dimensionName": "Grafana Users",
"unit": "user",
"includedUsage": 3,
"totalUsage": 14,
"overage": 11,
"orgRates": {
"tiers": [
{
"min": 3,
"rate": 8
}
]
},
"amountDue": 88,
"periodStart": "2024-09-01T00:00:00Z",
"periodEnd": "2024-09-30T23:59:59Z",
"description": "Hosted Grafana Usage - September 2024",
"notes": "Per-instance Usage\n - example.grafana.net - Total Unique Users: 14\n\nIncluded Users: 3\nTotal Unique Users: 14\nUsers in excess of 3: 11 @ $8/User = $88.00\nTotal Usage Amount: $88.00",
"usages": [
{
"id": 1111157272,
"stackId": 111118,
"periodStart": "2024-09-01T00:00:00Z",
"periodEnd": "2024-09-30T23:59:59Z",
"totalUsage": 14,
"isProrated": false,
"grafanaUsage": 14,
"onCallUsage": 0,
"stackName": "example.grafana.net",
"stackLabels": {}
}
]
}
]
}