Skip to content

Commit b9041d2

Browse files
committed
feat: add index to config
1 parent 23b5dec commit b9041d2

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ fn default_blocktime_millis() -> usize {
2626
fn default_consumer() -> String {
2727
"log-ingestor".into()
2828
}
29+
/// Default value for the elastic index
30+
fn default_index() -> String {
31+
"logstash-bec_test123".into()
32+
}
2933

3034
#[derive(Clone, Debug, Deserialize)]
3135
pub struct RedisConfig {
@@ -46,6 +50,8 @@ pub struct ElasticConfig {
4650
pub api_key: String,
4751
#[serde(default = "default_chunk_size")]
4852
pub chunk_size: u16,
53+
#[serde(default = "default_index")]
54+
pub index: String,
4955
}
5056

5157
#[derive(Clone, Debug, Deserialize)]

src/elastic_push.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub async fn consumer_loop(rx: &mut mpsc::UnboundedReceiver<LogRecord>, config:
5353
}
5454
let body = make_json_body(&buffer).unwrap_or(vec![]);
5555
let response = elastic_client
56-
.bulk(elasticsearch::BulkParts::Index("test-index"))
56+
.bulk(elasticsearch::BulkParts::Index(&config.index))
5757
.body(body)
5858
.send()
5959
.await;

src/example_config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ port = 6379
1111
[elastic]
1212
api_key = "RjhrMWY1Z0J4ZjV0T0NJQmIzdjU6ZjVURGdmWmVCM3I3ckd2ZmFLUXl6UQ=="
1313
chunk_size = 100
14+
index = "logstash-bec_test123"
1415

1516
[elastic.url]
1617
url = "http://localhost"

0 commit comments

Comments
 (0)