Skip to content

Commit

Permalink
Add druid monitoring (#1156)
Browse files Browse the repository at this point in the history
Signed-off-by: Tapajit Chandra Paul <tapajit@appscode.com>
  • Loading branch information
tapojit047 authored Mar 15, 2024
1 parent 3d02083 commit 362c68b
Show file tree
Hide file tree
Showing 6 changed files with 309 additions and 1 deletion.
20 changes: 20 additions & 0 deletions apis/kubedb/v1alpha2/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -952,8 +952,26 @@ const (
DruidExtensionPostgreSQLMetadataStorage = "postgresql-metadata-storage"
DruidExtensionBasicSecurity = "druid-basic-security"
DruidExtensionMultiStageQuery = "druid-multi-stage-query"
DruidExtensionPrometheusEmitter = "prometheus-emitter"
DruidService = "druid.service"

// Monitoring Configurations
DruidEmitter = "druid.emitter"
DruidEmitterPrometheus = "prometheus"
DruidEmitterPrometheusPortKey = "druid.emitter.prometheus.port"
DruidEmitterPrometheusPortVal = 8080
DruidMonitoringMonitorsKey = "druid.monitoring.monitors"
DruidEmitterPrometheusStrategy = "druid.emitter.prometheus.strategy"
DruidMetricsJVMMonitor = "org.apache.druid.java.util.metrics.JvmMonitor"
DruidMetricsServiceStatusMonitor = "org.apache.druid.server.metrics.ServiceStatusMonitor"
DruidMetricsQueryCountStatsMonitor = "org.apache.druid.server.metrics.QueryCountStatsMonitor"
DruidMonitoringHistoricalMetricsMonitor = "org.apache.druid.server.metrics.HistoricalMetricsMonitor"
DruidMonitoringSegmentsStatsMonitor = "org.apache.druid.server.metrics.SegmentStatsMonitor"
DruidMonitoringWorkerTaskCountsStatsMonitor = "org.apache.druid.server.metrics.WorkerTaskCountStatsMonitor"
DruidMonitoringQueryCountStatsMonitor = "org.apache.druid.server.metrics.QueryCountStatsMonitor"
DruidMonitoringTaskCountStatsMonitor = "org.apache.druid.server.metrics.TaskCountStatsMonitor"
DruidMonitoringSysMonitor = "org.apache.druid.java.util.metrics.SysMonitor"

/// Coordinators Configurations
DruidCoordinatorStartDelay = "druid.coordinator.startDelay"
DruidCoordinatorPeriod = "druid.coordinator.period"
Expand All @@ -973,6 +991,8 @@ const (
DruidIndexerLogsKillInitialDelay = "druid.indexer.logs.kill.initialDelay"
DruidIndexerLogsKillDelay = "druid.indexer.logs.kill.delay"

DruidEmitterLoggingLogLevel = "druid.emitter.logging.logLevel"

/// Historicals Configurations
// Properties
DruidProcessingNumOfThreads = "druid.processing.numThreads"
Expand Down
42 changes: 42 additions & 0 deletions apis/kubedb/v1alpha2/druid_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"kubedb.dev/apimachinery/crds"

"github.com/Masterminds/semver/v3"
promapi "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
"gomodules.xyz/pointer"
v1 "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -39,6 +40,7 @@ import (
meta_util "kmodules.xyz/client-go/meta"
"kmodules.xyz/client-go/policy/secomp"
appcat "kmodules.xyz/custom-resources/apis/appcatalog/v1alpha1"
mona "kmodules.xyz/monitoring-agent-api/api/v1"
ofst "kmodules.xyz/offshoot-api/api/v2"
pslister "kubeops.dev/petset/client/listers/apps/v1"
)
Expand Down Expand Up @@ -126,6 +128,46 @@ func (d *Druid) DefaultUserCredSecretName(username string) string {
return meta_util.NameWithSuffix(d.Name, strings.ReplaceAll(fmt.Sprintf("%s-cred", username), "_", "-"))
}

type DruidStatsService struct {
*Druid
}

func (ks DruidStatsService) TLSConfig() *promapi.TLSConfig {
return nil
}

func (ks DruidStatsService) GetNamespace() string {
return ks.Druid.GetNamespace()
}

func (ks DruidStatsService) ServiceName() string {
return ks.OffShootName() + "-stats"
}

func (ks DruidStatsService) ServiceMonitorName() string {
return ks.ServiceName()
}

func (ks DruidStatsService) ServiceMonitorAdditionalLabels() map[string]string {
return ks.OffshootLabels()
}

func (ks DruidStatsService) Path() string {
return DefaultStatsPath
}

func (ks DruidStatsService) Scheme() string {
return ""
}

func (d *Druid) StatsService() mona.StatsAccessor {
return &DruidStatsService{d}
}

func (d *Druid) StatsServiceLabels() map[string]string {
return d.ServiceLabels(StatsServiceAlias, map[string]string{LabelRole: RoleStats})
}

func (d *Druid) ConfigSecretName() string {
return meta_util.NameWithSuffix(d.OffShootName(), "config")
}
Expand Down
5 changes: 5 additions & 0 deletions apis/kubedb/v1alpha2/druid_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
core "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kmapi "kmodules.xyz/client-go/api/v1"
mona "kmodules.xyz/monitoring-agent-api/api/v1"
ofst "kmodules.xyz/offshoot-api/api/v2"
)

Expand Down Expand Up @@ -106,6 +107,10 @@ type DruidSpec struct {
// +optional
Halted bool `json:"halted,omitempty"`

// Monitor is used monitor database instance
// +optional
Monitor *mona.AgentSpec `json:"monitor,omitempty"`

// TerminationPolicy controls the delete operation for database
// +optional
TerminationPolicy TerminationPolicy `json:"terminationPolicy,omitempty"`
Expand Down
29 changes: 28 additions & 1 deletion apis/kubedb/v1alpha2/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions apis/kubedb/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 362c68b

Please sign in to comment.