Crates.io | opensearch-api |
lib.rs | opensearch-api |
version | 0.1.0 |
created_at | 2025-08-22 08:18:17.183741+00 |
updated_at | 2025-08-22 08:18:17.183741+00 |
description | High-performance REST API gateway for OpenSearch with security, observability and multi-tenant support |
homepage | https://gitlab.com/aerunti/opensearch-api |
repository | https://gitlab.com/aerunti/opensearch-api |
max_upload_size | |
id | 1806060 |
size | 409,758 |
High-performance REST API gateway for OpenSearch with enterprise-grade security, observability, and multi-tenant support.
# Install from crates.io (coming soon)
cargo install opensearch-api
# Build from source
git clone https://gitlab.com/aerunti/opensearch-api.git
cd opensearch-api
cargo build --release
Create a config.toml
file:
[server]
host = "127.0.0.1"
port = 8080
[opensearch]
url = "http://localhost:9200"
username = "admin"
password = "admin"
[security]
api_key_header = "X-API-Key"
rate_limit = 100 # requests per minute
[logging]
level = "info"
format = "json"
# Using cargo
cargo run --release
# Using the binary
./target/release/opensearch-api
# With custom config
OPENSEARCH_API_CONFIG=./my-config.toml opensearch-api
All requests require an API key:
curl -H "X-API-Key: your-api-key" http://localhost:8080/health
curl -X POST http://localhost:8080/api/v1/index/my-index/_doc \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"title": "Example Document",
"content": "This is an example",
"timestamp": "2024-01-01T00:00:00Z"
}'
curl -X POST http://localhost:8080/api/v1/search/my-index \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"query": {
"match": {
"content": "example"
}
}
}'
curl -X POST http://localhost:8080/api/v1/bulk \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/x-ndjson" \
--data-binary @bulk_data.ndjson
Configure tenant isolation in config.toml
:
[tenants]
enabled = true
header = "X-Tenant-ID"
index_prefix = true # Automatically prefix indices with tenant ID
Configure per-API key or global rate limits:
[rate_limiting]
enabled = true
default_limit = 100 # requests per minute
burst_size = 10
[rate_limiting.custom]
"premium-key" = 1000
"basic-key" = 50
Enable comprehensive audit logging:
[audit]
enabled = true
log_requests = true
log_responses = false # Set to true for debugging
index = "audit-logs" # OpenSearch index for audit logs
Prometheus-compatible metrics endpoint:
curl http://localhost:8080/metrics
Available metrics:
opensearch_api_requests_total
- Total requests by endpointopensearch_api_request_duration_seconds
- Request latencyopensearch_api_errors_total
- Error count by typeopensearch_api_active_connections
- Current active connectionsBenchmarks on a standard development machine:
# Development build
cargo build
# Release build with optimizations
cargo build --release
# Run tests
cargo test
# Run benchmarks
cargo bench
We welcome contributions! Please see CONTRIBUTING.md for details.
git checkout -b feature/amazing-feature
)git commit -m 'Add amazing feature'
)git push origin feature/amazing-feature
)This project is dual-licensed under MIT OR Apache-2.0. See LICENSE-MIT and LICENSE-APACHE for details.
Built with ❤️ by Aerun using: