Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add database monitor #3934

Merged
merged 33 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
37fd64e
add: restserver for database monitor
sakcer Aug 22, 2023
d22a3d9
add: victoriaMetrics for database monitor
sakcer Aug 23, 2023
8e47217
Delete req.go.bak
sakcer Aug 23, 2023
4634e1b
fix: change database monitor server directory
sakcer Aug 23, 2023
027d2cd
fix: change database monitor server directory
sakcer Aug 23, 2023
d367dad
Update vmstorage.yaml
sakcer Aug 23, 2023
0b71bce
fix: blocks without displaying an error
sakcer Aug 24, 2023
fcb9d6d
Merge branch 'dev' of github.com:sakcer/sealos into dev
sakcer Aug 24, 2023
7f91de8
fix: database monitor
sakcer Sep 13, 2023
dc64204
Merge branch 'main' of github.com:sakcer/sealos
sakcer Sep 13, 2023
2ab5f8d
Update services.yml
sakcer Sep 13, 2023
0fe3814
fix: database monitor
sakcer Sep 13, 2023
2607fcd
Merge branch 'main' of github.com:sakcer/sealos
sakcer Sep 13, 2023
3fa42a9
fix: database monitor
sakcer Sep 13, 2023
6610f3a
fix: database monitor
sakcer Sep 13, 2023
7262ff3
fix: database monitor
sakcer Sep 13, 2023
c86c98f
fix: database monitor
sakcer Sep 13, 2023
a30300a
fix: database monitor
sakcer Sep 13, 2023
a7b44aa
Update go.work
sakcer Sep 13, 2023
44c87d7
Update vmagent.yaml
sakcer Sep 13, 2023
842c05b
Update vmagent.yaml
sakcer Sep 13, 2023
1b6ddfa
Update vminsert.yaml
sakcer Sep 13, 2023
9b3cb3e
Update vmselect.yaml
sakcer Sep 13, 2023
dff6fa1
Update vmstorage.yaml
sakcer Sep 13, 2023
8e1f389
fix: database monitor
sakcer Sep 13, 2023
ac40b9f
fix: database monitor
sakcer Sep 13, 2023
20dc73e
fix: database monitor
sakcer Sep 13, 2023
337cd91
fix: database monitor
sakcer Sep 13, 2023
0669cd5
fix: database monitor
sakcer Sep 15, 2023
1846fe2
fix: database monitor
sakcer Sep 15, 2023
1a2cb3a
Merge branch 'labring:main' into main
sakcer Sep 15, 2023
9bf0aeb
fix: authentication and query
sakcer Sep 15, 2023
825695b
fix: authentication and query
sakcer Sep 15, 2023
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: 1 addition & 1 deletion .github/workflows/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
module: [ hub ]
module: [ hub, database ]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions go.work
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use (
./controllers/node
./controllers/user
./controllers/resources
./service/database
./service/hub
./service/payment
./staging/src/github.com/labring/image-cri-shim
Expand Down
9 changes: 9 additions & 0 deletions service/database/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# FROM scratch
FROM gcr.io/distroless/static:nonroot
# FROM gengweifeng/gcr-io-distroless-static-nonroot
ARG TARGETARCH
COPY bin/service-database-$TARGETARCH /manager
EXPOSE 9090
USER 65532:65532

ENTRYPOINT ["/manager"]
55 changes: 55 additions & 0 deletions service/database/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
IMG ?= ghcr.io/labring/sealos-database-service:latest

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif

# only support linux, non cgo
PLATFORMS ?= linux_arm64 linux_amd64
GOOS=linux
CGO_ENABLED=0
GOARCH=$(shell go env GOARCH)

GO_BUILD_FLAGS=-trimpath -ldflags "-s -w"

.PHONY: all
all: build

##@ General

# The help target prints out all targets with their descriptions organized
# beneath their categories. The categories are represented by '##@' and the
# target descriptions by '##'. The awk commands is responsible for reading the
# entire set of makefiles included in this invocation, looking for lines of the
# file as xyz: ## something, and then pretty-format the target and help. Then,
# if there's a line with ##@ something, that gets pretty-printed as a category.
# More info on the usage of ANSI control characters for terminal formatting:
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
# More info on the awk command:
# http://linuxcommand.org/lc3_adv_awk.php

.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

##@ Build

.PHONY: clean
clean:
rm -f $(SERVICE_NAME)

.PHONY: build
build: clean ## Build service-hub binary.
CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) go build $(GO_BUILD_FLAGS) -o bin/manager main.go

