Skip to content

Commit f488970

Browse files
feat: Azure blob storage support (#955)
add below env vars - P_AZR_URL=https://.blob.core.windows.net P_AZR_ACCOUNT= P_AZR_CONTAINER= P_AZR_ACCESS_KEY= command to start Parseable with azure blob storage- parseable blob-store Fixes: #687
1 parent 98dd0f4 commit f488970

File tree

5 files changed

+803
-4
lines changed

5 files changed

+803
-4
lines changed

server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ arrow-json = "53.0.0"
1616
arrow-ipc = { version = "53.0.0", features = ["zstd"] }
1717
arrow-select = "53.0.0"
1818
datafusion = "42.0.0"
19-
object_store = { version = "0.11.0", features = ["cloud", "aws"] }
19+
object_store = { version = "0.11.0", features = ["cloud", "aws", "azure"] }
2020
parquet = "53.0.0"
2121
arrow-flight = { version = "53.0.0", features = [ "tls" ] }
2222
tonic = {version = "0.12.3", features = ["tls", "transport", "gzip", "zstd"] }

server/src/metrics/storage.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,42 @@ pub mod s3 {
8686
}
8787
}
8888
}
89+
90+
pub mod azureblob {
91+
use crate::{metrics::METRICS_NAMESPACE, storage::AzureBlobConfig};
92+
use once_cell::sync::Lazy;
93+
use prometheus::{HistogramOpts, HistogramVec};
94+
95+
use super::StorageMetrics;
96+
97+
pub static REQUEST_RESPONSE_TIME: Lazy<HistogramVec> = Lazy::new(|| {
98+
HistogramVec::new(
99+
HistogramOpts::new("azr_blob_response_time", "AzureBlob Request Latency")
100+
.namespace(METRICS_NAMESPACE),
101+
&["method", "status"],
102+
)
103+
.expect("metric can be created")
104+
});
105+
106+
pub static QUERY_LAYER_STORAGE_REQUEST_RESPONSE_TIME: Lazy<HistogramVec> = Lazy::new(|| {
107+
HistogramVec::new(
108+
HistogramOpts::new("query_azr_blob_response_time", "AzureBlob Request Latency")
109+
.namespace(METRICS_NAMESPACE),
110+
&["method", "status"],
111+
)
112+
.expect("metric can be created")
113+
});
114+
115+
impl StorageMetrics for AzureBlobConfig {
116+
fn register_metrics(&self, handler: &actix_web_prometheus::PrometheusMetrics) {
117+
handler
118+
.registry
119+
.register(Box::new(REQUEST_RESPONSE_TIME.clone()))
120+
.expect("metric can be registered");
121+
handler
122+
.registry
123+
.register(Box::new(QUERY_LAYER_STORAGE_REQUEST_RESPONSE_TIME.clone()))
124+
.expect("metric can be registered");
125+
}
126+
}
127+
}

server/src/option.rs

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818

1919
use crate::cli::Cli;
2020
use crate::storage::object_storage::parseable_json_path;
21-
use crate::storage::{FSConfig, ObjectStorageError, ObjectStorageProvider, S3Config};
21+
use crate::storage::{
22+
AzureBlobConfig, FSConfig, ObjectStorageError, ObjectStorageProvider, S3Config,
23+
};
2224
use bytes::Bytes;
2325
use clap::error::ErrorKind;
2426
use clap::{command, Args, Command, FromArgMatches};
@@ -105,6 +107,22 @@ Cloud Native, log analytics platform for modern applications."#,
105107
storage_name: "s3",
106108
}
107109
}
110+
Some(("blob-store", m)) => {
111+
let cli = match Cli::from_arg_matches(m) {
112+
Ok(cli) => cli,
113+
Err(err) => err.exit(),
114+
};
115+
let storage = match AzureBlobConfig::from_arg_matches(m) {
116+
Ok(storage) => storage,
117+
Err(err) => err.exit(),
118+
};
119+
120+
Config {
121+
parseable: cli,
122+
storage: Arc::new(storage),
123+
storage_name: "blob_store",
124+
}
125+
}
108126
_ => unreachable!(),
109127
}
110128
}
@@ -163,11 +181,16 @@ Cloud Native, log analytics platform for modern applications."#,
163181
// returns the string representation of the storage mode
164182
// drive --> Local drive
165183
// s3 --> S3 bucket
184+
// azure_blob --> Azure Blob Storage
166185
pub fn get_storage_mode_string(&self) -> &str {
167186
if self.storage_name == "drive" {
168187
return "Local drive";
188+
} else if self.storage_name == "s3" {
189+
return "S3 bucket";
190+
} else if self.storage_name == "blob_store" {
191+
return "Azure Blob Storage";
169192
}
170-
"S3 bucket"
193+
"Unknown"
171194
}
172195

173196
pub fn get_server_mode_string(&self) -> &str {
@@ -193,6 +216,9 @@ fn create_parseable_cli_command() -> Command {
193216
let s3 = Cli::create_cli_command_with_clap("s3-store");
194217
let s3 = <S3Config as Args>::augment_args_for_update(s3);
195218

219+
let azureblob = Cli::create_cli_command_with_clap("blob-store");
220+
let azureblob = <AzureBlobConfig as Args>::augment_args_for_update(azureblob);
221+
196222
command!()
197223
.name("Parseable")
198224
.bin_name("parseable")
@@ -207,7 +233,7 @@ Join the community at https://logg.ing/community.
207233
"#,
208234
)
209235
.subcommand_required(true)
210-
.subcommands([local, s3])
236+
.subcommands([local, s3, azureblob])
211237
}
212238

213239
#[derive(Debug, Default, Eq, PartialEq)]

server/src/storage.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use chrono::Local;
2424

2525
use std::fmt::Debug;
2626

27+
mod azure_blob;
2728
mod localfs;
2829
mod metrics_layer;
2930
pub(crate) mod object_storage;
@@ -34,6 +35,7 @@ mod store_metadata;
3435

3536
use self::retention::Retention;
3637
pub use self::staging::StorageDir;
38+
pub use azure_blob::AzureBlobConfig;
3739
pub use localfs::FSConfig;
3840
pub use object_storage::{ObjectStorage, ObjectStorageProvider};
3941
pub use s3::S3Config;

0 commit comments

Comments
 (0)