Skip to content

Commit

Permalink
Add cert manager integration test (#801)
Browse files Browse the repository at this point in the history
* Add cert manager integration test
Signed-off-by: Pete Wall <pete.wall@grafana.com>
  • Loading branch information
petewall authored Oct 22, 2024
1 parent 3ccce08 commit ed99cf2
Show file tree
Hide file tree
Showing 31 changed files with 925 additions and 25 deletions.
13 changes: 7 additions & 6 deletions charts/feature-integrations/docs/integrations/cert-manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
| namespaces | list | `[]` | Namespaces to look for cert-manager instances. |
| portName | string | `"http-metrics"` | Name of the port to scrape metrics from. |

### Scrape Settings

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| jobName | string | `"integrations/cert-manager"` | The value of the job label for scraped metrics. |
| scrapeInterval | string | `60s` | How frequently to scrape metrics from Windows Exporter. |

### Metric Processing Settings

| Key | Type | Default | Description |
Expand All @@ -24,9 +31,3 @@
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| name | string | `""` | Name for this cert-manager instance. |

### Scrape Settings

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| scrapeInterval | string | `60s` | How frequently to scrape metrics from Windows Exporter. |
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ portName: http-metrics
# @section -- Scrape Settings
scrapeInterval:

# -- The value of the job label for scraped metrics.
# @section -- Scrape Settings
jobName: integrations/cert-manager

# -- Sets the max_cache_size for cadvisor prometheus.relabel component.
# This should be at least 2x-5x your largest scrape target or samples appended rate.
# ([docs](https://grafana.com/docs/alloy/latest/reference/components/prometheus.relabel/#arguments))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"field_selectors": {
"type": "array"
},
"jobName": {
"type": "string"
},
"labelSelectors": {
"type": "object",
"properties": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ cert_manager.kubernetes {{ include "helper.alloy_name" .name | quote }} {
{{- if $fieldSelectors }}
field_selectors = {{ $fieldSelectors | toJson }}
{{- end }}
port_name = {{ .portName | quote }}
port_name = {{ .portName | quote }}
}

cert_manager.scrape {{ include "helper.alloy_name" .name | quote }} {
targets = cert_manager.kubernetes.{{ include "helper.alloy_name" .name }}.output
clustering = true
job_label = {{ .jobName | quote }}
{{- if $metricAllowList }}
keep_metrics = "up|{{ $metricAllowList | join "|" | join "|" }}"
{{- end }}
Expand Down
6 changes: 4 additions & 2 deletions charts/feature-integrations/tests/cert-manager_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ tests:
cert_manager.kubernetes "my_cert_manager" {
label_selectors = ["app.kubernetes.io/name=cert-manager"]
port_name = "http-metrics"
port_name = "http-metrics"
}
cert_manager.scrape "my_cert_manager" {
targets = cert_manager.kubernetes.my_cert_manager.output
clustering = true
job_label = "integrations/cert-manager"
scrape_interval = "60s"
max_cache_size = 100000
forward_to = argument.metrics_destinations.value
Expand Down Expand Up @@ -69,12 +70,13 @@ tests:
cert_manager.kubernetes "my_cert_manager" {
namespaces = ["kube-system"]
label_selectors = ["app.kubernetes.io/name=cert-manager"]
port_name = "http-metrics"
port_name = "http-metrics"
}
cert_manager.scrape "my_cert_manager" {
targets = cert_manager.kubernetes.my_cert_manager.output
clustering = true
job_label = "integrations/cert-manager"
scrape_interval = "60s"
max_cache_size = 100000
forward_to = argument.metrics_destinations.value
Expand Down
3 changes: 3 additions & 0 deletions charts/feature-integrations/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@
"field_selectors": {
"type": "array"
},
"jobName": {
"type": "string"
},
"labelSelectors": {
"type": "object",
"properties": {
Expand Down
4 changes: 2 additions & 2 deletions charts/k8s-monitoring-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ In order to specify different destinations of the same type, you can use multipl
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| attempts | int | `10` | Number of times to retry the test on failure. |
| delay | int | `60` | Delay, in seconds, between test runs. |
| initialDelay | int | `10` | Initial delay, in seconds, before starting the first test run. |
| delay | int | `30` | Delay, in seconds, between test runs. |
| initialDelay | int | `0` | Initial delay, in seconds, before starting the first test run. |
| tests | list | `[]` | The tests to run. Each should contain an "env" object and a "queries" list. |

### General settings
Expand Down
4 changes: 2 additions & 2 deletions charts/k8s-monitoring-test/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ tests: []

# -- Initial delay, in seconds, before starting the first test run.
# @section -- Test settings
initialDelay: 10
initialDelay: 0

# -- Number of times to retry the test on failure.
# @section -- Test settings
attempts: 10

# -- Delay, in seconds, between test runs.
# @section -- Test settings
delay: 60
delay: 30

pod:
# -- nodeSelector to apply to the test runner pods.
Expand Down
2 changes: 1 addition & 1 deletion charts/k8s-monitoring/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ dependencies:
repository: https://grafana.github.io/helm-charts
version: 0.9.1
digest: sha256:734d4c8f6076481eb580378daa65fe163c78e9e07a1a214cb4b2fed16441b4c9
generated: "2024-10-21T17:06:40.407816+02:00"
generated: "2024-10-22T11:10:21.255416+02:00"
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,34 @@ cluster_metrics "feature" {
prometheus.remote_write.prometheus.receiver,
]
}

declare "etcd_integration" {
argument "metrics_destinations" {
comment = "Must be a list of metric destinations where collected metrics should be forwarded to"
}

import.git "etcd" {
repository = "https://github.com/grafana/alloy-modules.git"
revision = "main"
path = "modules/databases/kv/etcd/metrics.alloy"
pull_frequency = "15m"
}

etcd.kubernetes "k8s_controlplane_etcd" {
label_selectors = ["app.kubernetes.io/component=etcd"]
port_name = "metrics"
}

etcd.scrape "k8s_controlplane_etcd" {
targets = etcd.kubernetes.k8s_controlplane_etcd.output
clustering = true
scrape_interval = "60s"
max_cache_size = 100000
forward_to = argument.metrics_destinations.value
}
}
etcd_integration "integration" {
metrics_destinations = [
prometheus.remote_write.prometheus.receiver,
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,37 @@ data:
prometheus.remote_write.prometheus.receiver,
]
}
declare "etcd_integration" {
argument "metrics_destinations" {
comment = "Must be a list of metric destinations where collected metrics should be forwarded to"
}
import.git "etcd" {
repository = "https://github.com/grafana/alloy-modules.git"
revision = "main"
path = "modules/databases/kv/etcd/metrics.alloy"
pull_frequency = "15m"
}
etcd.kubernetes "k8s_controlplane_etcd" {
label_selectors = ["app.kubernetes.io/component=etcd"]
port_name = "metrics"
}
etcd.scrape "k8s_controlplane_etcd" {
targets = etcd.kubernetes.k8s_controlplane_etcd.output
clustering = true
scrape_interval = "60s"
max_cache_size = 100000
forward_to = argument.metrics_destinations.value
}
}
etcd_integration "integration" {
metrics_destinations = [
prometheus.remote_write.prometheus.receiver,
]
}
---
# Source: k8s-monitoring/templates/alloy-config.yaml
apiVersion: v1
Expand Down
Loading

0 comments on commit ed99cf2

Please sign in to comment.