OSS Vectors provides access control, Log Management, and CloudMonitor features to ensure data security, compliance, and observability.
Access control
OSS Vectors supports Bucket Policy and RAM Policy.
Bucket Policy: A resource-based authorization policy. You can attach it to a bucket to grant other Alibaba Cloud accounts, RAM users, or anonymous users access to specified vector resources.
RAM Policy: An identity-based authorization policy. You can attach it to RAM users, groups, or roles to define which vector bucket resources they can access.
List of supported actions
API | Action | Description |
oss:PutVectorBucket | Creates a vector bucket. | |
oss:GetVectorBucket | Gets the details of a vector bucket. | |
oss:ListVectorBuckets | Lists all vector buckets owned by the requester. | |
oss:DeleteVectorBucket | Deletes a vector bucket. | |
oss:PutBucketLogging | Enables log storage for a vector bucket. | |
oss:PutObject | When enabling log storage for a source vector bucket, this action writes the logs to another destination bucket. | |
oss:GetBucketLogging | Views the log storage configuration of a vector bucket. | |
oss:DeleteBucketLogging | Disables log storage for a vector bucket. | |
oss:PutBucketPolicy | Sets the authorization policy for a specified vector bucket. | |
oss:GetBucketPolicy | Gets the authorization policy of a specified vector bucket. | |
oss:DeleteBucketPolicy | Deletes the authorization policy of a specified vector bucket. | |
oss:PutVectorIndex | Creates a vector index. | |
oss:GetVectorIndex | Gets the details of a vector index. | |
oss:ListVectorIndexes | Lists all vector indexes in a vector bucket. | |
oss:DeleteVectorIndex | Deletes a vector index. | |
oss:PutVectors | Writes vector data. | |
oss:GetVectors | Gets specified vector data. | |
oss:ListVectors | Lists all vector data in a vector index. | |
oss:QueryVectors | Performs a vector similarity search. | |
oss:DeleteVectors | Deletes specified vector data from a vector index. |
Resource description format
Resource level | Format | Example |
All vector resources |
|
|
Vector bucket |
|
|
Vector index |
|
|
Bucket Policy
You can use a bucket policy to grant RAM users and other Alibaba Cloud accounts access to specified OSS resources.
Console
On the Vector Buckets page, click the destination bucket. In the navigation pane on the left, choose Access Control > Bucket Authorization Policy.
Click Add by Syntax. In the policy editor, enter the policy content. For example, to grant a user with UID 114232345180**** permissions to read and write vector data for the my-index index in the my-vector-bucket bucket:
{ "Version": "1", "Statement": [ { "Effect": "Allow", "Action": [ "oss:PutVectors", "oss:GetVectors" ], "Principal": [ "1142323451******" ], "Resource": [ "acs:ossvector:*:*:my-vector-bucket/my-index" ] } ] }Click OK to complete the creation.
ossutil
The following example shows how to set a bucket policy using a JSON configuration file named vector-policy.json. The file contains the following content:
{
"Version":"1",
"Statement":[
{
"Action":[
"oss:PutVectors",
"oss:GetVectors"
],
"Effect":"Deny",
"Principal":["1234567890"],
"Resource":["acs:ossvector:cn-hangzhou:1234567890:*"]
}
]
}ossutil vectors-api put-bucket-policy --bucket vector-example --body file://vector-policy.json
You can set a bucket policy for a vector bucket using a JSON configuration parameter:
ossutil vectors-api put-bucket-policy --bucket vector-example --body "{\"Version\":\"1\",\"Statement\":[{\"Action\":[\"oss:PutVectors\",\"oss:GetVectors\",\"oss:QueryVectors\"],\"Effect\":\"Allow\",\"Principal\":[\"1234567890\"],\"Resource\":[\"acs:ossvector:cn-hangzhou:1234567890:bucket/vector-example/*\"]}]}"
SDK
Python
import argparse
import alibabacloud_oss_v2 as oss
import alibabacloud_oss_v2.vectors as oss_vectors
parser = argparse.ArgumentParser(description="vector put bucket policy sample")
parser.add_argument('--region', help='The region in which the bucket is located.', required=True)
parser.add_argument('--bucket', help='The name of the bucket.', required=True)
parser.add_argument('--endpoint', help='The endpoint to use for accessing OSS.')
parser.add_argument('--account_id', help='The account id.', required=True)
def main():
args = parser.parse_args()
# Load credentials from environment variables
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Use the SDK's default configuration
cfg = oss.config.load_default()
cfg.credentials_provider = credentials_provider
cfg.region = args.region
cfg.account_id = args.account_id
cfg.use_internal_endpoint = True # To access OSS over the public network, set this to False or delete this line.
if args.endpoint is not None:
cfg.endpoint = args.endpoint
vector_client = oss_vectors.Client(cfg)
policy_content = '''
{
"Version":"1",
"Statement":[
{
"Action":[
"oss:PutVectors",
"oss:GetVectors"
],
"Effect":"Deny",
"Principal":["1234567890"],
"Resource":["acs:ossvector:cn-hangzhou:1234567890:*/*"]
}
]
}
'''
result = vector_client.put_bucket_policy(oss_vectors.models.PutBucketPolicyRequest(
bucket=args.bucket,
body=policy_content
))
print(f'status code: {result.status_code},'
f' request id: {result.request_id},'
)
if __name__ == "__main__":
main()Go
package main
import (
"context"
"flag"
"log"
"strings"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/vectors"
)
var (
region string
bucketName string
accountId string
)
func init() {
flag.StringVar(®ion, "region", "", "The region in which the vector bucket is located.")
flag.StringVar(&bucketName, "bucket", "", "The name of the vector bucket.")
flag.StringVar(&accountId, "account-id", "", "The ID of the vector account.")
}
func main() {
flag.Parse()
if len(bucketName) == 0 {
flag.PrintDefaults()
log.Fatalf("invalid parameters, bucket name required")
}
if len(region) == 0 {
flag.PrintDefaults()
log.Fatalf("invalid parameters, region required")
}
if len(accountId) == 0 {
flag.PrintDefaults()
log.Fatalf("invalid parameters, accounId required")
}
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region).WithAccountId(accountId).
// To access resources over the public network, set this parameter to false or remove this line.
WithUseInternalEndpoint(true)
client := vectors.NewVectorsClient(cfg)
request := &vectors.PutBucketPolicyRequest{
Bucket: oss.Ptr(bucketName),
Body: strings.NewReader(`{
"Version":"1",
"Statement":[
{
"Action":[
"oss:PutVectors",
"oss:GetVectors"
],
"Effect":"Deny",
"Principal":["1234567890"],
"Resource":["acs:ossvector:cn-hangzhou:1234567890:*/*"]
}
]
}`),
}
result, err := client.PutBucketPolicy(context.TODO(), request)
if err != nil {
log.Fatalf("failed to put vector bucket policy %v", err)
}
log.Printf("put vector bucket policy result:%#v\n", result)
}
Java
import com.aliyun.sdk.service.oss2.credentials.CredentialsProvider;
import com.aliyun.sdk.service.oss2.credentials.EnvironmentVariableCredentialsProvider;
import com.aliyun.sdk.service.oss2.OperationInput;
import com.aliyun.sdk.service.oss2.OperationOptions;
import com.aliyun.sdk.service.oss2.OperationOutput;
import com.aliyun.sdk.service.oss2.transport.BinaryData;
import java.util.HashMap;
import java.util.Map;
import com.aliyun.sdk.service.oss2.vectors.OSSVectorsClient;
public class PutBucketPolicySample {
public static void main(String[] args) throws Exception {
CredentialsProvider provider = new EnvironmentVariableCredentialsProvider();
try (OSSVectorsClient client = OSSVectorsClient.newBuilder()
.region("cn-hangzhou")
.accountId("1234567890")
.credentialsProvider(provider)
.build()) {
String policy = "{\n"
+ " \"Version\": \"1\",\n"
+ " \"Statement\": [\n"
+ " {\n"
+ " \"Action\": [\"oss:PutVectors\", \"oss:GetVectors\"],\n"
+ " \"Effect\": \"Deny\",\n"
+ " \"Principal\": [\"1234567890\"],\n"
+ " \"Resource\": [\"acs:ossvector:cn-hangzhou:1234567890:*/*\"]\n"
+ " }\n"
+ " ]\n"
+ "}";
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
Map<String, String> parameters = new HashMap<>();
parameters.put("policy", "");
OperationInput input = OperationInput.newBuilder()
.opName("PutBucketPolicy")
.method("PUT")
.bucket("examplebucket")
.parameters(parameters)
.headers(headers)
.body(BinaryData.fromString(policy))
.build();
OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
System.out.println("status code: " + output.statusCode()
+ ", request id: " + output.headers().get("x-oss-request-id"));
}
}
}API
You can call the PutBucketPolicy operation to set an authorization policy for a vector bucket.
RAM Policy
RAM policies are supported. You can use the Resource Access Management (RAM) console to configure permissions related to vector buckets for RAM users or roles. RAM policies support resource granularity at the index level.
Scenario 1: Grant a RAM user full permissions on a specified vector index
{
"Version": "1",
"Statement": [
{
"Effect": "Allow",
"Action": "*",
"Resource": [
"acs:ossvector:*:*:my-vector-bucket/my-index"
]
}
]
}Scenario 2: Grant a RAM user full control over a vector bucket
{
"Version": "1",
"Statement": [
{
"Effect": "Allow",
"Action": "*",
"Resource": [
"acs:ossvector:*:*:my-vector-bucket",
"acs:ossvector:*:*:my-vector-bucket/*"
]
}
]
} Log Management
The access log feature stores access records in a specified OSS bucket for security audits, performance analysis, and troubleshooting.
Console
On the Vector Buckets page, click the destination bucket. In the navigation pane on the left, choose Log Management > Log Storage.
Turn on the Log Storage switch and configure the following parameters:
Destination Storage Location: Select a bucket to store the log files. The bucket must be in the same region as the vector bucket.
Log Prefix: Set the directory and prefix for the log files, such as
MyLog-.Authorized Role: Use the default log service role AliyunOSSLoggingDefaultRole or select a custom role.
ossutil
The following examples show how to enable log storage for a bucket named examplebucket. The log file prefix is MyLog-, and the access logs are stored in the examplebucket bucket.
-
You can use a JSON configuration file. The bucket-logging-status.json file contains the following content:
{ "BucketLoggingStatus": { "LoggingEnabled": { "TargetBucket": "examplebucket", "TargetPrefix": "MyLog-", "LoggingRole": "AliyunOSSLoggingDefaultRole" } } }Example command:
ossutil vectors-api put-bucket-logging --bucket examplebucket --bucket-logging-status file://bucket-logging-status.json -
You can use JSON configuration parameters. Example command:
ossutil vectors-api put-bucket-logging --bucket examplebucket --bucket-logging-status "{\"BucketLoggingStatus\":{\"LoggingEnabled\":{\"TargetBucket\":\"examplebucket\",\"TargetPrefix\":\"MyLog-\",\"LoggingRole\":\"AliyunOSSLoggingDefaultRole\"}}}"
SDK
Python
import argparse
import alibabacloud_oss_v2 as oss
import alibabacloud_oss_v2.vectors as oss_vectors
parser = argparse.ArgumentParser(description="vector put bucket logging sample")
parser.add_argument('--region', help='The region in which the bucket is located.', required=True)
parser.add_argument('--bucket', help='The name of the bucket.', required=True)
parser.add_argument('--endpoint', help='The endpoint to access OSS')
parser.add_argument('--account_id', help='The account ID.', required=True)
parser.add_argument('--target_bucket', help='The name of the target bucket.', required=True)
def main():
args = parser.parse_args()
# Load credentials from environment variables
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Use the SDK's default configuration
cfg = oss.config.load_default()
cfg.credentials_provider = credentials_provider
cfg.region = args.region
cfg.account_id = args.account_id
cfg.use_internal_endpoint = True # Set to False to use the public network endpoint.
if args.endpoint is not None:
cfg.endpoint = args.endpoint
vector_client = oss_vectors.Client(cfg)
result = vector_client.put_bucket_logging(oss_vectors.models.PutBucketLoggingRequest(
bucket=args.bucket,
bucket_logging_status=oss_vectors.models.BucketLoggingStatus(
logging_enabled=oss_vectors.models.LoggingEnabled(
target_bucket=args.target_bucket,
target_prefix='log-prefix',
logging_role='AliyunOSSLoggingDefaultRole'
)
)
))
print(f'status code: {result.status_code},'
f' request id: {result.request_id},'
)
if __name__ == "__main__":
main()
Go
package main
import (
"context"
"flag"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/vectors"
"log"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
var (
region string
bucketName string
accountId string
)
func init() {
flag.StringVar(®ion, "region", "", "The region in which the vector bucket is located.")
flag.StringVar(&bucketName, "bucket", "", "The name of the vector bucket.")
flag.StringVar(&accountId, "account-id", "", "The id of vector account.")
}
func main() {
flag.Parse()
if len(bucketName) == 0 {
flag.PrintDefaults()
log.Fatalf("invalid parameters, bucket name required")
}
if len(region) == 0 {
flag.PrintDefaults()
log.Fatalf("invalid parameters, region required")
}
if len(accountId) == 0 {
flag.PrintDefaults()
log.Fatalf("invalid parameters, accountId required")
}
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region).WithAccountId(accountId).
// To access OSS over the public internet, set this parameter to false or remove this line.
WithUseInternalEndpoint(true)
client := vectors.NewVectorsClient(cfg)
request := &vectors.PutBucketLoggingRequest{
Bucket: oss.Ptr(bucketName),
BucketLoggingStatus: &vectors.BucketLoggingStatus{
&vectors.LoggingEnabled{
TargetBucket: oss.Ptr("TargetBucket"),
TargetPrefix: oss.Ptr("TargetPrefix"),
LoggingRole: oss.Ptr("AliyunOSSLoggingDefaultRole"),
},
},
}
result, err := client.PutBucketLogging(context.TODO(), request)
if err != nil {
log.Fatalf("failed to put vector bucket logging %v", err)
}
log.Printf("put vector bucket logging result:%#v\n", result)
}
Java
import com.aliyun.sdk.service.oss2.credentials.CredentialsProvider;
import com.aliyun.sdk.service.oss2.credentials.EnvironmentVariableCredentialsProvider;
import com.aliyun.sdk.service.oss2.OperationInput;
import com.aliyun.sdk.service.oss2.OperationOptions;
import com.aliyun.sdk.service.oss2.OperationOutput;
import com.aliyun.sdk.service.oss2.transport.BinaryData;
import java.util.HashMap;
import java.util.Map;
import com.aliyun.sdk.service.oss2.vectors.OSSVectorsClient;
public class PutBucketLoggingSample {
public static void main(String[] args) throws Exception {
CredentialsProvider provider = new EnvironmentVariableCredentialsProvider();
try (OSSVectorsClient client = OSSVectorsClient.newBuilder()
.region("cn-hangzhou")
.accountId("1234567890")
.credentialsProvider(provider)
.build()) {
String loggingConfig = "{\n"
+ " \"BucketLoggingStatus\": {\n"
+ " \"LoggingEnabled\": {\n"
+ " \"TargetBucket\": \"targetbucket\",\n"
+ " \"TargetPrefix\": \"log/\"\n"
+ " }\n"
+ " }\n"
+ "}";
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
Map<String, String> parameters = new HashMap<>();
parameters.put("logging", "");
OperationInput input = OperationInput.newBuilder()
.opName("PutBucketLogging")
.method("PUT")
.bucket("examplebucket")
.parameters(parameters)
.headers(headers)
.body(BinaryData.fromString(loggingConfig))
.build();
OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
System.out.println("status code: " + output.statusCode()
+ ", request id: " + output.headers().get("x-oss-request-id"));
}
}
}API
You can call the PutBucketLogging operation to enable log storage for a vector bucket.
Log file naming convention
Log files use the following naming convention:
<TargetPrefix><SourceBucket>YYYY-mm-DD-HH-MM-SS-UniqueString
|
Parameter |
Description |
|
TargetPrefix |
The prefix for the log file name. |
|
SourceBucket |
The source bucket that generates access logs. |
|
YYYY-mm-DD-HH-MM-SS |
The timestamp in year, month, day, hour, minute, and second format. Logs use hourly granularity: HH=01 covers 01:00:00 to 01:59:59. MM and SS are always 00. |
|
UniqueString |
A system-generated unique identifier for the log file. |
Log format and example
-
Log format
OSS access logs contain information about the requester and the accessed resource. The format is as follows:
RemoteIP Reserved Reserved Time "RequestURL" HTTPStatus SentBytes RequestTime "Referer" "UserAgent" "HostName" "RequestID" "LoggingFlag" "RequesterAliyunID" "Operation" "BucketName" "ObjectName" ObjectSize ServerCostTime "ErrorCode" RequestLength "UserID" DeltaDataSize "SyncRequest" "StorageClass" "TargetStorageClass" "TransmissionAccelerationAccessPoint" "AccessKeyID" "BucketARN"Field
Example
Description
RemoteIP
192.168.0.1
The IP address of the requester.
Reserved
-
A reserved field. The value is always a hyphen (-).
Reserved
-
A reserved field. The value is always a hyphen (-).
Time
03/Jan/2021:14:59:49 +0800
The time when OSS received the request.
RequestURL
GET /example.jpg HTTP/1.0
The request URL that contains a query string.
OSS ignores query string parameters starting with
x-but records them in the access log. Usex-prefixed parameters to tag and locate specific requests.HTTPStatus
200
The HTTP status code returned by OSS.
SentBytes
999131
The downstream traffic generated by the request, in bytes.
RequestTime
127
The request completion time, in milliseconds.
Referer
http://www.aliyun.com/product/oss
The HTTP Referer of the request.
UserAgent
curl/7.15.5
The User-Agent header of the HTTP request.
HostName
examplebucket.oss-cn-hangzhou.aliyuncs.com
The destination domain name.
RequestID
5FF16B65F05BC932307A3C3C
The request ID.
LoggingFlag
true
Indicates whether logging is enabled. Valid values:
-
true: Logging is enabled.
-
false: Logging is not enabled.
RequesterAliyunID
16571836914537****
The user ID of the requester. A hyphen (-) indicates an anonymous request.
Operation
GetObject
The operation performed.
BucketName
examplebucket
The name of the destination bucket.
ObjectName
example.jpg
The name of the destination object.
ObjectSize
999131
The size of the destination object, in bytes.
ServerCostTime
88
The time OSS took to process the request, in milliseconds.
ErrorCode
-
The error code returned by OSS. A hyphen (-) indicates that no error was returned.
RequestLength
302
The length of the request, in bytes.
UserID
16571836914537****
The ID of the bucket owner.
DeltaDataSize
-
The change in the object size. A hyphen (-) indicates the request did not involve a write operation.
SyncRequest
-
The type of request. Valid values:
-
-: A general request.
-
cdn: A CDN origin request.
-
lifecycle: A request to transition or delete data, triggered by a lifecycle rule.
StorageClass
Standard
The storage class of the destination object. Valid values:
-
Standard: Standard.
-
IA: Infrequent Access.
-
Archive: Archive.
-
Cold Archive: Cold Archive.
-
Deep Cold Archive: Deep Cold Archive.
-
-: The object's storage class could not be obtained.
TargetStorageClass
-
The storage class after a lifecycle or CopyObject transition. Valid values:
-
Standard: Changed to Standard.
-
IA: Changed to Infrequent Access.
-
Archive: Changed to Archive.
-
Cold Archive: Changed to Cold Archive.
-
Deep Cold Archive: Changed to Deep Cold Archive.
-
-: No object storage class conversion operation is involved.
TransmissionAccelerationAccessPoint
-
The transfer acceleration endpoint region used to access the bucket. Example: cn-hangzhou for the China (Hangzhou) region.
A hyphen (-) indicates no transfer acceleration domain was used, or the endpoint is in the same region as the bucket.
AccessKeyID
LTAI****************
The AccessKey ID of the requester.
-
For requests from the console, the log field shows a temporary AccessKey ID that starts with TMP.
-
For requests from a tool or an SDK using a long-term key, the log field shows a common AccessKey ID. Example:
LTAI****************. -
For requests using temporary access credentials from Security Token Service (STS), the log shows a temporary AccessKey ID that starts with STS.
NoteA hyphen (-) in this field indicates an anonymous request.
BucketARN
acs:oss***************
The globally unique resource descriptor for the bucket.
-
-
Log example
192.168.0.1 - - [03/Jan/2021:14:59:49 +0800] "GET /example.jpg HTTP/1.0" 200 999131 127 "http://www.aliyun.com/product/oss" "curl/7.15.5" "examplebucket.oss-cn-hangzhou.aliyuncs.com" "5FF16B65F05BC932307A3C3C" "true" "16571836914537****" "GetObject" "examplebucket" "example.jpg" 999131 88 "-" 302 "16571836914537****" - "cdn" "standard" "-" "-" "LTAI****************" "acs:oss***************"Import stored log files into Log Service for analysis. Import OSS data. Query and analysis overview.
Monitoring and usage
Vector buckets are integrated with CloudMonitor. On the Cloud Product Dashboard of CloudMonitor, you can view key usage metrics for vector buckets in real time. These metrics include the number of vector rows and storage capacity.
View monitoring metrics
Log on to the CloudMonitor console.
In the navigation pane on the left, choose Dashboard > Cloud Product Dashboard.
On the Cloud Product Dashboard page, select Object Storage OSS Vector Bucket from the product drop-down list. Then, select the destination region and the vector bucket instance.
On the Overview tab, you can view service quality metrics such as requests, traffic, bandwidth, latency, and SLA. Switch to the Metering Reference tab to view usage metrics for the number of vector rows and total vector storage capacity.
The default collection period is 1 hour. You can switch to a time range of 1 hour, 3 hours, 6 hours, 12 hours, 1 day, 3 days, 7 days, or 14 days.
Configure alert rules
On the Cloud Product Dashboard page, click Create Alert Rule in the upper-right corner. You can set threshold-based alerts based on the number of vector rows or storage capacity. For example, an alert notification can be triggered when the storage capacity exceeds a preset value. This lets you scale out or clear data promptly. For more information, see Create an alert rule.
Supported monitoring metrics
The monitoring metrics for vector buckets are displayed on the Overview and Metering Reference tabs on the Cloud Product Dashboard of CloudMonitor. The Overview tab provides service quality metrics such as the number of requests, queries per second (QPS), bandwidth, server-side average latency, and service-level agreement (SLA). The Metering Reference tab provides usage metrics for the number of vector rows and storage capacity.
Query dimension | Monitoring chart description |
BucketArn |
|
Bucket |
|