Skip to content

Commit

Permalink
chore: update cue template
Browse files Browse the repository at this point in the history
  • Loading branch information
kubeJocker committed Oct 24, 2023
1 parent 07e0a0a commit 1db9075
Show file tree
Hide file tree
Showing 16 changed files with 319 additions and 19 deletions.
34 changes: 34 additions & 0 deletions controllers/monitor/builder/cue/engine/engine_template.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
logs: {
include:[string]
}

parameters: {
clusterName: string
componentName: string
containerName: string
metrics: {
enabled: *true | bool
collectionInterval: *"30s" | string
enabled_metrics?: [string]
}
logs: {
enabled: *true | bool
logs_collector?: [logs]
}
}

output: {
"\(parameters.clusterName)/\(parameters.componentName)/\(parameters.containerName)/\(parameters.containerName)": {
enabled_metrics: parameters.metrics.enabled
enabled_logs: parameters.logs.enabled
metrics_collector: {
collection_interval: parameters.collection_interval
if parameters.enabled_metrics != _|_ {
enable_metrics: parameters.enabled_metrics
}
}
if logs.logs_collector != _|_ {
logs_collector: logs.logs_collector
}
}
}
11 changes: 11 additions & 0 deletions controllers/monitor/builder/cue/engine/infra.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
parameters: {
collection_interval: *"15s" | string,
initial_delay: *"10s" | string,
timeout: *"5s" | string,
}

output: {
collection_interval: parameters.collection_interval,
initial_delay: parameters.initial_delay,
timeout: parameters.timeout,
}
5 changes: 0 additions & 5 deletions controllers/monitor/builder/cue/extension/extensions.cue
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

parameters: {
enable: *true | bool
container_runtime_type: *"containerd" | string
}

