Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.

- Helm: Allow Pod `priorityClassName` to be configured ([#752]).
- Add support for `34.0.0` ([#755]).
- Add `prometheus.io/path|port|scheme` annotations to metrics services ([#761]).

### Changed

Expand All @@ -31,6 +32,7 @@ All notable changes to this project will be documented in this file.
[#753]: https://github.com/stackabletech/druid-operator/pull/753
[#755]: https://github.com/stackabletech/druid-operator/pull/755
[#756]: https://github.com/stackabletech/druid-operator/pull/756
[#761]: https://github.com/stackabletech/druid-operator/pull/761

## [25.7.0] - 2025-07-23

Expand Down
10 changes: 6 additions & 4 deletions rust/operator-binary/src/druid_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ use crate::{
Container, DB_PASSWORD_ENV, DB_USERNAME_ENV, DRUID_CONFIG_DIRECTORY, DS_BUCKET,
DeepStorageSpec, DruidClusterStatus, DruidRole, EXTENSIONS_LOADLIST, HDFS_CONFIG_DIRECTORY,
JVM_CONFIG, JVM_SECURITY_PROPERTIES_FILE, LOG_CONFIG_DIRECTORY, MAX_DRUID_LOG_FILES_SIZE,
OPERATOR_NAME, RUNTIME_PROPS, RW_CONFIG_DIRECTORY, S3_ACCESS_KEY, S3_ENDPOINT_URL,
S3_PATH_STYLE_ACCESS, S3_SECRET_KEY, STACKABLE_LOG_DIR, ZOOKEEPER_CONNECTION_STRING,
authentication::AuthenticationClassesResolved, authorization::DruidAuthorization,
build_recommended_labels, build_string_list, security::DruidTlsSecurity, v1alpha1,
METRICS_PORT, METRICS_PORT_NAME, OPERATOR_NAME, RUNTIME_PROPS, RW_CONFIG_DIRECTORY,
S3_ACCESS_KEY, S3_ENDPOINT_URL, S3_PATH_STYLE_ACCESS, S3_SECRET_KEY, STACKABLE_LOG_DIR,
ZOOKEEPER_CONNECTION_STRING, authentication::AuthenticationClassesResolved,
authorization::DruidAuthorization, build_recommended_labels, build_string_list,
security::DruidTlsSecurity, v1alpha1,
},
discovery::{self, build_discovery_configmaps},
extensions::get_extension_list,
Expand Down Expand Up @@ -1078,6 +1079,7 @@ fn build_rolegroup_statefulset(
.args(vec![main_container_commands.join("\n")])
.add_env_vars(rest_env)
.add_container_ports(druid_tls_security.container_ports(role))
.add_container_port(METRICS_PORT_NAME, METRICS_PORT.into())
// 10s * 30 = 300s to come up
.startup_probe(druid_tls_security.get_tcp_socket_probe(30, 10, 30, 3))
// 10s * 1 = 10s to get removed from service
Expand Down
18 changes: 17 additions & 1 deletion rust/operator-binary/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use snafu::{ResultExt, Snafu};
use stackable_operator::{
builder::meta::ObjectMetaBuilder,
k8s_openapi::api::core::v1::{Service, ServicePort, ServiceSpec},
kvp::{Label, ObjectLabels},
kvp::{Annotations, Label, ObjectLabels},
role_utils::RoleGroupRef,
};

Expand Down Expand Up @@ -85,6 +85,7 @@ pub fn build_rolegroup_metrics_service(
.with_recommended_labels(object_labels)
.context(MetadataBuildSnafu)?
.with_label(Label::try_from(("prometheus.io/scrape", "true")).context(LabelBuildSnafu)?)
.with_annotations(prometheus_annotations())
.build(),
spec: Some(ServiceSpec {
// Internal communication does not need to be exposed
Expand Down Expand Up @@ -117,3 +118,18 @@ fn rolegroup_metrics_service_name(role_group_ref_object_name: &str) -> String {
pub fn rolegroup_headless_service_name(role_group_ref_object_name: &str) -> String {
format!("{role_group_ref_object_name}-{HEADLESS_SERVICE_SUFFIX}")
}

/// Common annotations for Prometheus
///
/// These annotations can be used in a ServiceMonitor.
///
/// see also <https://github.com/prometheus-community/helm-charts/blob/prometheus-27.32.0/charts/prometheus/values.yaml#L983-L1036>
fn prometheus_annotations() -> Annotations {
Annotations::try_from([
("prometheus.io/path".to_owned(), "/metrics".to_owned()),
("prometheus.io/port".to_owned(), METRICS_PORT.to_string()),
("prometheus.io/scheme".to_owned(), "http".to_owned()),
("prometheus.io/scrape".to_owned(), "true".to_owned()),
])
.expect("should be valid annotations")
}
Loading