Skip to content

Commit 9d74a2f

Browse files
committed
experimental vector build
1 parent 90a247d commit 9d74a2f

55 files changed

Lines changed: 31546 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

vector/boil-config.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,18 @@ protoc-version = "31.1"
1212
# Note: In UBI10, this should change to 4.23.9.0-4.el10
1313
inotify-tools = "3.22.1.0-1.el9"
1414
rpm-release = "1"
15+
16+
[versions."d10f3a5b892833232002c97f24bf008dbef1eeec".local-images]
17+
# We need to point to a special version of stackable-devel which will have the
18+
# correct toolchain to build vector.
19+
stackable-devel = "vector-build"
20+
stackable-base = "1.0.0"
21+
22+
[versions."d10f3a5b892833232002c97f24bf008dbef1eeec".build-arguments]
23+
# See .scripts/upload_new_protoc_version.sh
24+
# Unsure which version is used by vector. They seem to install `buf` in workflows.
25+
protoc-version = "31.1"
26+
# See here: https://dl.fedoraproject.org/pub/epel/9/Everything/x86_64/Packages/i/
27+
# Note: In UBI10, this should change to 4.23.9.0-4.el10
28+
inotify-tools = "3.22.1.0-1.el9"
29+
rpm-release = "1"

vector/stackable/patches/d10f3a5b892833232002c97f24bf008dbef1eeec/0001-initial-azure_logs_ingestion-implementation.patch

Lines changed: 13654 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
From 0a0b5e087e7df29ba1d31094e9cba9bdd6fc3557 Mon Sep 17 00:00:00 2001
2+
From: Jed Laundry <jlaundry@jlaundry.com>
3+
Date: Sat, 2 Nov 2024 23:16:15 +0000
4+
Subject: tidy up error messages
5+
6+
---
7+
src/sinks/azure_logs_ingestion/service.rs | 23 ++++++++++++-----------
8+
1 file changed, 12 insertions(+), 11 deletions(-)
9+
10+
diff --git a/src/sinks/azure_logs_ingestion/service.rs b/src/sinks/azure_logs_ingestion/service.rs
11+
index 9a7d99eca..ad01bbb05 100644
12+
--- a/src/sinks/azure_logs_ingestion/service.rs
13+
+++ b/src/sinks/azure_logs_ingestion/service.rs
14+
@@ -137,21 +137,26 @@ impl AzureLogsIngestionService {
15+
let res = client.call(request).in_current_span().await?;
16+
17+
if res.status().is_server_error() {
18+
- return Err("Server returned a server error".into());
19+
+ return Err("Azure returned a server error".into());
20+
+ }
21+
+
22+
+ if res.status() == StatusCode::UNAUTHORIZED {
23+
+ return Err("Azure returned 401 Unauthorised. Check that the token_scope matches the soverign cloud endpoint.".into());
24+
}
25+
26+
if res.status() == StatusCode::FORBIDDEN {
27+
- return Err("The service failed to authenticate the request. Verify that the workspace ID and connection key are valid".into());
28+
+ return Err("Azure returned 403 Forbidden. Verify that the credential has the Monitoring Metrics Publisher role on the Data Collection Rule.".into());
29+
}
30+
31+
if res.status() == StatusCode::NOT_FOUND {
32+
- return Err(
33+
- "Either the URL provided is incorrect, or the request is too large".into(),
34+
- );
35+
+ return Err("Azure returned 404 Not Found. Either the URL provided is incorrect, or the request is too large".into());
36+
}
37+
38+
if res.status() == StatusCode::BAD_REQUEST {
39+
- return Err("The workspace has been closed or the request was invalid".into());
40+
+ let body_bytes: Bytes = hyper::body::to_bytes(res.into_body()).await.unwrap();
41+
+ let body_string: String = String::from_utf8(body_bytes.to_vec()).unwrap();
42+
+ let err_string: String = format!("Azure returned 400 Bad Request: {body_string}");
43+
+ return Err(err_string.into());
44+
}
45+
46+
Ok(())
47+
@@ -176,12 +181,8 @@ impl Service<AzureLogsIngestionRequest> for AzureLogsIngestionService {
48+
Box::pin(async move {
49+
let http_request = http_request?;
50+
let response = client.call(http_request).in_current_span().await?;
51+
- let response_status = response.status();
52+
- // let body_bytes: Bytes = hyper::body::to_bytes(response.into_body()).await.unwrap();
53+
- // let body_string: String = String::from_utf8(body_bytes.to_vec()).unwrap();
54+
- // println!("response: {}", body_string);
55+
Ok(AzureLogsIngestionResponse {
56+
- http_status: response_status,
57+
+ http_status: response.status(),
58+
raw_byte_size: request.metadata.request_encoded_size(),
59+
events_byte_size: request
60+
.metadata
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
From 809f9cfe18017b4eafd82d2883a1982b8f80bbf1 Mon Sep 17 00:00:00 2001
2+
From: Jed Laundry <jlaundry@jlaundry.com>
3+
Date: Sat, 2 Nov 2024 23:18:16 +0000
4+
Subject: make token_scope configurable
5+
6+
Signed-off-by: Jed Laundry <jlaundry@jlaundry.com>
7+
---
8+
src/sinks/azure_logs_ingestion/config.rs | 16 ++++++++++++++--
9+
src/sinks/azure_logs_ingestion/service.rs | 5 ++++-
10+
2 files changed, 18 insertions(+), 3 deletions(-)
11+
12+
diff --git a/src/sinks/azure_logs_ingestion/config.rs b/src/sinks/azure_logs_ingestion/config.rs
13+
index 5c1249363..5d5a0ef9c 100644
14+
--- a/src/sinks/azure_logs_ingestion/config.rs
15+
+++ b/src/sinks/azure_logs_ingestion/config.rs
16+
@@ -22,8 +22,9 @@ use super::{
17+
/// Max number of bytes in request body
18+
const MAX_BATCH_SIZE: usize = 30 * 1024 * 1024;
19+
20+
-// Log Ingestion API version
21+
-// const API_VERSION: &str = "2023-01-01";
22+
+pub(super) fn default_scope() -> String {
23+
+ "https://monitor.azure.com/.default".into()
24+
+}
25+
26+
/// Configuration for the `azure_logs_ingestion` sink.
27+
#[configurable_component(sink(
28+
@@ -51,6 +52,14 @@ pub struct AzureLogsIngestionConfig {
29+
#[configurable(metadata(docs::examples = "Custom-MyTable"))]
30+
pub stream_name: String,
31+
32+
+ /// [Token scope][token_scope] for dedicated Azure regions.
33+
+ ///
34+
+ /// [token_scope]: https://learn.microsoft.com/en-us/azure/azure-monitor/logs/logs-ingestion-api-overview
35+
+ #[configurable(metadata(docs::examples = "https://monitor.azure.us/.default"))]
36+
+ #[configurable(metadata(docs::examples = "https://monitor.azure.cn/.default"))]
37+
+ #[serde(default = "default_scope")]
38+
+ pub(super) token_scope: String,
39+
+
40+
#[configurable(derived)]
41+
#[serde(default, skip_serializing_if = "crate::serde::is_default")]
42+
pub encoding: Transformer,
43+
@@ -81,6 +90,7 @@ impl Default for AzureLogsIngestionConfig {
44+
endpoint: Default::default(),
45+
dcr: Default::default(),
46+
stream_name: Default::default(),
47+
+ token_scope: default_scope(),
48+
encoding: Default::default(),
49+
batch: Default::default(),
50+
request: Default::default(),
51+
@@ -96,6 +106,7 @@ impl AzureLogsIngestionConfig {
52+
&self,
53+
cx: SinkContext,
54+
endpoint: UriSerde,
55+
+ token_scope: String,
56+
) -> crate::Result<(VectorSink, Healthcheck)> {
57+
let endpoint = endpoint.with_default_parts().uri;
58+
let protocol = get_http_scheme_from_uri(&endpoint).to_string();
59+
@@ -117,6 +128,7 @@ impl AzureLogsIngestionConfig {
60+
client,
61+
endpoint,
62+
credential,
63+
+ token_scope,
64+
)?;
65+
let healthcheck = service.healthcheck();
66+
67+
diff --git a/src/sinks/azure_logs_ingestion/service.rs b/src/sinks/azure_logs_ingestion/service.rs
68+
index ad01bbb05..a4ff46c55 100644
69+
--- a/src/sinks/azure_logs_ingestion/service.rs
70+
+++ b/src/sinks/azure_logs_ingestion/service.rs
71+
@@ -75,6 +75,7 @@ pub struct AzureLogsIngestionService {
72+
client: HttpClient,
73+
endpoint: Uri,
74+
credential: Arc<dyn TokenCredential>,
75+
+ token_scope: String,
76+
default_headers: HeaderMap,
77+
}
78+
79+
@@ -84,6 +85,7 @@ impl AzureLogsIngestionService {
80+
client: HttpClient,
81+
endpoint: Uri,
82+
credential: Arc<dyn TokenCredential>,
83+
+ token_scope: String,
84+
) -> crate::Result<Self> {
85+
// let mut parts = endpoint.into_parts();
86+
// parts.path_and_query = Some(
87+
@@ -104,6 +106,7 @@ impl AzureLogsIngestionService {
88+
client,
89+
endpoint,
90+
credential,
91+
+ token_scope,
92+
default_headers,
93+
})
94+
}
95+
@@ -113,7 +116,7 @@ impl AzureLogsIngestionService {
96+
97+
// TODO: make this an option, for soverign clouds
98+
let access_token = executor::block_on(self.credential
99+
- .get_token(&["https://monitor.azure.com/.default"]))
100+
+ .get_token(&[&self.token_scope]))
101+
.expect("failed to get access token from credential");
102+
103+
let bearer = format!("Bearer {}", access_token.token.secret());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
From 8acb7b19800288b92380e4a398ca019ed61c93ea Mon Sep 17 00:00:00 2001
2+
From: Jed Laundry <jlaundry@jlaundry.com>
3+
Date: Sat, 2 Nov 2024 23:22:14 +0000
4+
Subject: parameterise the dcr_immutable_id and stream_name
5+
6+
Signed-off-by: Jed Laundry <jlaundry@jlaundry.com>
7+
---
8+
src/sinks/azure_logs_ingestion/config.rs | 25 +++++++++++++++--------
9+
src/sinks/azure_logs_ingestion/service.rs | 22 ++++++++++++--------
10+
2 files changed, 31 insertions(+), 16 deletions(-)
11+
12+
diff --git a/src/sinks/azure_logs_ingestion/config.rs b/src/sinks/azure_logs_ingestion/config.rs
13+
index 5d5a0ef9c..711ceae98 100644
14+
--- a/src/sinks/azure_logs_ingestion/config.rs
15+
+++ b/src/sinks/azure_logs_ingestion/config.rs
16+
@@ -40,11 +40,11 @@ pub struct AzureLogsIngestionConfig {
17+
#[configurable(metadata(docs::examples = "https://my-dce-5kyl.eastus-1.ingest.monitor.azure.com"))]
18+
pub endpoint: String,
19+
20+
- /// The [Data collection rule][dcr] for the Data collection endpoint.
21+
+ /// The [Data collection rule immutable ID][dcr_immutable_id] for the Data collection endpoint.
22+
///
23+
- /// [dcr]: https://learn.microsoft.com/en-us/azure/azure-monitor/logs/logs-ingestion-api-overview
24+
+ /// [dcr_immutable_id]: https://learn.microsoft.com/en-us/azure/azure-monitor/logs/logs-ingestion-api-overview
25+
#[configurable(metadata(docs::examples = "dcr-000a00a000a00000a000000aa000a0aa"))]
26+
- pub dcr: String,
27+
+ pub dcr_immutable_id: String,
28+
29+
/// The [Stream name][stream_name] for the Data collection rule.
30+
///
31+
@@ -88,7 +88,7 @@ impl Default for AzureLogsIngestionConfig {
32+
fn default() -> Self {
33+
Self {
34+
endpoint: Default::default(),
35+
- dcr: Default::default(),
36+
+ dcr_immutable_id: Default::default(),
37+
stream_name: Default::default(),
38+
token_scope: default_scope(),
39+
encoding: Default::default(),
40+
@@ -106,6 +106,8 @@ impl AzureLogsIngestionConfig {
41+
&self,
42+
cx: SinkContext,
43+
endpoint: UriSerde,
44+
+ dcr_immutable_id: String,
45+
+ stream_name: String,
46+
token_scope: String,
47+
) -> crate::Result<(VectorSink, Healthcheck)> {
48+
let endpoint = endpoint.with_default_parts().uri;
49+
@@ -127,6 +129,8 @@ impl AzureLogsIngestionConfig {
50+
let service = AzureLogsIngestionService::new(
51+
client,
52+
endpoint,
53+
+ dcr_immutable_id,
54+
+ stream_name,
55+
credential,
56+
token_scope,
57+
)?;
58+
@@ -156,10 +160,15 @@ impl_generate_config_from_default!(AzureLogsIngestionConfig);
59+
#[typetag::serde(name = "azure_logs_ingestion")]
60+
impl SinkConfig for AzureLogsIngestionConfig {
61+
async fn build(&self, cx: SinkContext) -> crate::Result<(VectorSink, Healthcheck)> {
62+
- // https://my-dce-5kyl.eastus-1.ingest.monitor.azure.com/dataCollectionRules/dcr-000a00a000a00000a000000aa000a0aa/streams/Custom-MyTable?api-version=2023-01-01
63+
- // let endpoint = format!("{}/dataCollectionRules/{}/streams/{}", self.endpoint, self.dcr, self.stream_name).parse()?;
64+
- let endpoint = self.endpoint.parse()?;
65+
- self.build_inner(cx, endpoint).await
66+
+
67+
+ let endpoint: UriSerde = self.endpoint.parse()?;
68+
+ self.build_inner(
69+
+ cx,
70+
+ endpoint,
71+
+ self.dcr_immutable_id.clone(),
72+
+ self.stream_name.clone(),
73+
+ self.token_scope.clone(),
74+
+ ).await
75+
}
76+
77+
fn input(&self) -> Input {
78+
diff --git a/src/sinks/azure_logs_ingestion/service.rs b/src/sinks/azure_logs_ingestion/service.rs
79+
index a4ff46c55..757ccc5a7 100644
80+
--- a/src/sinks/azure_logs_ingestion/service.rs
81+
+++ b/src/sinks/azure_logs_ingestion/service.rs
82+
@@ -15,7 +15,10 @@ use tracing::Instrument;
83+
84+
use crate::{http::HttpClient, sinks::prelude::*};
85+
86+
-// JSON content type of logs
87+
+/// Log Ingestion API version
88+
+const API_VERSION: &str = "2023-01-01";
89+
+
90+
+/// JSON content type of logs
91+
const CONTENT_TYPE: &str = "application/json";
92+
93+
static CONTENT_TYPE_VALUE: LazyLock<HeaderValue> =
94+
@@ -84,16 +87,19 @@ impl AzureLogsIngestionService {
95+
pub fn new(
96+
client: HttpClient,
97+
endpoint: Uri,
98+
+ dcr_immutable_id: String,
99+
+ stream_name: String,
100+
credential: Arc<dyn TokenCredential>,
101+
token_scope: String,
102+
) -> crate::Result<Self> {
103+
- // let mut parts = endpoint.into_parts();
104+
- // parts.path_and_query = Some(
105+
- // format!("a9ee8e5b-ed0e-4980-9b9c-15e1f939db7f?api-version={API_VERSION}")
106+
- // .parse()
107+
- // .expect("query should never fail to parse"),
108+
- // );
109+
- // let endpoint = Uri::from_parts(parts)?;
110+
+ let mut parts = endpoint.into_parts();
111+
+ parts.path_and_query = Some(
112+
+ // https://my-dce-5kyl.eastus-1.ingest.monitor.azure.com/dataCollectionRules/dcr-000a00a000a00000a000000aa000a0aa/streams/Custom-MyTable?api-version=2023-01-01
113+
+ format!("/dataCollectionRules/{dcr_immutable_id}/streams/{stream_name}?api-version={API_VERSION}")
114+
+ .parse()
115+
+ .expect("path and query should never fail to parse"),
116+
+ );
117+
+ let endpoint = Uri::from_parts(parts)?;
118+
119+
let default_headers = {
120+
let mut headers = HeaderMap::new();
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
From 1609a631cc1b2e2b3e1abd556455dcb20a4ad28b Mon Sep 17 00:00:00 2001
2+
From: Jed Laundry <jlaundry@jlaundry.com>
3+
Date: Sat, 2 Nov 2024 23:30:57 +0000
4+
Subject: spelling mistake
5+
6+
---
7+
src/sinks/azure_logs_ingestion/service.rs | 2 +-
8+
1 file changed, 1 insertion(+), 1 deletion(-)
9+
10+
diff --git a/src/sinks/azure_logs_ingestion/service.rs b/src/sinks/azure_logs_ingestion/service.rs
11+
index 757ccc5a7..7c593c456 100644
12+
--- a/src/sinks/azure_logs_ingestion/service.rs
13+
+++ b/src/sinks/azure_logs_ingestion/service.rs
14+
@@ -150,7 +150,7 @@ impl AzureLogsIngestionService {
15+
}
16+
17+
if res.status() == StatusCode::UNAUTHORIZED {
18+
- return Err("Azure returned 401 Unauthorised. Check that the token_scope matches the soverign cloud endpoint.".into());
19+
+ return Err("Azure returned 401 Unauthorised. Check that the token_scope matches the sovereign cloud endpoint.".into());
20+
}
21+
22+
if res.status() == StatusCode::FORBIDDEN {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
From e1a61da6161e1bdcf60d12ae052001caffbc6746 Mon Sep 17 00:00:00 2001
2+
From: Jed Laundry <jlaundry@jlaundry.com>
3+
Date: Fri, 17 Jan 2025 22:06:03 +1300
4+
Subject: add reminder from upstream changes
5+
6+
---
7+
src/sinks/azure_logs_ingestion/config.rs | 2 ++
8+
1 file changed, 2 insertions(+)
9+
10+
diff --git a/src/sinks/azure_logs_ingestion/config.rs b/src/sinks/azure_logs_ingestion/config.rs
11+
index 711ceae98..0b2a8f3aa 100644
12+
--- a/src/sinks/azure_logs_ingestion/config.rs
13+
+++ b/src/sinks/azure_logs_ingestion/config.rs
14+
@@ -123,6 +123,8 @@ impl AzureLogsIngestionConfig {
15+
// https://github.com/Azure/azure-sdk-for-rust/blob/main/sdk/identity/azure_identity/CHANGELOG.md
16+
let credential: Arc<dyn TokenCredential> = azure_identity::create_credential()?;
17+
18+
+ // TODO this needs to change with toolchain 1.83.0, as per commit ca084cc (#22068)
19+
+ //let tls_settings = TlsSettings::from_options(self.tls.as_ref())?;
20+
let tls_settings = TlsSettings::from_options(&self.tls)?;
21+
let client = HttpClient::new(Some(tls_settings), &cx.proxy)?;
22+

0 commit comments

Comments
 (0)