.PHONY: docker-build
docker-build: build
mv bin/manager bin/service-database-${TARGETARCH}
docker build -t $(IMG) .

.PHONY: docker-push
docker-push:
docker push $(IMG)
54 changes: 54 additions & 0 deletions service/database/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# RESTServer

## Description

restserver for database monitoring

## Getting Started

### Running on the cluster

1. Build and push your image to the location specified by `IMG`:

```sh
make docker-build docker-push IMG=<some-registry>/sealos-cloud-database-monitor:tag
```

2. Deploy the restserver:

```sh
kubectl apply -f deploy/manifests/
```

### How it works

To enable the database frontend application to retrieve monitoring data, you need to modify the environment variable `MONITOR_URL` of the frontend deployment to the corresponding address of the restserver.

Additionally, to configure the data source, you need to set the environment variable `PROMETHEUS_SERVICE_HOST` of the restserver deployment to the correct address.

```
e.g.
http://prometheus.sealos.svc.cluster.local
```

## License

Copyright 2023.

Licensed under the Apache License, Version 2.0 (the "License");

you may not use this file except in compliance with the License.

You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software

distributed under the License is distributed on an "AS IS" BASIS,

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and

limitations under the License.
136 changes: 136 additions & 0 deletions service/database/api/req.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
package api

import "errors"

type PromRequest struct {
User string
Pwd string
NS string
Type string
Query string
Cluster string
Range PromRange
// Match_old PromMatch
}

