Retornar um alerta de um projeto
Retorna um alerta. Esse alerta se aplica a qualquer componente em um projeto. Você recebe um alerta quando um componente monitorado atinge ou excede um valor definido por você. Para usar esse recurso, a conta de serviço ou a chave de API solicitante deve ter a função somente leitura do projeto. Use o ponto de extremidade Retornar todos os alertas de um projeto para recuperar todos os alertas aos quais o usuário autenticado tem acesso.
Este recurso permanece sob revisão e pode mudar.
parâmetros de caminho
-
Sequência única de 24dígitos hexadecimais que identifica seu projeto. Use o endpoint /groups para extrair todos os projetos aos quais o usuário autenticado tem acesso.
AVISO: grupos e projetos são termos sinônimos. O ID do seu grupo é igual ao ID do seu projeto. Para grupos existentes, o ID do grupo/projeto permanece o mesmo. O recurso e os endpoints correspondentes usam o termo grupos.
O formato deve corresponder ao seguinte padrão:
^([a-f0-9]{24})$
. -
String exclusiva de 24 dígitos hexadecimais que identifica o alerta.
O formato deve corresponder ao seguinte padrão:
^([a-f0-9]{24})$
.
parâmetros de query
-
Sinalizador que indica se o aplicativo empacota a resposta em um objeto JSON
envelope
. Alguns clientes de API não podem acessar os cabeçalhos de resposta HTTP ou o código de status. Para corrigir isso, defina envelope=true na consulta. Os endpoints que retornam uma lista de resultados usam o objeto de resultados como um envelope. O aplicativo adiciona o parâmetro de status ao corpo da resposta.O valor padrão é
false
. -
Sinalizador que indica se o corpo da resposta deve estar no formato prettyprint.
O valor padrão é
false
.Prettyprint
atlas api alerts getGroupAlert --help
import (
"os"
"context"
"log"
sdk "go.mongodb.org/atlas-sdk/v20231115001/admin"
)
func main() {
ctx := context.Background()
clientID := os.Getenv("MONGODB_ATLAS_CLIENT_ID")
clientSecret := os.Getenv("MONGODB_ATLAS_CLIENT_SECRET")
// See https://dochub.mongodb.org/core/atlas-go-sdk-oauth
client, err := sdk.NewClient(sdk.UseOAuthAuth(clientID, clientSecret))
if err != nil {
log.Fatalf("Error: %v", err)
}
params = &sdk.GetGroupAlertApiParams{}
sdkResp, httpResp, err := client.AlertsApi.
GetGroupAlertWithParams(ctx, params).
Execute()
}
curl --include --header "Authorization: Bearer ${ACCESS_TOKEN}" \
--header "Accept: application/vnd.atlas.2023-11-15+json" \
-X GET "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/alerts/{alertId}?pretty=true"
curl --user "${PUBLIC_KEY}:${PRIVATE_KEY}" \
--digest --include \
--header "Accept: application/vnd.atlas.2023-11-15+json" \
-X GET "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/alerts/{alertId}?pretty=true"
{
"acknowledgedUntil": "2025-05-04T09:42:00Z",
"acknowledgementComment": "Expiration on 3/19. Silencing for 7days.",
"acknowledgingUsername": "hello@example.com",
"alertConfigId": "32b6e34b3d91647abb20e7b8",
"created": "2025-05-04T09:42:00Z",
"eventTypeName": "DEPLOYMENT_FAILURE",
"groupId": "32b6e34b3d91647abb20e7b8",
"id": "32b6e34b3d91647abb20e7b8",
"lastNotified": "2025-05-04T09:42:00Z",
"links": [
{
"href": "https://cloud.mongodb.com/api/atlas",
"rel": "self"
}
],
"orgId": "32b6e34b3d91647abb20e7b8",
"resolved": "2025-05-04T09:42:00Z",
"status": "OPEN",
"updated": "2025-05-04T09:42:00Z"
}
{
"acknowledgedUntil": "2025-05-04T09:42:00Z",
"acknowledgementComment": "Expiration on 3/19. Silencing for 7days.",
"acknowledgingUsername": "hello@example.com",
"alertConfigId": "32b6e34b3d91647abb20e7b8",
"clusterName": "cluster1",
"created": "2025-05-04T09:42:00Z",
"eventTypeName": "CLUSTER_MONGOS_IS_MISSING",
"groupId": "32b6e34b3d91647abb20e7b8",
"id": "32b6e34b3d91647abb20e7b8",
"lastNotified": "2025-05-04T09:42:00Z",
"links": [
{
"href": "https://cloud.mongodb.com/api/atlas",
"rel": "self"
}
],
"orgId": "32b6e34b3d91647abb20e7b8",
"resolved": "2025-05-04T09:42:00Z",
"status": "OPEN",
"updated": "2025-05-04T09:42:00Z"
}
{
"acknowledgedUntil": "2025-05-04T09:42:00Z",
"acknowledgementComment": "Expiration on 3/19. Silencing for 7days.",
"acknowledgingUsername": "hello@example.com",
"alertConfigId": "32b6e34b3d91647abb20e7b8",
"clusterName": "cluster1",
"created": "2025-05-04T09:42:00Z",
"eventTypeName": "HOST_DOWN",
"groupId": "32b6e34b3d91647abb20e7b8",
"hostnameAndPort": "cloud-test.mongodb.com:27017",
"id": "32b6e34b3d91647abb20e7b8",
"lastNotified": "2025-05-04T09:42:00Z",
"links": [
{
"href": "https://cloud.mongodb.com/api/atlas",
"rel": "self"
}
],
"orgId": "32b6e34b3d91647abb20e7b8",
"replicaSetName": "event-replica-set",
"resolved": "2025-05-04T09:42:00Z",
"status": "OPEN",
"updated": "2025-05-04T09:42:00Z"
}
{
"acknowledgedUntil": "2025-05-04T09:42:00Z",
"acknowledgementComment": "Expiration on 3/19. Silencing for 7days.",
"acknowledgingUsername": "hello@example.com",
"alertConfigId": "32b6e34b3d91647abb20e7b8",
"clusterName": "cluster1",
"created": "2025-05-04T09:42:00Z",
"currentValue": {
"number": 42.0,
"units": "bits"
},
"eventTypeName": "OUTSIDE_METRIC_THRESHOLD",
"groupId": "32b6e34b3d91647abb20e7b8",
"hostnameAndPort": "cloud-test.mongodb.com:27017",
"id": "32b6e34b3d91647abb20e7b8",
"lastNotified": "2025-05-04T09:42:00Z",
"links": [
{
"href": "https://cloud.mongodb.com/api/atlas",
"rel": "self"
}
],
"metricName": "ASSERT_USER",
"orgId": "32b6e34b3d91647abb20e7b8",
"replicaSetName": "event-replica-set",
"resolved": "2025-05-04T09:42:00Z",
"status": "OPEN",
"updated": "2025-05-04T09:42:00Z"
}
{
"acknowledgedUntil": "2025-05-04T09:42:00Z",
"acknowledgementComment": "Expiration on 3/19. Silencing for 7days.",
"acknowledgingUsername": "hello@example.com",
"alertConfigId": "32b6e34b3d91647abb20e7b8",
"clusterName": "cluster1",
"created": "2025-05-04T09:42:00Z",
"eventTypeName": "NO_PRIMARY",
"groupId": "32b6e34b3d91647abb20e7b8",
"hostnameAndPort": "cloud-test.mongodb.com:27017",
"id": "32b6e34b3d91647abb20e7b8",
"lastNotified": "2025-05-04T09:42:00Z",
"links": [
{
"href": "https://cloud.mongodb.com/api/atlas",
"rel": "self"
}
],
"nonRunningHostIds": [
"32b6e34b3d91647abb20e7b8"
],
"orgId": "32b6e34b3d91647abb20e7b8",
"parentClusterId": "32b6e34b3d91647abb20e7b8",
"replicaSetName": "event-replica-set",
"resolved": "2025-05-04T09:42:00Z",
"status": "OPEN",
"updated": "2025-05-04T09:42:00Z"
}
{
"acknowledgedUntil": "2025-05-04T09:42:00Z",
"acknowledgementComment": "Expiration on 3/19. Silencing for 7days.",
"acknowledgingUsername": "hello@example.com",
"alertConfigId": "32b6e34b3d91647abb20e7b8",
"created": "2025-05-04T09:42:00Z",
"eventTypeName": "HOST_DOWN",
"groupId": "32b6e34b3d91647abb20e7b8",
"id": "32b6e34b3d91647abb20e7b8",
"instanceName": "foobar",
"lastNotified": "2025-05-04T09:42:00Z",
"links": [
{
"href": "https://cloud.mongodb.com/api/atlas",
"rel": "self"
}
],
"orgId": "32b6e34b3d91647abb20e7b8",
"processorErrorMsg": "MongoServerError: Failed to start stream processor: (Location77175) Could not connect to the Kafka topic with kafka error code: -195, message: Local: Broker transport failure.: (Location77175)",
"processorName": "foobar",
"processorState": "STARTED",
"resolved": "2025-05-04T09:42:00Z",
"status": "OPEN",
"updated": "2025-05-04T09:42:00Z"
}
{
"acknowledgedUntil": "2025-05-04T09:42:00Z",
"acknowledgementComment": "Expiration on 3/19. Silencing for 7days.",
"acknowledgingUsername": "hello@example.com",
"alertConfigId": "32b6e34b3d91647abb20e7b8",
"created": "2025-05-04T09:42:00Z",
"eventTypeName": "CREDIT_CARD_ABOUT_TO_EXPIRE",
"groupId": "32b6e34b3d91647abb20e7b8",
"id": "32b6e34b3d91647abb20e7b8",
"lastNotified": "2025-05-04T09:42:00Z",
"links": [
{
"href": "https://cloud.mongodb.com/api/atlas",
"rel": "self"
}
],
"orgId": "32b6e34b3d91647abb20e7b8",
"resolved": "2025-05-04T09:42:00Z",
"status": "OPEN",
"updated": "2025-05-04T09:42:00Z"
}
{
"error": 401,
"detail": "(This is just an example, the exception may not be related to this endpoint)",
"reason": "Unauthorized",
"errorCode": "NOT_ORG_GROUP_CREATOR"
}
{
"error": 403,
"detail": "(This is just an example, the exception may not be related to this endpoint)",
"reason": "Forbidden",
"errorCode": "CANNOT_CHANGE_GROUP_NAME"
}
{
"error": 404,
"detail": "(This is just an example, the exception may not be related to this endpoint) Cannot find resource AWS",
"reason": "Not Found",
"errorCode": "RESOURCE_NOT_FOUND"
}
{
"error": 500,
"detail": "(This is just an example, the exception may not be related to this endpoint)",
"reason": "Internal Server Error",
"errorCode": "UNEXPECTED_ERROR"
}