すべての推奨インデックスを返す
Performance Advisor が提案するインデックスを返します。Performance Advisor は MongoDB が遅いと判断したクエリをモニターし、クエリ パフォーマンスを改善するための新しいインデックスを提案します。このリソースを使用するには、リクエスト元のサービス アカウントまたは API キーにプロジェクトの読み取り専用ロールが必要です。
path パラメータ
-
プロジェクトを識別する一意の 24 桁の 16 進数文字列。 認証済みユーザーがアクセスできるすべてのプロジェクトを取得するには、 /groups エンドポイントを使用します。
注: グループとプロジェクトは同義語です。そのため、グループ ID はプロジェクト ID と同じです。既存のグループの場合、グループ/プロジェクト ID は同じままです。リソースおよび対応するエンドポイントでは、グループという用語が使用されます。
形式は次のパターンと一致する必要があります:
^([a-f0-9]{24})$
。 -
クラスターを識別する人間が判読できるラベル。
形式は次のパターンと一致する必要があります:
^[a-zA-Z0-9][a-zA-Z0-9-]*$
。
クエリ パラメータ
-
推奨されたインデックスを検索する ProcessId 。 ProcessId は、MongoDB プロセスを提供するホストとポートの組み合わせです。 ホストは、MongoDB プロセス(
mongod
またはmongos
)を実行するホストのホスト名、FQDN、IPv 4アドレス、または IPv 6アドレスである必要があります。 ポートは MongoDB プロセスがリクエストをリッスンする IANA ポートである必要があります。 複数のprocessIdを含めるには、各processIdの間をアンパサンド(&
)で区切って、パラメーターを複数回渡します。各 の形式は次のパターンと一致する必要があります:
^([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-f]{1,4}\:){7}([0-9a-f]{1,4})|(([a-z0-9]+\.){1,10}[a-z]+)?(\:[0-9]{4,5})$
。 -
推奨されたインデックスを検索する名前空間。名前空間は 1 件のデータベースと 1 件のコレクション リソースで構成され、
.
:<database>.<collection>
と記述されます。複数の名前空間を含めるには、各名前空間の間をアンパサンド (&
) で区切って、パラメーターを複数回渡します。このパラメーターを省略すると、すべての名前空間の結果が返されます。 -
クエリが推奨インデックスを取得する日時。このパラメータは、 UNIXエポックから経過したミリ秒数で値を表します。
- into パラメーターを指定しない場合、エンドポイントはsince値から現在の時刻までのデータを返します。
- sinceパラメーターもsinceパラメーターも指定しない場合、エンドポイントは過去の24時間のデータを返します。
の最小値は
1199145600000
です。 -
クエリが推奨インデックスを取得する日時。このパラメータは、 UNIXエポック から経過したミリ秒数で値を表します。
- into パラメーターを指定する場合は、 sinceパラメーターを指定する必要があります。
- sinceパラメーターもsinceパラメーターも指定しない場合、エンドポイントは過去の24時間のデータを返します。
の最小値は
1199145600000
です。
atlas api performanceAdvisor listGroupClusterPerformanceAdvisorSuggestedIndexes --help
import (
"os"
"context"
"log"
sdk "go.mongodb.org/atlas-sdk/v20240805001/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.ListGroupClusterPerformanceAdvisorSuggestedIndexesApiParams{}
sdkResp, httpResp, err := client.PerformanceAdvisorApi.
ListGroupClusterPerformanceAdvisorSuggestedIndexesWithParams(ctx, params).
Execute()
}
curl --include --header "Authorization: Bearer ${ACCESS_TOKEN}" \
--header "Accept: application/vnd.atlas.2024-08-05+json" \
-X GET "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/performanceAdvisor/suggestedIndexes?pretty=true"
curl --user "${PUBLIC_KEY}:${PRIVATE_KEY}" \
--digest --include \
--header "Accept: application/vnd.atlas.2024-08-05+json" \
-X GET "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/performanceAdvisor/suggestedIndexes?pretty=true"
{
"shapes": [
{
"avgMs": 42,
"count": 42,
"id": "32b6e34b3d91647abb20e7b8",
"inefficiencyScore": 42,
"namespace": "string",
"operations": [
{
"predicates": [
{}
],
"stats": {
"ms": 42,
"nReturned": 42,
"nScanned": 42,
"ts": 42
}
}
]
}
],
"suggestedIndexes": [
{
"avgObjSize": 42.0,
"id": "32b6e34b3d91647abb20e7b8",
"impact": [
"string"
],
"index": [
{
"additionalProperty1": 1,
"additionalProperty2": 1
}
],
"namespace": "string",
"weight": 42.0
}
]
}
{
"error": 400,
"detail": "(This is just an example, the exception may not be related to this endpoint) No provider AWS exists.",
"reason": "Bad Request",
"errorCode": "VALIDATION_ERROR"
}
{
"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": 429,
"detail": "(This is just an example, the exception may not be related to this endpoint)",
"reason": "Too Many Requests",
"errorCode": "RATE_LIMITED"
}
{
"error": 500,
"detail": "(This is just an example, the exception may not be related to this endpoint)",
"reason": "Internal Server Error",
"errorCode": "UNEXPECTED_ERROR"
}