type PromMetric struct {
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why use this empty struct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it can be deleted


// type PromMatch struct {
// Ns string `mapstructure:"namespace"`
// Po string `mapstructure:"pod"`
// Inst string `mapstructure:"instance"`
// Datname string `mapstructure:"datname"`
// Cluster string `mapstructure:"app_kubernetes_io_instance"`
// }

type PromRange struct {
Start string `mapstructure:"start"`
End string `mapstructure:"end"`
Step string `mapstructure:"step"`
Time string `mapstructure:"time"`
}

type QueryResult struct {
Status string `json:"status"`
Data struct {
ResultType string `json:"resultType"`
Result []struct {
Metric map[string]string `json:"metric"`
Values [][]interface{} `json:"values"`
Value []interface{} `json:"value"`
} `json:"result"`
} `json:"data"`
}

var (
ErrNoAuth = errors.New("no permission for this namespace")
ErrNoSealosHost = errors.New("unable to get the sealos host")
ErrNoPromHost = errors.New("unable to get the prometheus host")
ErrUncompleteParam = errors.New("at least provide both namespace and query")
ErrEmptyKubeconfig = errors.New("empty kubeconfig")
ErrNilNs = errors.New("namespace not found")
)

var (
Mysql = map[string]string{
"cpu": "round(max by (pod) (rate(container_cpu_usage_seconds_total{namespace=~\"#\",pod=~\"@-mysql-\\\\d\",container=\"mysql\" }[5m])) / on (pod) (max by (pod) (container_spec_cpu_quota{namespace=~\"#\", pod=~\"@-mysql-\\\\d\",container=\"mysql\"} / 100000)) * 100,0.01)",
"memory": "round(max by (pod)(container_memory_usage_bytes{namespace=~\"#\",pod=~\"@-mysql-\\\\d\",container=\"mysql\"})/ on (pod) (max by (pod) (container_spec_memory_limit_bytes{namespace=~\"#\", pod=~\"@-mysql-\\\\d\", container=\"mysql\"})) * 100,0.01)",
"disk_capacity": "(max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_capacity_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-mysql-\\\\d\"}))",
"disk_used": "(max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_used_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-mysql-\\\\d\"}))",
"disk": "round((max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_used_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-mysql-\\\\d\"})) / (max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_capacity_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-mysql-\\\\d\"})) * 100, 0.01)",
// "disk": "max by (persistentvolumeclaim,namespace,type) (label_replace(kubelet_volume_stats_capacity_bytes{namespace=~\"#\", persistentvolumeclaim=~\"data-@-mysql-\\\\d\"},\"type\",\"capacity\",\"__name__\", \"(.+)\")) or max by (persistentvolumeclaim,namespace,type) (label_replace(kubelet_volume_stats_used_bytes{namespace=~\"#\", persistentvolumeclaim=~\"data-@-mysql-\\\\d\"},\"type\",\"used\",\"__name__\", \"(.+)\"))",
"uptime": "sum(mysql_global_status_uptime{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}) by (namespace,app_kubernetes_io_instance,pod)",
"connections": "sum(max_over_time(mysql_global_status_threads_connected{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[1m])) by (namespace,app_kubernetes_io_instance,pod)",
"commands": "topk(5, rate(mysql_global_status_commands_total{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[1m]) > 0)",

"innodb": "sum(mysql_global_variables_innodb_buffer_pool_size{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}) by (namespace,app_kubernetes_io_instance,pod)",
"slow_queries": "sum(rate(mysql_global_status_slow_queries{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[1m])) by (namespace,app_kubernetes_io_instance,pod)",

// "hits_ratio": "(rate(mysql_global_status_table_open_cache_hits{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[5m]))/((rate(mysql_global_status_table_open_cache_hits{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[5m]))+(rate(mysql_global_status_table_open_cache_misses{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[5m])))"

"aborted_connections": "sum(rate(mysql_global_status_aborted_connects{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[1m])) by (namespace,app_kubernetes_io_instance,pod)",
"table_locks": "sum(rate(mysql_global_status_table_locks_immediate{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[1m])) by (namespace,app_kubernetes_io_instance,pod)",
}
Pgsql = map[string]string{
// "cpu": "round(max by (pod) (rate(container_cpu_usage_seconds_total{namespace=~\"#\",pod=~\"@-postgresql-\\\\d\" ,container=\"postgresql\"}[5m])) / on (pod) (max by (pod) (kube_pod_container_resource_limits{namespace=~\"#\", pod=~\"@-postgresql-\\\\d\", resource=\"cpu\",container=\"postgresql\"})) * 100,0.01)",
"cpu": "round(max by (pod) (rate(container_cpu_usage_seconds_total{namespace=~\"#\",pod=~\"@-postgresql-\\\\d\" ,container=\"postgresql\"}[5m])) / on (pod) (max by (pod) (container_spec_cpu_quota{namespace=~\"#\", pod=~\"@-postgresql-\\\\d\",container=\"postgresql\"} / 100000)) * 100,0.01)",

"memory": "round(max by (pod)(container_memory_usage_bytes{namespace=~\"#\",pod=~\"@-postgresql-\\\\d\",container=\"postgresql\" })/ on (pod) (max by (pod) (container_spec_memory_limit_bytes{namespace=~\"#\", pod=~\"@-postgresql-\\\\d\", container=\"postgresql\"})) * 100,0.01)",
"disk": "round((max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_used_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-postgresql-\\\\d\"})) / (max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_capacity_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-postgresql-\\\\d\"})) * 100, 0.01)",
// "disk": "max by (persistentvolumeclaim,namespace,type) (label_replace(kubelet_volume_stats_capacity_bytes{namespace=~\"#\", persistentvolumeclaim=~\"data-@-postgresql-\\\\d\"},\"type\",\"capacity\",\"__name__\", \"(.+)\")) or max by (persistentvolumeclaim,namespace,type) (label_replace(kubelet_volume_stats_used_bytes{namespace=~\"#\", persistentvolumeclaim=~\"data-@-postgresql-\\\\d\"},\"type\",\"used\",\"__name__\", \"(.+)\"))",
"disk_capacity": "(max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_capacity_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-postgresql-\\\\d\"}))",
"disk_used": "(max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_used_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-postgresql-\\\\d\"}))",
"uptime": "avg (time() - pg_postmaster_start_time_seconds{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}) by(namespace, app_kubernetes_io_instance, pod)",
"connections": "sum(pg_stat_database_numbackends{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"})",
"commands": "sum by (command,app_kubernetes_io_instance)(label_replace(rate(pg_stat_database_tup_deleted{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[1m]),\"command\",\"delete\",\"namespace\",\"(.*)\")) or sum by (command,app_kubernetes_io_instance)(label_replace(rate(pg_stat_database_tup_inserted{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[1m]),\"command\",\"insert\",\"namespace\",\"(.*)\")) or sum by (command,app_kubernetes_io_instance)(label_replace(rate(pg_stat_database_tup_fetched{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[1m]),\"command\",\"fetch\",\"namespace\",\"(.*)\")) or sum by (command,app_kubernetes_io_instance)(label_replace(rate(pg_stat_database_tup_returned{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[1m]),\"command\",\"return\",\"namespace\",\"(.*)\")) or sum by (command,app_kubernetes_io_instance)(label_replace(rate(pg_stat_database_tup_updated{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[1m]),\"command\",\"update\",\"namespace\",\"(.*)\"))",

"db_size": "pg_database_size_bytes{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}",

// "hits_ratio": "round(100*sum(pg_stat_database_blks_hit{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}) by (namespace, app_kubernetes_io_instance)/ (sum by (namespace, app_kubernetes_io_instance) (pg_stat_database_blks_hit{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}) + sum by (namespace, app_kubernetes_io_instance) (pg_stat_database_blks_read{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"})) ,0.1)"

"active_connections": " pg_stat_activity_count{namespace=~\"#\", app_kubernetes_io_instance=~\"@\",state=\"active\"}",
// "commits": "label_replace(rate (pg_stat_database_xact_rollback{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[1m]) ,\"command\",\"rollback\", \"namespace\",\"(.+)\") or label_replace(rate (pg_stat_database_xact_commit{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[1m]) ,\"command\",\"commit\", \"namespace\",\"(.+)\")",
"rollbacks": "rate (pg_stat_database_xact_rollback{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[1m])",
"commits": "rate (pg_stat_database_xact_commit{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[1m])",
"tx_duration": "max without(state) (max_over_time(pg_stat_activity_max_tx_duration{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[1m]))",
"block_read_time": "rate(pg_stat_database_blk_read_time{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[1m])",
"block_write_time": "rate(pg_stat_database_blk_write_time{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[1m])",
}

