1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Copyright 2023 Greptime Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Bulk API Log Benchmark Example
//!
//! This benchmark demonstrates the LogTableDataProvider for generating synthetic log data
//! and measuring GreptimeDB bulk API ingestion performance.
//!
//! Note: The bulk API does not automatically create tables. You must manually create the table
//! before running this benchmark using the following schema:
//!
//! ```sql
//! CREATE TABLE IF NOT EXISTS `benchmark_logs` (
//! `ts` TIMESTAMP(3) NOT NULL,
//! `log_uid` STRING NULL,
//! `log_message` STRING NULL,
//! `log_level` STRING NULL,
//! `host_id` STRING NULL,
//! `host_name` STRING NULL,
//! `service_id` STRING NULL,
//! `service_name` STRING NULL,
//! `container_id` STRING NULL,
//! `container_name` STRING NULL,
//! `pod_id` STRING NULL,
//! `pod_name` STRING NULL,
//! `cluster_id` STRING NULL,
//! `cluster_name` STRING NULL,
//! `trace_id` STRING NULL,
//! `span_id` STRING NULL,
//! `user_id` STRING NULL,
//! `session_id` STRING NULL,
//! `request_id` STRING NULL,
//! `response_time_ms` BIGINT NULL,
//! `log_source` STRING NULL,
//! `version` STRING NULL,
//! TIME INDEX (`ts`)
//! )
//! ENGINE=mito
//! WITH(
//! append_mode = 'true',
//! skip_wal = 'true'
//! );
//! ```
//!
//! Usage:
//! cargo run --example bulk_api_log_benchmark --release
//!
//! Environment variables:
//! GREPTIME_ENDPOINT - GreptimeDB endpoint (default: localhost:4001)
//! GREPTIMEDB_DBNAME - Database name (default: public)
//! TABLE_ROW_COUNT - Number of rows to generate (default: 1_000_000)
//! BATCH_SIZE - Batch size for ingestion (default: 64 * 1024)
//! PARALLELISM - Parallel requests (default: 8)
//! COMPRESSION - Enable compression (default: lz4)
use BulkApiBenchmarkRunner;
use ;
async