mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-21 12:13:55 +09:00
feat(monitoring): stamp application identity on tenant vmagent scrapes
Application pods in a tenant's namespaces are also scraped by the tenant's own vmagent, and its series need the same identity labels and the same protection against an exporter choosing them, or the two stores would disagree about which application a series belongs to. The class is identical to the cluster-wide one in monitoring-agents. Assisted-by: LLM Signed-off-by: ZverGuy <maximbel2003@gmail.com>
This commit is contained in:
1 parent
f98ee76d2d
commit
14f815a5cc
2 files changed
+87
No files matched your search
@@ -24,6 +24,31 @@ spec:
|
||||
|
||||
scrapeInterval: 30s
|
||||
selectAllByDefault: false
|
||||
# The target always carries all three identity labels, "-" when the pod
|
||||
# has no lineage ("-" is not a valid Kubernetes label value, so it never
|
||||
# collides with a real one). That makes every exporter-supplied copy
|
||||
# collide and be renamed to exported_* (honorLabels false), where it is
|
||||
# dropped; the placeholder itself is removed before storage.
|
||||
scrapeClasses:
|
||||
- name: application-identity
|
||||
default: true
|
||||
relabelConfigs:
|
||||
{{- range list "group" "kind" "name" }}
|
||||
- targetLabel: apps_cozystack_io_application_{{ . }}
|
||||
replacement: "-"
|
||||
- sourceLabels: [__meta_kubernetes_pod_label_apps_cozystack_io_application_{{ . }}]
|
||||
regex: (.+)
|
||||
targetLabel: apps_cozystack_io_application_{{ . }}
|
||||
{{- end }}
|
||||
metricRelabelConfigs:
|
||||
- action: labeldrop
|
||||
regex: (exported_)+apps_cozystack_io_application_(group|kind|name)
|
||||
{{- range list "group" "kind" "name" }}
|
||||
- sourceLabels: [apps_cozystack_io_application_{{ . }}]
|
||||
regex: "-"
|
||||
targetLabel: apps_cozystack_io_application_{{ . }}
|
||||
replacement: ""
|
||||
{{- end }}
|
||||
{{- with .Values.vmagent.inlineScrapeConfig }}
|
||||
inlineScrapeConfig: |
|
||||
{{- . | nindent 4 }}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
suite: tenant vmagent stamps application identity on exporter series
|
||||
templates:
|
||||
- templates/vm/vmagent.yaml
|
||||
release:
|
||||
name: monitoring
|
||||
namespace: tenant-foo
|
||||
|
||||
# Same rules as the cluster-wide vmagent in monitoring-agents, pinned there
|
||||
# by an identical suite; see it for why the placeholder and the drop exist.
|
||||
tests:
|
||||
- it: every scrape gets the application identity class unless it names another
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.scrapeClasses[0].name
|
||||
value: application-identity
|
||||
- equal:
|
||||
path: spec.scrapeClasses[0].default
|
||||
value: true
|
||||
- lengthEqual:
|
||||
path: spec.scrapeClasses
|
||||
count: 1
|
||||
|
||||
- it: the identity comes from the scraped pod's lineage labels, with a placeholder when the pod has none
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.scrapeClasses[0].relabelConfigs
|
||||
value:
|
||||
- targetLabel: apps_cozystack_io_application_group
|
||||
replacement: "-"
|
||||
- sourceLabels: [__meta_kubernetes_pod_label_apps_cozystack_io_application_group]
|
||||
regex: (.+)
|
||||
targetLabel: apps_cozystack_io_application_group
|
||||
- targetLabel: apps_cozystack_io_application_kind
|
||||
replacement: "-"
|
||||
- sourceLabels: [__meta_kubernetes_pod_label_apps_cozystack_io_application_kind]
|
||||
regex: (.+)
|
||||
targetLabel: apps_cozystack_io_application_kind
|
||||
- targetLabel: apps_cozystack_io_application_name
|
||||
replacement: "-"
|
||||
- sourceLabels: [__meta_kubernetes_pod_label_apps_cozystack_io_application_name]
|
||||
regex: (.+)
|
||||
targetLabel: apps_cozystack_io_application_name
|
||||
|
||||
- it: an exporter-supplied identity is dropped and the placeholder never reaches storage
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.scrapeClasses[0].metricRelabelConfigs
|
||||
value:
|
||||
- action: labeldrop
|
||||
regex: (exported_)+apps_cozystack_io_application_(group|kind|name)
|
||||
- sourceLabels: [apps_cozystack_io_application_group]
|
||||
regex: "-"
|
||||
targetLabel: apps_cozystack_io_application_group
|
||||
replacement: ""
|
||||
- sourceLabels: [apps_cozystack_io_application_kind]
|
||||
regex: "-"
|
||||
targetLabel: apps_cozystack_io_application_kind
|
||||
replacement: ""
|
||||
- sourceLabels: [apps_cozystack_io_application_name]
|
||||
regex: "-"
|
||||
targetLabel: apps_cozystack_io_application_name
|
||||
replacement: ""
|
||||
Reference in new issue
Block a user