Mongo = map[string]string{
"cpu": "round(max by (pod) (rate(container_cpu_usage_seconds_total{namespace=~\"#\",pod=~\"@-mongodb-\\\\d\" ,container=\"mongodb\" }[5m])) / on (pod) (max by (pod) (container_spec_cpu_quota{namespace=~\"#\", pod=~\"@-mongodb-\\\\d\" ,container=\"mongodb\"} / 100000)) * 100,0.01)",
"memory": "round(max by (pod)(container_memory_usage_bytes{namespace=~\"#\",pod=~\"@-mongodb-\\\\d\" ,container=\"mongodb\"})/ on (pod) (max by (pod) (container_spec_memory_limit_bytes{namespace=~\"#\", pod=~\"@-mongodb-\\\\d\",container=\"mongodb\"})) * 100,0.01)",
"disk_capacity": "(max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_capacity_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-mongodb-\\\\d\"}))",
"disk": "round((max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_used_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-mongodb-\\\\d\"})) / (max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_capacity_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-mongodb-\\\\d\"})) * 100, 0.01)",
// "disk": "max by (persistentvolumeclaim,namespace,type) (label_replace(kubelet_volume_stats_capacity_bytes{namespace=~\"#\", persistentvolumeclaim=~\"data-@-mongodb-\\\\d\"},\"type\",\"capacity\",\"__name__\", \"(.+)\")) or max by (persistentvolumeclaim,namespace,type) (label_replace(kubelet_volume_stats_used_bytes{namespace=~\"#\", persistentvolumeclaim=~\"data-@-mongodb-\\\\d\"},\"type\",\"used\",\"__name__\", \"(.+)\"))",
"disk_used": "(max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_used_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-mongodb-\\\\d\"}))",
"uptime": "sum by(namespace, app_kubernetes_io_instance, pod) (mongodb_instance_uptime_seconds{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"})",
"connections": "mongodb_connections{namespace=~\"#\", app_kubernetes_io_instance=~\"@\", state=~\"current\"}",
"commands": "label_replace(rate(mongodb_op_counters_total{namespace=~\"#\", app_kubernetes_io_instance=~\"@\", type!=\"command\"}[1m]) or irate(mongodb_op_counters_total{namespace=~\"#\", app_kubernetes_io_instance=~\"@\", type!=\"command\"}[1m]), \"command\", \"$1\", \"type\", \"(.*)\")",