output: {
extensions: {
memory_ballast:
Expand Down
12 changes: 10 additions & 2 deletions controllers/monitor/builder/cue/processor/processors.cue
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,17 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

output:
memory_limiter:{
output: {
memory_limiter:{
limit_mib: 512
spike_limit_mib: 128
check_interval: "10s"
}
batch: {
send_batch_max_size: 200
send_batch_size: 200
timeout: "5s"
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,24 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

output:
resource_attributes: {
output: {
watch_observers: ["apecloud_engine_observer"]
receivers:{
container_filelog: {
rule: "type == \"container\" && config != nil && config.EnabledLogs"
config: {
input_configs: "`config.LogsCollector`"
container_id: "`container_id`"
pod_ip: "`endpoint`"
storage: "file_storage/oteld"
cluster_name: "`config.ClusterName`"
component_name: "`config.ComponentName`"
character_type: "`config.CharacterType`"
}
}

}
resource_attributes: {
container: {
app_kubernetes_io_component: "`labels[\"app.kubernetes.io/component\"]`"
app_kubernetes_io_instance: "`labels[\"app.kubernetes.io/instance\"]`"
Expand All @@ -30,3 +46,5 @@ output:
job: "oteld-app-metrics"
}
}
}

36 changes: 36 additions & 0 deletions controllers/monitor/builder/cue/receiver/metrics/app/mongodb.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (C) 2022-2023 ApeCloud Co., Ltd
//
// This file is part of KubeBlocks project
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

output:
apecloudmongo: {
rule: "type == \"container\" && monitor_type == \"mongodb\" && config != nil && config.EnabledMetrics"
config: {
endpoint: "`endpoint`:27017"
username: "`envs[\"MONGODB_ROOT_USER\"]`"
password: "`envs[\"MONGODB_ROOT_PASSWORD\"]`"
connect_params: "admin?ssl=false&authSource=admin"
collect_all: true
collection_interval: "`settings.CollectionInterval`"
direct_connect: true
global_conn_pool: false
compatible_mode: true
}
resource_attributes: {
job: oteld-app-metrics
receiver: apecloudmongodb
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ parameters: {
endpoint: *"`endpoint`:3306" | string
username: *"`envs[\"MYSQL_ROOT_USER\"]`" | string
password: *"`envs[\"MYSQL_ROOT_PASSWORD\"]`" | string
allow_native_passwords: *true | bool
transport: *"tcp" | string
collection_interval: *"`settings.CollectionInterval`" | string
}

output:
Expand All @@ -31,8 +28,8 @@ output:
endpoint: parameters.endpoint
username: parameters.username
password: parameters.password
allow_native_passwords: parameters.allow_native_passwords
transport: parameters.transport
allow_native_passwords: true
transport: "tcp"
collection_interval: "`settings.CollectionInterval`"
}
resource_attributes:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright (C) 2022-2023 ApeCloud Co., Ltd
//
// This file is part of KubeBlocks project
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

parameters: {
enpoint: *"`endpoint`:5432" | string
username: *"`envs[\"PGUSER_SUPERUSER\"]`" | string
password: *"`envs[\"PGPASSWORD_SUPERUSER\"]`" | string
job: *"oteld-app-metrics" | string
databases: *["postgres"] | [string]
exclude_databases: *["template0", "template1"] | [string]
}

output:
apecloudpostgresql: {
rule: "type == \"container\" && monitor_type == \"postgresql\" && config != nil && config.EnabledMetrics"
config: {
endpoint: parameters.enpoint
username: parameters.username
password: parameters.password
databases: parameters.databases
exclude_databases: parameters.exclude_databases
collection_interval: "`settings.CollectionInterval`"
transport: "tcp"
tls: {
insecure: true
insecure_skip_verify: true
}
}
resource_attributes: {
job: parameters.job
receiver: "apecloudpostgresql"
}
}
41 changes: 41 additions & 0 deletions controllers/monitor/builder/cue/receiver/metrics/app/pulsar.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (C) 2022-2023 ApeCloud Co., Ltd
//
// This file is part of KubeBlocks project
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

parameters: {
endpoint: *"`endpoint`:8000" | string
}

output: {
"prometheus_simple/pulsar": {
rule: "type == \"container\" && config != nil && config.EnabledMetrics && config.ClusterDefName == \"pulsar\" && ( config.ComponentDefName == \"bookies-recovery\" || config.ComponentDefName == \"zookeeper\" || config.ComponentDefName == \"bookies\" )"
config: {
collection_interval: "settings.CollectionInterval"
use_service_account: false
endpoint: parameters.endpoint
disable_keep_alives: false
}
}
"prometheus_simple/pulsar2": {
rule: "type == \"container\" && config != nil && config.EnabledMetrics && config.ClusterDefName == \"pulsar\" && ( config.ComponentDefName == \"bookies-recovery\" || config.ComponentDefName == \"zookeeper\" || config.ComponentDefName == \"bookies\" )"
config: {
collection_interval: "settings.CollectionInterval"
use_service_account: false
endpoint: parameters.endpoint
disable_keep_alives: false
}
}
}
27 changes: 27 additions & 0 deletions controllers/monitor/builder/cue/receiver/metrics/app/qdrant.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (C) 2022-2023 ApeCloud Co., Ltd
//
// This file is part of KubeBlocks project
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

output:
"prometheus_simple/qdrant": {
rule: "type == \"container\" && config != nil && config.EnabledMetrics && config.ClusterDefName == \"qdrant\" && config.ComponentDefName == \"qdrant\""
config: {
collection_interval: "`settings.CollectionInterval`"
endpoint: "`endpoint`:6333"
disable_keep_alives: false
use_service_account: false
}
}
45 changes: 45 additions & 0 deletions controllers/monitor/builder/cue/receiver/metrics/app/redis.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (C) 2022-2023 ApeCloud Co., Ltd
//
// This file is part of KubeBlocks project
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

parameters: {
job: *"oteld-app-metrics" | string
endpoint: *"`endpoint`:6379" | string
username: *"envs[\"REDIS_REPL_USER\"]" | string
password: *"envs[\"REDIS_REPL_PASSWORD\"]" | string
}

output:
apecloudredis: {
rule: "type == \"container\" && monitor_type == \"redis\" && config != nil && config.EnabledMetrics"
config: {
endpoint: parameters.endpoint
username: parameters.username
password: parameters.password
password_file: ""
lua_script: ""
tls: {
insecure: true
insecure_skip_verify: true
}
collection_interval: "`settings.CollectionInterval`"
}

resource_attributes: {
job: parameters.job
receiver: "apecloudredis"
}
}
34 changes: 34 additions & 0 deletions controllers/monitor/builder/cue/receiver/metrics/app/wescale.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (C) 2022-2023 ApeCloud Co., Ltd
//
// This file is part of KubeBlocks project
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

parameters: {
metrics_path: *"/metrics" | string,
endpoint: *"`endpoint`:`envs[\"VTTABLET_PORT\"]`" | string,
disable_keep_alives: *false | bool,
}

output:
"prometheus_simple/vttablet": {
rule: "type == \"container\" && config != nil && config.EnabledMetrics && config.ComponentDefName == \"mysql\" && config.ClusterDefName == \"apecloud-mysql\" && config.ContainerName == \"vttablet\""
config: {
collection_interval: "`settings.CollectionInterval`"
use_service_account: false
metrics_path: parameters.metrics_path
endpoint: parameters.endpoint
disable_keep_alives: parameters.disable_keep_alives
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

parameters: {
collection_interval: *"15s" | string
job: *"oteld-k8s-cluster-metrics" | string
}


output:
k8s_cluster: {
rule: "type == \"k8s.node\""
Expand All @@ -28,6 +28,7 @@ output:
}
resource_attributes: {
receiver: "k8s_cluster"
job: parameters.job
}
}

Loading

0 comments on commit 1db9075

Please sign in to comment.