From c80670f80bf0850368e307aaae735d7e5fb22aa4 Mon Sep 17 00:00:00 2001 From: Brutus5000 Date: Sun, 12 Jan 2025 10:40:53 +0100 Subject: [PATCH] Switch to VMPodScrape --- apps/faf-icebreaker/templates/deployment.yaml | 5 +- .../templates/statefulset.yaml | 2 + ops/monitoring/templates/ServiceScrape.yaml | 47 --------------- .../templates/annotations-discovery.yaml | 23 ++++---- .../stock-annotations-discovery.yaml | 57 ------------------- 5 files changed, 14 insertions(+), 120 deletions(-) delete mode 100644 ops/monitoring/templates/ServiceScrape.yaml delete mode 100644 ops/monitoring/templates/stock-annotations-discovery.yaml diff --git a/apps/faf-icebreaker/templates/deployment.yaml b/apps/faf-icebreaker/templates/deployment.yaml index 4c9f2bae..c4a2519b 100644 --- a/apps/faf-icebreaker/templates/deployment.yaml +++ b/apps/faf-icebreaker/templates/deployment.yaml @@ -17,9 +17,8 @@ spec: labels: app: faf-icebreaker annotations: - prometheus.io/scrape: 'true' - prometheus.io/port: '8081' - prometheus.io/path: '/actuator/prometheus' + # Does not provide metrics at the moment + prometheus.io/scrape: 'false' spec: initContainers: - name: geolite-db-dl diff --git a/apps/faf-replay-server/templates/statefulset.yaml b/apps/faf-replay-server/templates/statefulset.yaml index bbb59d12..656390a4 100644 --- a/apps/faf-replay-server/templates/statefulset.yaml +++ b/apps/faf-replay-server/templates/statefulset.yaml @@ -32,6 +32,8 @@ spec: ports: - name: replay-stream containerPort: 15000 + - name: prometheus + containerPort: 8011 volumeMounts: - name: config mountPath: /config/config.yaml diff --git a/ops/monitoring/templates/ServiceScrape.yaml b/ops/monitoring/templates/ServiceScrape.yaml deleted file mode 100644 index 91d737ed..00000000 --- a/ops/monitoring/templates/ServiceScrape.yaml +++ /dev/null @@ -1,47 +0,0 @@ -# Grabbed from -# https://gist.github.com/f41gh7/1fed801c5e288e8a6bdbd931ae0f74fd -# https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1033 - -# Unlike kube-prometheus-stack, VM doesn't automatically scrape services that have the prometheus labels set -# Thanks to copying and pasting from GitHub issues, we can easily workaround the problem - -apiVersion: operator.victoriametrics.com/v1beta1 -kind: VMServiceScrape -metadata: - name: services -spec: - discoveryRole: "endpoints" - jobLabel: "app.kubernetes.io/name" - endpoints: - - port: metrics - relabelConfigs: - - sourceLabels: - [__meta_kubernetes_service_annotation_prometheus_io_scrape] - action: keep - regex: "true" - - - sourceLabels: - [__meta_kubernetes_service_annotation_prometheus_io_scheme] - action: replace - targetLabel: __scheme__ - regex: (https?) - - - sourceLabels: - [__meta_kubernetes_service_annotation_prometheus_io_path] - action: replace - targetLabel: __metrics_path__ - regex: (.+) - - - sourceLabels: - [ - __address__, - __meta_kubernetes_service_annotation_prometheus_io_port, - ] - action: replace - targetLabel: __address__ - regex: ([^:]+)(?::\d+)?;(\d+) - replacement: $1:$2 - - namespaceSelector: - any: true - selector: {} \ No newline at end of file diff --git a/ops/monitoring/templates/annotations-discovery.yaml b/ops/monitoring/templates/annotations-discovery.yaml index 8a31a9d6..9f52d755 100644 --- a/ops/monitoring/templates/annotations-discovery.yaml +++ b/ops/monitoring/templates/annotations-discovery.yaml @@ -1,29 +1,29 @@ -# Our modified +# Our modified apiVersion: operator.victoriametrics.com/v1beta1 -kind: VMServiceScrape +kind: VMPodScrape metadata: name: annotations-discovery spec: - discoveryRole: service - endpoints: - - port: http-metrics - relabelConfigs: + namespaceSelector: + any: true + podMetricsEndpoints: + - relabelConfigs: # Check if scrape is enabled - - source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scrape] + - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape] action: keep regex: "true" # Match container port with port from annotation - action: keep_if_equal - source_labels: [__meta_kubernetes_service_annotation_prometheus_io_port, __meta_kubernetes_service_container_port_number] + source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_port, __meta_kubernetes_pod_container_port_number] # Set scrape path - - source_labels: [__meta_kubernetes_service_annotation_prometheus_io_path] + - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path] action: replace target_label: __metrics_path__ regex: (.+) # Set port to address - source_labels: - [__address__, __meta_kubernetes_service_annotation_prometheus_io_port] + [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port] action: replace regex: ([^:]+)(?::\d+)?;(\d+) replacement: $1:$2 @@ -32,6 +32,3 @@ spec: - source_labels: [__meta_kubernetes_namespace] target_label: namespace - namespaceSelector: - any: true - selector: {} diff --git a/ops/monitoring/templates/stock-annotations-discovery.yaml b/ops/monitoring/templates/stock-annotations-discovery.yaml deleted file mode 100644 index 97ef3858..00000000 --- a/ops/monitoring/templates/stock-annotations-discovery.yaml +++ /dev/null @@ -1,57 +0,0 @@ -# This is "official" file -# https://docs.victoriametrics.com/operator/migration/#auto-discovery-for-prometheusio-annotations -# Doesn't actually work for our needs -# Scrapes the pods (endpoints) behind services with the appropriate labels -# We may have pods without services, services without properly labeled backing pods and other shenanigans - -# API: https://docs.victoriametrics.com/operator/api/#vmservicescrape -# Examples (1 as of the time of writing): https://docs.victoriametrics.com/operator/resources/vmservicescrape/#examples - -apiVersion: operator.victoriametrics.com/v1beta1 -kind: VMServiceScrape -metadata: - name: stock-annotations-discovery -spec: - discoveryRole: service - endpoints: - - port: http - relabelConfigs: - # Skip scrape for init containers - - action: drop - source_labels: [__meta_kubernetes_pod_container_init] - regex: "true" - # Match container port with port from annotation - - action: keep_if_equal - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_port, __meta_kubernetes_pod_container_port_number] - # Check if scrape is enabled - - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape] - action: keep - regex: "true" - # Set scrape path - - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path] - action: replace - target_label: __metrics_path__ - regex: (.+) - # Set port to address - - source_labels: - [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port] - action: replace - regex: ([^:]+)(?::\d+)?;(\d+) - replacement: $1:$2 - target_label: __address__ - # Copy labels from pod labels - - action: labelmap - regex: __meta_kubernetes_pod_label_(.+) - # Set pod name, container name, namespace and node name to labels - - source_labels: [__meta_kubernetes_pod_name] - target_label: pod - - source_labels: [__meta_kubernetes_pod_container_name] - target_label: container - - source_labels: [__meta_kubernetes_namespace] - target_label: namespace - - source_labels: [__meta_kubernetes_pod_node_name] - action: replace - target_label: node - namespaceSelector: - any: true - selector: {} # You need to specify selector here \ No newline at end of file