"db_size": "mongodb_dbstats_dataSize{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}",

"document_ops": "rate(mongodb_mongod_metrics_document_total{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[1m])",
"pg_faults": "rate(mongodb_extra_info_page_faults_total{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[1m]) or irate(mongodb_extra_info_page_faults_total{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[1m])",
}

Redis = map[string]string{
"cpu": "round(max by (pod) (rate(container_cpu_usage_seconds_total{namespace=~\"#\",pod=~\"@-redis-\\\\d\" ,container=\"redis\"}[5m])) / on (pod) (max by (pod) (container_spec_cpu_quota{namespace=~\"#\", pod=~\"@-redis-\\\\d\",container=\"redis\"} / 100000)) * 100,0.01)",
"memory": "round(max by (pod)(container_memory_usage_bytes{namespace=~\"#\",pod=~\"@-redis-\\\\d\",container=\"redis\" })/ on (pod) (max by (pod) (container_spec_memory_limit_bytes{namespace=~\"#\", pod=~\"@-redis-\\\\d\",container=\"redis\"})) * 100,0.01)",
"disk_capacity": "(max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_capacity_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-redis-\\\\d\"}))",
"disk": "round((max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_used_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-redis-\\\\d\"})) / (max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_capacity_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-redis-\\\\d\"})) * 100, 0.01)",
// "disk": "max by (persistentvolumeclaim,namespace,type) (label_replace(kubelet_volume_stats_capacity_bytes{namespace=~\"#\", persistentvolumeclaim=~\"data-@-redis-\\\\d\"},\"type\",\"capacity\",\"__name__\", \"(.+)\")) or max by (persistentvolumeclaim,namespace,type) (label_replace(kubelet_volume_stats_used_bytes{namespace=~\"#\", persistentvolumeclaim=~\"data-@-redis-\\\\d\"},\"type\",\"used\",\"__name__\", \"(.+)\"))",
"disk_used": "(max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_used_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-redis-\\\\d\"}))",
"uptime": "redis_uptime_in_seconds{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}",
"connections": "sum(redis_connected_clients{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"})",
"commands": "label_replace(sum(irate(redis_commands_total{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"} [1m])) by (cmd, namespace, app_kubernetes_io_instance), \"command\", \"$1\", \"cmd\", \"(.*)\")",

"db_items": "sum (redis_db_keys{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}) by (db)",

"hits_ratio": "avg(rate(redis_keyspace_hits_total{namespace=~\"#\",app_kubernetes_io_instance=\"@\"}[1m]) / clamp_min((irate(redis_keyspace_misses_total{namespace=~\"#\",app_kubernetes_io_instance=~\"@\"}[1m]) + irate(redis_keyspace_hits_total{namespace=~\"#\",app_kubernetes_io_instance=\"@\"}[1m])), 0.01)) by (pod, app_kubernetes_io_instance)",
"commands_duration": "avg(rate(redis_commands_duration_seconds_total{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[1m])) by (cmd) / avg(irate(redis_commands_total{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[1m])) by (cmd)",
"blocked_connections": "sum(redis_blocked_clients{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"})",
"key_evictions": "irate(redis_evicted_keys_total{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[1m])",
}
)
Loading
Loading