Skip to content

Commit 0d21a45

Browse files
Enable Log Aggregation for Superset (#326)
# Description Add log aggregation
1 parent 2a06c13 commit 0d21a45

65 files changed

Lines changed: 1494 additions & 125 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.

CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22

33
## [Unreleased]
44

5+
### Added
6+
7+
- Log aggregation added ([#326]).
8+
59
### Changed
610

7-
- `operator-rs` `0.31.0` -> `0.34.0` ([#322]).
8-
- Bumped stackable image versions to "23.4.0-rc1" ([#322]).
11+
- `operator-rs` `0.31.0` -> `0.35.0` ([#322], [#326]).
12+
- Bumped stackable image versions to "23.4.0-rc2" ([#322], [#326]).
913
- Fragmented `SupersetConfig` ([#323]).
1014

1115
[#322]: https://github.com/stackabletech/superset-operator/pull/322
1216
[#323]: https://github.com/stackabletech/superset-operator/pull/323
17+
[#326]: https://github.com/stackabletech/superset-operator/pull/326
1318

1419
## [23.1.0] - 2023-01-23
1520

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deploy/helm/superset-operator/crds/crds.yaml

Lines changed: 319 additions & 0 deletions
Large diffs are not rendered by default.

docs/modules/superset/examples/getting_started/superset.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ metadata:
66
spec:
77
image:
88
productVersion: 1.5.1
9-
stackableVersion: 23.4.0-rc1
9+
stackableVersion: 23.4.0-rc2
1010
credentialsSecret: simple-superset-credentials
1111
loadExamplesOnInit: true
1212
nodes:

docs/modules/superset/pages/usage.adoc

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ metadata:
2121
spec:
2222
image:
2323
productVersion: 1.5.1
24-
stackableVersion: 23.4.0-rc1
24+
stackableVersion: 23.4.0-rc2
2525
[...]
2626
authenticationConfig:
2727
authenticationClass: ldap # <1>
@@ -101,6 +101,27 @@ image::superset-databases.png[Superset databases showing the connected Druid clu
101101
The managed Superset instances are automatically configured to export Prometheus metrics. See
102102
xref:home:operators:monitoring.adoc[] for more details.
103103

104+
== Log aggregation
105+
106+
The logs can be forwarded to a Vector log aggregator by providing a discovery
107+
ConfigMap for the aggregator and by enabling the log agent:
108+
109+
[source,yaml]
110+
----
111+
spec:
112+
vectorAggregatorConfigMapName: vector-aggregator-discovery
113+
nodes:
114+
config:
115+
logging:
116+
enableVectorAgent: true
117+
databaseInitialization:
118+
logging:
119+
enableVectorAgent: true
120+
----
121+
122+
Further information on how to configure logging, can be found in
123+
xref:home:concepts:logging.adoc[].
124+
104125
== Configuration & Environment Overrides
105126

106127
The cluster definition also supports overriding configuration properties and environment variables,

examples/superset-with-ldap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ metadata:
150150
spec:
151151
image:
152152
productVersion: 1.5.1
153-
stackableVersion: 23.4.0-rc1
153+
stackableVersion: 23.4.0-rc2
154154
credentialsSecret: superset-with-ldap-server-veri-tls-credentials
155155
nodes:
156156
roleGroups:

rust/crd/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ publish = false
1111
[dependencies]
1212
serde = "1.0"
1313
serde_json = "1.0"
14-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.34.0" }
14+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.35.0" }
1515
strum = { version = "0.24", features = ["derive"] }
1616
snafu = "0.7"
1717
tracing = "0.1"

rust/crd/src/lib.rs

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,23 @@ use stackable_operator::{
1414
kube::{runtime::reflector::ObjectRef, CustomResource},
1515
product_config::flask_app_config_writer::{FlaskAppConfigOptions, PythonType},
1616
product_config_utils::{ConfigError, Configuration},
17+
product_logging::{self, spec::Logging},
1718
role_utils::{Role, RoleGroupRef},
1819
schemars::{self, JsonSchema},
1920
};
20-
use std::{collections::BTreeMap, num::ParseIntError};
21+
use std::collections::BTreeMap;
2122
use strum::{Display, EnumIter, EnumString, IntoEnumIterator};
2223

2324
pub const APP_NAME: &str = "superset";
24-
25+
pub const CONFIG_DIR: &str = "/stackable/config";
26+
pub const LOG_CONFIG_DIR: &str = "/stackable/log_config";
27+
pub const LOG_DIR: &str = "/stackable/log";
2528
pub const PYTHONPATH: &str = "/stackable/app/pythonpath";
2629
pub const SUPERSET_CONFIG_FILENAME: &str = "superset_config.py";
30+
pub const LOG_VOLUME_SIZE_IN_MIB: u32 = 10;
2731

2832
#[derive(Debug, Snafu)]
2933
pub enum Error {
30-
#[snafu(display("invalid int config value"))]
31-
InvalidIntConfigValue { source: ParseIntError },
3234
#[snafu(display("unknown Superset role found {role}. Should be one of {roles:?}"))]
3335
UnknownSupersetRole { role: String, roles: Vec<String> },
3436
#[snafu(display("fragment validation failure"))]
@@ -44,6 +46,7 @@ pub enum SupersetConfigOptions {
4446
RowLimit,
4547
MapboxApiKey,
4648
SupersetWebserverTimeout,
49+
LoggingConfigurator,
4750
AuthType,
4851
AuthUserRegistration,
4952
AuthUserRegistrationRole,
@@ -89,6 +92,7 @@ impl FlaskAppConfigOptions for SupersetConfigOptions {
8992
SupersetConfigOptions::RowLimit => PythonType::IntLiteral,
9093
SupersetConfigOptions::MapboxApiKey => PythonType::Expression,
9194
SupersetConfigOptions::SupersetWebserverTimeout => PythonType::IntLiteral,
95+
SupersetConfigOptions::LoggingConfigurator => PythonType::Expression,
9296
SupersetConfigOptions::AuthType => PythonType::Expression,
9397
SupersetConfigOptions::AuthUserRegistration => PythonType::BoolLiteral,
9498
SupersetConfigOptions::AuthUserRegistrationRole => PythonType::StringLiteral,
@@ -136,6 +140,10 @@ pub struct SupersetClusterSpec {
136140
pub stopped: Option<bool>,
137141
/// The Superset image to use
138142
pub image: ProductImage,
143+
/// Name of the Vector aggregator discovery ConfigMap.
144+
/// It must contain the key `ADDRESS` with the address of the Vector aggregator.
145+
#[serde(skip_serializing_if = "Option::is_none")]
146+
pub vector_aggregator_config_map_name: Option<String>,
139147
pub credentials_secret: String,
140148
pub mapbox_secret: Option<String>,
141149
#[serde(default)]
@@ -144,6 +152,8 @@ pub struct SupersetClusterSpec {
144152
pub authentication_config: Option<SupersetClusterAuthenticationConfig>,
145153
#[serde(default, skip_serializing_if = "Option::is_none")]
146154
pub nodes: Option<Role<SupersetConfigFragment>>,
155+
#[serde(default, skip_serializing_if = "Option::is_none")]
156+
pub database_initialization: Option<supersetdb::SupersetDbConfigFragment>,
147157
/// Specify the type of the created kubernetes service.
148158
/// This attribute will be removed in a future release when listener-operator is finished.
149159
/// Use with caution.
@@ -258,6 +268,26 @@ pub enum SupersetRole {
258268
)]
259269
pub struct SupersetStorageConfig {}
260270

271+
#[derive(
272+
Clone,
273+
Debug,
274+
Deserialize,
275+
Display,
276+
Eq,
277+
EnumIter,
278+
JsonSchema,
279+
Ord,
280+
PartialEq,
281+
PartialOrd,
282+
Serialize,
283+
)]
284+
#[serde(rename_all = "kebab-case")]
285+
#[strum(serialize_all = "kebab-case")]
286+
pub enum Container {
287+
Superset,
288+
Vector,
289+
}
290+
261291
#[derive(Clone, Debug, Default, Fragment, JsonSchema, PartialEq)]
262292
#[fragment_attrs(
263293
derive(
@@ -284,6 +314,8 @@ pub struct SupersetConfig {
284314
/// CPU and memory limits for Superset pods
285315
#[fragment_attrs(serde(default))]
286316
pub resources: Resources<SupersetStorageConfig, NoRuntimeLimits>,
317+
#[fragment_attrs(serde(default))]
318+
pub logging: Logging<Container>,
287319
}
288320

289321
impl SupersetConfig {
@@ -303,6 +335,7 @@ impl SupersetConfig {
303335
},
304336
storage: SupersetStorageConfigFragment {},
305337
},
338+
logging: product_logging::spec::default_logging(),
306339
..Default::default()
307340
}
308341
}

rust/crd/src/supersetdb.rs

Lines changed: 87 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,77 @@
11
use crate::{SupersetCluster, APP_NAME};
22
use serde::{Deserialize, Serialize};
3-
use snafu::Snafu;
4-
use stackable_operator::builder::ObjectMetaBuilder;
5-
use stackable_operator::commons::product_image_selection::{ProductImage, ResolvedProductImage};
6-
use stackable_operator::k8s_openapi::apimachinery::pkg::apis::meta::v1::Time;
7-
use stackable_operator::k8s_openapi::chrono::Utc;
8-
use stackable_operator::kube::CustomResource;
9-
use stackable_operator::kube::ResourceExt;
10-
use stackable_operator::labels::{self, APP_VERSION_LABEL};
11-
use stackable_operator::schemars::{self, JsonSchema};
3+
use snafu::{ResultExt, Snafu};
4+
use stackable_operator::{
5+
builder::ObjectMetaBuilder,
6+
commons::product_image_selection::{ProductImage, ResolvedProductImage},
7+
config::{
8+
fragment::{self, Fragment, ValidationError},
9+
merge::Merge,
10+
},
11+
k8s_openapi::{apimachinery::pkg::apis::meta::v1::Time, chrono::Utc},
12+
kube::CustomResource,
13+
kube::ResourceExt,
14+
labels::{self, APP_VERSION_LABEL},
15+
product_logging::{self, spec::Logging},
16+
schemars::{self, JsonSchema},
17+
};
18+
use strum::{Display, EnumIter};
1219

1320
#[derive(Snafu, Debug)]
1421
#[allow(clippy::enum_variant_names)]
1522
pub enum Error {
16-
#[snafu(display("object is missing metadata to build owner reference"))]
17-
ObjectMissingMetadataForOwnerRef {
18-
source: stackable_operator::error::Error,
19-
},
20-
#[snafu(display("failed to retrieve superset version"))]
21-
NoSupersetVersion,
23+
#[snafu(display("fragment validation failure"))]
24+
FragmentValidationFailure { source: ValidationError },
2225
}
2326
type Result<T, E = Error> = std::result::Result<T, E>;
2427

28+
#[derive(
29+
Clone,
30+
Debug,
31+
Deserialize,
32+
Display,
33+
Eq,
34+
EnumIter,
35+
JsonSchema,
36+
Ord,
37+
PartialEq,
38+
PartialOrd,
39+
Serialize,
40+
)]
41+
#[serde(rename_all = "kebab-case")]
42+
#[strum(serialize_all = "kebab-case")]
43+
pub enum InitDbContainer {
44+
SupersetInitDb,
45+
Vector,
46+
}
47+
48+
#[derive(Clone, Debug, Default, Eq, Fragment, JsonSchema, PartialEq)]
49+
#[fragment_attrs(
50+
derive(
51+
Clone,
52+
Debug,
53+
Default,
54+
Deserialize,
55+
Merge,
56+
JsonSchema,
57+
PartialEq,
58+
Serialize
59+
),
60+
serde(rename_all = "camelCase")
61+
)]
62+
pub struct SupersetDbConfig {
63+
#[fragment_attrs(serde(default))]
64+
pub logging: Logging<InitDbContainer>,
65+
}
66+
67+
impl SupersetDbConfig {
68+
fn default_config() -> SupersetDbConfigFragment {
69+
SupersetDbConfigFragment {
70+
logging: product_logging::spec::default_logging(),
71+
}
72+
}
73+
}
74+
2575
#[derive(Clone, CustomResource, Debug, Deserialize, JsonSchema, PartialEq, Serialize)]
2676
#[kube(
2777
group = "superset.stackable.tech",
@@ -42,6 +92,9 @@ pub struct SupersetDBSpec {
4292
pub image: ProductImage,
4393
pub credentials_secret: String,
4494
pub load_examples: bool,
95+
#[serde(skip_serializing_if = "Option::is_none")]
96+
pub vector_aggregator_config_map_name: Option<String>,
97+
pub config: SupersetDbConfigFragment,
4598
}
4699

47100
impl SupersetDB {
@@ -66,6 +119,18 @@ impl SupersetDB {
66119
image: superset.spec.image.clone(),
67120
credentials_secret: superset.spec.credentials_secret.clone(),
68121
load_examples: superset.spec.load_examples_on_init.unwrap_or_default(),
122+
vector_aggregator_config_map_name: superset
123+
.spec
124+
.vector_aggregator_config_map_name
125+
.clone(),
126+
config: SupersetDbConfigFragment {
127+
logging: superset
128+
.spec
129+
.database_initialization
130+
.clone()
131+
.unwrap_or_default()
132+
.logging,
133+
},
69134
},
70135
status: None,
71136
})
@@ -74,6 +139,13 @@ impl SupersetDB {
74139
pub fn job_name(&self) -> String {
75140
self.name_unchecked()
76141
}
142+
143+
pub fn merged_config(&self) -> Result<SupersetDbConfig, Error> {
144+
let defaults = SupersetDbConfig::default_config();
145+
let mut config = self.spec.config.to_owned();
146+
config.merge(&defaults);
147+
fragment::validate(config).context(FragmentValidationFailureSnafu)
148+
}
77149
}
78150

79151
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, JsonSchema)]

rust/operator-binary/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ publish = false
1010

1111
[dependencies]
1212
anyhow = "1.0"
13-
clap = "4.0"
13+
clap = "4.1"
1414
fnv = "1.0"
1515
futures = { version = "0.3", features = ["compat"] }
1616
indoc = "1.0"
1717
serde = "1.0"
1818
snafu = "0.7"
19-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.34.0" }
19+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.35.0" }
2020
stackable-superset-crd = { path = "../crd" }
2121
strum = { version = "0.24", features = ["derive"] }
22-
tokio = { version = "1.23", features = ["macros", "rt-multi-thread"] }
22+
tokio = { version = "1.25", features = ["macros", "rt-multi-thread"] }
2323
tracing = "0.1"
2424

2525
[build-dependencies]
2626
built = { version = "0.5", features = ["chrono", "git2"] }
27-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.34.0" }
27+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.35.0" }
2828
stackable-superset-crd = { path = "../crd" }

0 commit comments

Comments
 (0)