From e844ef12363ad3f52b4466b86081a3e28b2e08c7 Mon Sep 17 00:00:00 2001 From: Miles Garnsey <11435896+Miles-Garnsey@users.noreply.github.com> Date: Wed, 11 Jan 2023 16:31:48 +1100 Subject: [PATCH] Add relabelling to ServiceMonitors for CDC metrics. (#807) * Add relabelling to ServiceMonitors for CDC metrics. --- .github/workflows/kuttl_tests.yaml | 108 +++++++++++----------- CHANGELOG/CHANGELOG-1.4.md | 2 + Makefile | 4 +- pkg/telemetry/prom_cass_servicemonitor.go | 5 + 4 files changed, 63 insertions(+), 56 deletions(-) diff --git a/.github/workflows/kuttl_tests.yaml b/.github/workflows/kuttl_tests.yaml index 25204b6d6..1bfb7777e 100644 --- a/.github/workflows/kuttl_tests.yaml +++ b/.github/workflows/kuttl_tests.yaml @@ -4,17 +4,17 @@ on: push: branches: - main - - 'release/**' + - "release/**" paths-ignore: - - 'docs/**' - - 'CHANGELOG/**' + - "docs/**" + - "CHANGELOG/**" pull_request: branches: - main - - 'release/**' + - "release/**" paths-ignore: - - 'docs/**' - - 'CHANGELOG/**' + - "docs/**" + - "CHANGELOG/**" jobs: build_image: @@ -72,53 +72,53 @@ jobs: matrix: k8s_version: ["1.21"] kuttl-test: - - test-servicemonitors - - test-user-defined-ns - - test-all-deployments + - test-servicemonitors + - test-user-defined-ns + - test-all-deployments steps: - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - if: github.event_name == 'pull_request' - with: - ref: ${{ github.event.pull_request.head.sha }} - - uses: actions/checkout@v2 - if: github.event_name != 'pull_request' - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version-file: 'go.mod' - cache: true - - name: Kind kube-proxy issue workaround - run: sudo sysctl net/netfilter/nf_conntrack_max=524288 - - name: Download k8ssandra-operator image - uses: actions/download-artifact@v2 - with: - name: k8ssandra-operator - path: /tmp - - name: Load Docker images - run: | - docker load --input /tmp/k8ssandra-k8ssandra-operator.tar - - name: Install kustomize - uses: imranismail/setup-kustomize@v2 - - name: Install kuttl - run: | - make install-kuttl - - name: Create kind cluster - run: | - kind create cluster --name k8ssandra-0 --config ./test/kuttl/config/kind/w3k${{ matrix.k8s_version }}.yaml - make cert-manager - make IMG="k8ssandra/k8ssandra-operator:${{ needs.build_image.outputs.image_tag }}" kind-load-image - - name: Run kuttl test - run: | - # We are running tests against k8s 1.21 - # Additional versions must be added in kind config files under ./test/config/kind + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + if: github.event_name == 'pull_request' + with: + ref: ${{ github.event.pull_request.head.sha }} + - uses: actions/checkout@v2 + if: github.event_name != 'pull_request' + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version-file: "go.mod" + cache: true + - name: Kind kube-proxy issue workaround + run: sudo sysctl net/netfilter/nf_conntrack_max=524288 + - name: Download k8ssandra-operator image + uses: actions/download-artifact@v2 + with: + name: k8ssandra-operator + path: /tmp + - name: Load Docker images + run: | + docker load --input /tmp/k8ssandra-k8ssandra-operator.tar + - name: Install kustomize + uses: imranismail/setup-kustomize@v2 + - name: Install kuttl + run: | + make install-kuttl + - name: Create kind cluster + run: | + kind create cluster --name k8ssandra-0 --config ./test/kuttl/config/kind/w3k${{ matrix.k8s_version }}.yaml + make cert-manager + make IMG="k8ssandra/k8ssandra-operator:${{ needs.build_image.outputs.image_tag }}" kind-load-image + - name: Run kuttl test + run: | + # We are running tests against k8s 1.21 + # Additional versions must be added in kind config files under ./test/config/kind - # Currently we aren't using the kuttl-test Makefile target while trying to iron out the - # release process. The following changes have been made to stay as close as possible - # to the existing behavior with kuttl tests while supporting the ability to use a release - # image tag of the operator. - - ./bin/kubectl-kuttl test --kind-context=k8ssandra-0 --start-kind=false --test ${{ matrix.kuttl-test }} - - name: Delete kind cluster - run: | - kind delete cluster --name k8ssandra-0 + # Currently we aren't using the kuttl-test Makefile target while trying to iron out the + # release process. The following changes have been made to stay as close as possible + # to the existing behavior with kuttl tests while supporting the ability to use a release + # image tag of the operator. + + ./bin/kubectl-kuttl test --kind-context=k8ssandra-0 --start-kind=false --test ${{ matrix.kuttl-test }} + - name: Delete kind cluster + run: | + kind delete cluster --name k8ssandra-0 diff --git a/CHANGELOG/CHANGELOG-1.4.md b/CHANGELOG/CHANGELOG-1.4.md index 8176bdf98..3fa133053 100644 --- a/CHANGELOG/CHANGELOG-1.4.md +++ b/CHANGELOG/CHANGELOG-1.4.md @@ -14,6 +14,8 @@ Changelog for the K8ssandra Operator, new PRs should update the `unreleased` sec When cutting a new release, update the `unreleased` heading to the tag being generated and date, like `## vX.Y.Z - YYYY-MM-DD` and create a new placeholder section for `unreleased` entries. ## unreleased + +* [FEATURE] [#807](https://github.com/k8ssandra/k8ssandra-operator/pull/807) Adds Prometheus ServiceMonitor relabelling configurations for the CDC agent. The Agent's metrics will now appear in Prometheus alongside Cassandra's. * [BUGFIX] [#808](https://github.com/k8ssandra/k8ssandra-operator/pull/808) Ensure that commonLabels are propagated to Prometheus ServiceMonitor resources. ## v1.4.1 - 2022-01-04 diff --git a/Makefile b/Makefile index c8f01b4ed..ecf8816e2 100644 --- a/Makefile +++ b/Makefile @@ -318,7 +318,7 @@ CONTROLLER_TOOLS_VERSION ?= v0.10.0 cert-manager: ## Install cert-manager to the cluster kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/$(CERT_MANAGER_VERSION)/cert-manager.yaml -# Wait for cert-manager rollout to be fully done +# Wait for cert-manager rollout to be fully done kubectl rollout status deployment cert-manager -n cert-manager kubectl rollout status deployment cert-manager-cainjector -n cert-manager kubectl rollout status deployment cert-manager-webhook -n cert-manager @@ -468,7 +468,7 @@ kuttl-test: install-kuttl docker-build ./bin/kubectl-kuttl test --kind-context=k8ssandra-0 --start-kind=false --test test-user-defined-ns # Install kuttl for e2e tests. -install-kuttl: +install-kuttl: mkdir -p ./bin ; \ cd ./bin ; \ OS="$$(uname | tr '[:upper:]' '[:lower:]')" ; \ diff --git a/pkg/telemetry/prom_cass_servicemonitor.go b/pkg/telemetry/prom_cass_servicemonitor.go index 43c08c6a4..60ec79892 100644 --- a/pkg/telemetry/prom_cass_servicemonitor.go +++ b/pkg/telemetry/prom_cass_servicemonitor.go @@ -242,6 +242,11 @@ spec: sourceLabels: - mcac targetLabel: __name__ + - regex: org\.apache\.cassandra\.metrics\.cdc_agent\.(\w+) + replacement: mcac_cdc_agent_${1} + sourceLabels: + - mcac + targetLabel: __name__ - regex: com\.datastax\.bdp\.type\.performance_objects\.name\.cql_slow_log\.metrics\.queries_latency replacement: mcac_cql_slow_log_query_latency sourceLabels: