-
Notifications
You must be signed in to change notification settings - Fork 1
security_encryption_metrics
Stand: 5. Dezember 2025
Version: 1.0.0
Kategorie: Security
- Overview
- Metrics Structure
- Operation Counters
- Error Counters
- Performance Metrics
- Data Volume Metrics
- Key Rotation Metrics
- Access via HTTP API
ThemisDB exposes comprehensive encryption metrics for monitoring security operations, performance, and key rotation progress.
themis_encryption_operations_total (Counter)
- Description: Total number of encryption operations
- Labels: None
- Use Case: Track encryption workload
themis_decryption_operations_total (Counter)
- Description: Total number of decryption operations
- Labels: None
- Use Case: Track decryption workload
themis_reencryption_operations_total (Counter)
- Description: Total number of successful lazy re-encryptions
- Labels: None
- Use Case: Monitor key rotation progress
themis_reencryption_skipped_total (Counter)
- Description: Number of re-encryption checks that found data already using latest key
- Labels: None
- Use Case: Identify completion of key rotation
themis_encryption_errors_total (Counter)
- Description: Total number of encryption failures
- Labels: None
- Alerts: Spike indicates key provider issues or memory exhaustion
themis_decryption_errors_total (Counter)
- Description: Total number of decryption failures
- Labels: None
- Alerts: Non-zero indicates data corruption, key mismatch, or tampering attempts
themis_reencryption_errors_total (Counter)
- Description: Total number of lazy re-encryption failures
- Labels: None
- Alerts: Non-zero indicates key rotation issues
themis_encryption_duration_seconds (Histogram)
- Description: Encryption operation latency distribution
-
Buckets:
-
le_100us: ≤ 100 microseconds -
le_500us: ≤ 500 microseconds -
le_1ms: ≤ 1 millisecond -
le_5ms: ≤ 5 milliseconds -
le_10ms: ≤ 10 milliseconds -
gt_10ms: > 10 milliseconds
-
- Use Case: Detect performance degradation
themis_decryption_duration_seconds (Histogram)
- Description: Decryption operation latency distribution
- Buckets: Same as encryption
- Use Case: Monitor read path latency
themis_encryption_bytes_total (Counter)
- Description: Total bytes encrypted
- Labels: None
- Use Case: Storage capacity planning, compliance reporting
themis_decryption_bytes_total (Counter)
- Description: Total bytes decrypted
- Labels: None
- Use Case: Read workload analysis
themis_key_rotation_events_total (Counter)
- Description: Total number of key rotation events
- Labels: None
- Use Case: Audit key lifecycle
Key Rotation Progress (Derived Metric)
-
Formula:
reencrypt_skipped / (reencrypt_operations + reencrypt_skipped) * 100 - Description: Percentage of data already using latest key version
- Target: 100% (all data migrated)
Returns all metrics in Prometheus exposition format:
# TYPE themis_encryption_operations_total counter
themis_encryption_operations_total 1234567
# TYPE themis_decryption_operations_total counter
themis_decryption_operations_total 9876543
# TYPE themis_reencryption_operations_total counter
themis_reencryption_operations_total 45678
# TYPE themis_encryption_duration_le_1ms counter
themis_encryption_duration_le_1ms 1200000
# TYPE themis_encryption_bytes_total counter
themis_encryption_bytes_total 52428800
Returns encryption-specific metrics as JSON:
{
"operations": {
"encrypt_total": 1234567,
"decrypt_total": 9876543,
"reencrypt_total": 45678,
"reencrypt_skipped": 2345
},
"errors": {
"encrypt_errors": 0,
"decrypt_errors": 2,
"reencrypt_errors": 0
},
"performance": {
"encrypt_duration_buckets": {
"le_100us": 800000,
"le_500us": 350000,
"le_1ms": 50000,
"le_5ms": 30000,
"le_10ms": 3500,
"gt_10ms": 1067
},
"decrypt_duration_buckets": {
"le_100us": 7000000,
"le_500us": 2500000,
"le_1ms": 200000,
"le_5ms": 150000,
"le_10ms": 20000,
"gt_10ms": 6543
}
},
"bytes": {
"encrypted_total": 52428800,
"decrypted_total": 419430400
},
"key_rotation": {
"rotation_events": 3,
"migration_progress_percent": 95.2
}
}rate(themis_encryption_operations_total[5m])
rate(themis_decryption_errors_total[5m])
100 * (
themis_reencryption_skipped_total /
(themis_reencryption_operations_total + themis_reencryption_skipped_total)
)
histogram_quantile(0.95,
rate(themis_encryption_duration_le_1ms[5m])
)
rate(themis_encryption_bytes_total[5m]) / 1024 / 1024
HighDecryptionErrorRate
alert: HighDecryptionErrorRate
expr: rate(themis_decryption_errors_total[5m]) > 0.01
for: 5m
severity: critical
annotations:
summary: "Decryption error rate > 1%"
description: "Data corruption or tampering detected"EncryptionPerformanceDegradation
alert: EncryptionPerformanceDegradation
expr: themis_encryption_duration_gt_10ms / themis_encryption_operations_total > 0.05
for: 10m
severity: warning
annotations:
summary: "> 5% of encryptions take > 10ms"
description: "Key provider latency or resource exhaustion"SlowKeyRotation
alert: SlowKeyRotation
expr: |
100 * (
themis_reencryption_skipped_total /
(themis_reencryption_operations_total + themis_reencryption_skipped_total)
) < 50
for: 24h
severity: warning
annotations:
summary: "Key rotation < 50% complete after 24h"
description: "Increase re-encryption rate or check errors"All metrics use std::atomic with memory_order_relaxed for lock-free updates. This ensures:
- Zero contention on hot paths
- Consistent reads (eventual consistency)
- No performance impact on encryption operations
Total memory per FieldEncryption instance:
- 42 counters × 8 bytes = 336 bytes
- Negligible overhead (<0.01% of typical workload)
Metrics are collected at:
-
Encryption Path:
encrypt()entry/exit -
Decryption Path:
decryptToBytes()entry/exit -
Re-Encryption Path:
decryptAndReEncrypt()decision points
Duration tracking uses std::chrono::high_resolution_clock with microsecond precision.
Scenario: Rotate user_pii key from v2 to v3
-
Before Rotation:
reencrypt_operations_total = 0 reencrypt_skipped_total = 0 -
During Rotation (first 1000 reads):
reencrypt_operations_total = 1000 reencrypt_skipped_total = 0 migration_progress = 0% -
Mid-Rotation (50% complete):
reencrypt_operations_total = 50000 reencrypt_skipped_total = 50000 migration_progress = 50% -
After Rotation (all data migrated):
reencrypt_operations_total = 100000 reencrypt_skipped_total = 900000 migration_progress = 90% # Next reads only increment skipped: reencrypt_skipped_total = 1000000 migration_progress = 90.9%
Requirement: Demonstrate encryption of personal data
Evidence:
-
themis_encryption_operations_total > 0(encryption active) -
themis_decryption_errors_total == 0(integrity verified) -
themis_encryption_bytes_total(volume of encrypted data)
Requirement: Key rotation within 12 months
Evidence:
-
themis_key_rotation_events_total >= 1(per year per key) -
migration_progress == 100%(all data migrated) - Grafana dashboard: Time-to-100% migration < 30 days
Causes:
-
Data Corruption: Disk/network errors
- Check: RocksDB metrics, disk SMART status
-
Key Mismatch: Wrong key version after restore
- Check: Vault key version consistency
-
Tampering: Authentication tag failures
- Check: Audit logs for unauthorized access
Resolution:
# Check error details in logs
grep "Decryption failed" server.err | tail -20
# Verify key provider connectivity
curl -k https://vault:8200/v1/sys/health
# Test decryption with known good blob
./test_encryption --verify-blob "known_good.json"Causes:
-
Low Read Rate: Data rarely accessed
- Solution: Proactive bulk re-encryption
-
Re-Encryption Errors:
reencrypt_errors_total > 0- Check: Key provider availability, memory
Resolution:
# Force re-encryption of all data
./admin_tool reencrypt --collection users --field email --key-id user_pii
# Monitor progress
curl http://localhost:8080/api/encryption/metrics | jq '.key_rotation.migration_progress_percent'-
Per-Key Metrics:
themis_encryption_operations_total{key_id="user_pii"}- Requires thread-safe map or metric registry
-
Field-Level Metrics:
themis_encrypted_fields_total{collection="users",field="email"}- Track schema-based encryption coverage
-
HSM Integration Metrics:
themis_hsm_operations_total{operation="sign|verify|encrypt"}- Monitor hardware security module usage
-
Cache Hit Rate:
themis_key_cache_hits / themis_key_cache_total- Optimize key provider caching
- Architecture-ACCESS-MODEL-IMPLEMENTATION-SUMMARY
- Architecture-ADR-003-pg-dump-sql-parser
- Architecture-BASEENTITY-PRINCIPLE
- Architecture-CACHE-STORAGE-INTEGRATION
- Architecture-CMAKE-ARCHITECTURE
- Architecture-CMAKE-FLAGS-REFERENCE
- Architecture-CMAKE-MODULAR-ARCHITECTURE
- Architecture-CONCERNS-ARCHITECTURE-DIAGRAM
- Architecture-CONCERNS-IMPLEMENTATION-SUMMARY
- Architecture-CONTENT-MODEL
- Architecture-COPILOT-THEMISDB-GRAPH-RAG-BACKEND-ARCHITECTURE
- Architecture-CRYPTO-AND-KEYS
- Architecture-FEATURE-FLAGS-REFERENCE
- Architecture-GPU-ARCHITECTURE-REVIEW-TEMPLATE
- Architecture-HTTP-SHUTDOWN-HARDENING
- Architecture-MIGRATION-GUIDE-CONCERNS
- Architecture-MIGRATION-GUIDE-v13-v14
- Architecture-MODULARIZATION-GUIDE
- Architecture-MODULAR-ARCHITECTURE-ROADMAP
- Architecture-MODULE-ARCHITECTURE-INDEX
- Architecture-P1D01-ISSMPLUGIN-DESIGN-REVIEW
- Architecture-P1-D01-ISSMPLUGIN-DESIGN-REVIEW
- Architecture-P1-D08-MAMBA-GOVERNANCE-CONTRACT
- Architecture-P1-P2-IMPLEMENTATION-COMPLETION-INDEX
- Architecture-PHASE0-COMPLETION-ASSESSMENT
- Architecture-PHASE3-QUERYENGINE-DI-ARCHITECTURE
- Architecture-PHASE4-INDEX-MANAGER-DI
- Architecture-POSTGRESQL-WIRE-PROTOCOL
- Architecture-QUERYENGINE-IMPLEMENTATION-GUIDE
- Architecture-QUERY-SCHEDULING
- Architecture-RAFT-CONSENSUS-DESIGN
- Architecture-README
- Architecture-README-SSM-HYBRID-IMPLEMENTATION
- Architecture-REFACTORING-SUMMARY
- Architecture-RESOURCE-POOLING
- Architecture-SOURCE-DIRECTORY-GUIDE
- Architecture-THEMIS-CORE-GUIDE
- Architecture-UNIFIED-ACCESS-MODEL
- Architecture-WAL-GRPC-MTLS-CONFIGURATION
- Architecture-WIRE-PROTOCOL-RETRY
- Architecture-boltzmann-observability-draft
- Architecture-experimental-logarithmic-vector-storage
- Architecture-llm-wiki-mvp-adr
- Architecture-rewrite-engine-architecture
- Architecture-rope-api-architecture
- Architecture-ssm-gguf-mamba-status
- Architecture-ssm-hybrid-analysis
- Architecture-ssm-hybrid-rollout-plan
- Architecture-ssm-plugin-interface-design-review
- Architecture-transaction-coordinators
- Architecture-wiki-secondary-index
- Architecture-wire-protocol
- Governance-DISABLED-STUB-POLICY
- Governance-DOCS-PR-POLICY
- Governance-GA-PROMOTION-SIGN-OFF
- Governance-GITHUB-MILESTONES-SETUP
- Governance-MATURITY-CLAIM-VERIFICATION-CHECKLIST
- Governance-MATURITY-EVIDENCE-REGISTRY
- Governance-MERGE-GATE-BOT-CONFIG
- Governance-MERGE-GATE-STATUS-LIVE
- Governance-PHASE3-ENFORCEMENT-RUNBOOK
- Governance-PHASE-1-CLOSURE-REPORT
- Governance-PHASE-CLOSURE-POLICY
- Governance-PHASE-DEPENDENCY-GRAPH
- Governance-PLUGIN-SUBMODULE-ROLLBACK
- Governance-PRODUCTION-READY-2026-DELIVERY-PLAN
- Governance-PR-VERSION-TARGETING
- Governance-PR-VERSION-TARGETING-BACKFILL
- Governance-QUERY-MODULE-STATUS
- Governance-README
- Governance-RELEASE-PROMOTION-GATE-POLICY
- Governance-RELEASE-VALIDATION-CHECKLIST
- Governance-SECURITY-MODULE-5671-EVIDENCE-SUMMARY
- Governance-SHARDING-P6-RESIDUAL-RISK-ACCEPTANCE
- Governance-SOURCECODE-COMPLIANCE-GOVERNANCE
- Governance-UPDATES-DEVELOPMENT-STATUS-SIGN-OFF
- Governance-WAVE-C-IMPLEMENTATION-COMPLETE
- Module-acceleration-Roadmap
- Module-access-model-Roadmap
- Module-ai-Roadmap
- Module-analytics-Roadmap
- Module-api-Roadmap
- Module-aql-Roadmap
- Module-auth-Roadmap
- Module-base-Roadmap
- Module-cache-Roadmap
- Module-cdc-Roadmap
- Module-chaos-Roadmap
- Module-chimera-Roadmap
- Module-config-Roadmap
- Module-content-Roadmap
- Module-core-Roadmap
- Module-distributed-knowledge-Roadmap
- Module-distributed-tensor-Roadmap
- Module-document-Roadmap
- Module-ethics-ai-Roadmap
- Module-evaluation-Roadmap
- Module-execution-Roadmap
- Module-exporters-Roadmap
- Module-failover-Roadmap
- Module-geo-Roadmap
- Module-governance-Roadmap
- Module-gpu-Roadmap
- Module-graph-Roadmap
- Module-image-analysis-Roadmap
- Module-importers-Roadmap
- Module-index-Roadmap
- Module-ingestion-Roadmap
- Module-llama-cpp-Roadmap
- Module-llm-Roadmap
- Module-llm-streaming-Roadmap
- Module-llm-wiki-Roadmap
- Module-maintenance-Roadmap
- Module-metadata-Roadmap
- Module-network-Roadmap
- Module-observability-Roadmap
- Module-onnx-clip-Roadmap
- Module-performance-Roadmap
- Module-plugins-Roadmap
- Module-process-Roadmap
- Module-projects-Roadmap
- Module-prompt-engineering-Roadmap
- Module-query-Roadmap
- Module-rag-Roadmap
- Module-replication-Roadmap
- Module-retrieval-Roadmap
- Module-rpc-grpc-Roadmap
- Module-scheduler-Roadmap
- Module-scraper-Roadmap
- Module-search-Roadmap
- Module-security-Roadmap
- Module-server-Roadmap
- Module-sharding-Roadmap
- Module-stable-diffusion-Roadmap
- Module-storage-Roadmap
- Module-temporal-Roadmap
- Module-tensor-Roadmap
- Module-themis-Roadmap
- Module-timeseries-Roadmap
- Module-toolbox-Roadmap
- Module-training-Roadmap
- Module-transaction-Roadmap
- Module-updates-Roadmap
- Module-user-storage-encrypted-Roadmap
- Module-utils-Roadmap
- Module-vector-search-Roadmap
- Module-voice-Roadmap
- Module-whisper-Roadmap