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

PodMonitoring: Adding test case for probing attempt. #447

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
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
145 changes: 145 additions & 0 deletions pkg/operator/apis/monitoring/v1/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,23 @@ func TestPodMonitoring_ScrapeConfig(t *testing.T) {
Path: "/prometheus",
ProxyURL: "http://foo.bar/test",
},
// Testing behaviour of multiple jobs with the same port.
{
Port: intstr.FromString("http"),
Interval: "60s",
Path: "/probe",
Params: map[string][]string{
"target": {"http://target1"},
},
},
{
Port: intstr.FromString("http"),
Interval: "60s",
Path: "/probe",
Params: map[string][]string{
"target": {"http://target2"},
},
},
},
TargetLabels: TargetLabels{
FromPod: []LabelMapping{
Expand Down Expand Up @@ -714,6 +731,134 @@ relabel_configs:
target_label: key3
action: replace
kubernetes_sd_configs:
- role: pod
kubeconfig_file: ""
follow_redirects: true
enable_http2: true
selectors:
- role: pod
field: spec.nodeName=$(NODE_NAME)
`,
`job_name: PodMonitoring/ns1/name1/http
honor_timestamps: false
params:
target:
- http://target1
scrape_interval: 1m
scrape_timeout: 1m
metrics_path: /probe
sample_limit: 1
label_limit: 2
label_name_length_limit: 3
label_value_length_limit: 4
follow_redirects: true
enable_http2: true
relabel_configs:
- source_labels: [__meta_kubernetes_namespace]
regex: ns1
action: keep
- source_labels: [__meta_kubernetes_namespace]
target_label: namespace
action: replace
- target_label: job
replacement: name1
action: replace
- target_label: project_id
replacement: test_project
action: replace
- target_label: location
replacement: test_location
action: replace
- target_label: cluster
replacement: test_cluster
action: replace
- source_labels: [__meta_kubernetes_pod_name]
target_label: __tmp_instance
action: replace
- source_labels: [__meta_kubernetes_pod_controller_kind, __meta_kubernetes_pod_node_name]
regex: DaemonSet;(.*)
target_label: __tmp_instance
replacement: $1
action: replace
- source_labels: [__meta_kubernetes_pod_container_port_name]
regex: http
action: keep
- source_labels: [__tmp_instance, __meta_kubernetes_pod_container_port_name]
regex: (.+);(.+)
target_label: instance
replacement: $1:$2
action: replace
- source_labels: [__meta_kubernetes_pod_label_key1]
target_label: key2
action: replace
- source_labels: [__meta_kubernetes_pod_label_key3]
target_label: key3
action: replace
kubernetes_sd_configs:
- role: pod
kubeconfig_file: ""
follow_redirects: true
enable_http2: true
selectors:
- role: pod
field: spec.nodeName=$(NODE_NAME)
`,
`job_name: PodMonitoring/ns1/name1/http
honor_timestamps: false
params:
target:
- http://target2
scrape_interval: 1m
scrape_timeout: 1m
metrics_path: /probe
sample_limit: 1
label_limit: 2
label_name_length_limit: 3
label_value_length_limit: 4
follow_redirects: true
enable_http2: true
relabel_configs:
- source_labels: [__meta_kubernetes_namespace]
regex: ns1
action: keep
- source_labels: [__meta_kubernetes_namespace]
target_label: namespace
action: replace
- target_label: job
replacement: name1
action: replace
- target_label: project_id
replacement: test_project
action: replace
- target_label: location
replacement: test_location
action: replace
- target_label: cluster
replacement: test_cluster
action: replace
- source_labels: [__meta_kubernetes_pod_name]
target_label: __tmp_instance
action: replace
- source_labels: [__meta_kubernetes_pod_controller_kind, __meta_kubernetes_pod_node_name]
regex: DaemonSet;(.*)
target_label: __tmp_instance
replacement: $1
action: replace
- source_labels: [__meta_kubernetes_pod_container_port_name]
regex: http
action: keep
- source_labels: [__tmp_instance, __meta_kubernetes_pod_container_port_name]
regex: (.+);(.+)
target_label: instance
replacement: $1:$2
action: replace
- source_labels: [__meta_kubernetes_pod_label_key1]
target_label: key2
action: replace
- source_labels: [__meta_kubernetes_pod_label_key3]
target_label: key3
action: replace
kubernetes_sd_configs:
- role: pod
kubeconfig_file: ""
follow_redirects: true
Expand Down