From 96d090e577b96cfad3acb14a1bf963d1bc1711b9 Mon Sep 17 00:00:00 2001 From: Xiyue Yu Date: Tue, 27 Aug 2019 20:35:09 -0700 Subject: [PATCH 1/4] fixed invalid metric name and added scrape config for inmemory channel --- --selector=app=prometheus | 1 + cmd/in_memory/channel_controller/main.go | 2 +- cmd/in_memory/channel_dispatcher/main.go | 2 +- cmd/sources_controller/main.go | 2 +- .../in-memory-channel/500-controller.yaml | 4 ++ .../in-memory-channel/500-dispatcher.yaml | 4 ++ .../100-prometheus-scrape-kn-eventing.yaml | 38 +++++++++++++++++++ 7 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 --selector=app=prometheus diff --git a/--selector=app=prometheus b/--selector=app=prometheus new file mode 100644 index 00000000000..0663dbeae2f --- /dev/null +++ b/--selector=app=prometheus @@ -0,0 +1 @@ +elasticsearch-logging-0 \ No newline at end of file diff --git a/cmd/in_memory/channel_controller/main.go b/cmd/in_memory/channel_controller/main.go index bbc666f5f79..66e9efac636 100644 --- a/cmd/in_memory/channel_controller/main.go +++ b/cmd/in_memory/channel_controller/main.go @@ -26,7 +26,7 @@ import ( ) func main() { - sharedmain.Main("inmemorychannel-controller", + sharedmain.Main("inmemorychannel_controller", inmemorychannel.NewController, ) } diff --git a/cmd/in_memory/channel_dispatcher/main.go b/cmd/in_memory/channel_dispatcher/main.go index f1b83eea519..bb6d8dbbb5f 100644 --- a/cmd/in_memory/channel_dispatcher/main.go +++ b/cmd/in_memory/channel_dispatcher/main.go @@ -26,7 +26,7 @@ import ( ) func main() { - sharedmain.Main("inmemorychannel-dispatcher", + sharedmain.Main("inmemorychannel_dispatcher", inmemorychannel.NewController, ) } diff --git a/cmd/sources_controller/main.go b/cmd/sources_controller/main.go index 03a5ce688cb..cabed7b5b37 100644 --- a/cmd/sources_controller/main.go +++ b/cmd/sources_controller/main.go @@ -27,7 +27,7 @@ import ( ) func main() { - sharedmain.Main("source-controller", + sharedmain.Main("source_controller", apiserversource.NewController, containersource.NewController, cronjobsource.NewController, diff --git a/config/channels/in-memory-channel/500-controller.yaml b/config/channels/in-memory-channel/500-controller.yaml index 591bca32bdd..a05e9c34cf8 100644 --- a/config/channels/in-memory-channel/500-controller.yaml +++ b/config/channels/in-memory-channel/500-controller.yaml @@ -25,6 +25,7 @@ spec: matchLabels: &labels messaging.knative.dev/channel: in-memory-channel messaging.knative.dev/role: controller + app: imc-controller template: metadata: labels: *labels @@ -44,6 +45,9 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace + ports: + - containerPort: 9090 + name: metrics volumeMounts: - name: config-logging mountPath: /etc/config-logging diff --git a/config/channels/in-memory-channel/500-dispatcher.yaml b/config/channels/in-memory-channel/500-dispatcher.yaml index 731251be20a..a0ed8eef149 100644 --- a/config/channels/in-memory-channel/500-dispatcher.yaml +++ b/config/channels/in-memory-channel/500-dispatcher.yaml @@ -25,6 +25,7 @@ spec: matchLabels: &labels messaging.knative.dev/channel: in-memory-channel messaging.knative.dev/role: dispatcher + app: imc-dispatcher template: metadata: labels: *labels @@ -44,6 +45,9 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace + ports: + - containerPort: 9090 + name: metrics volumeMounts: - name: config-logging mountPath: /etc/config-logging diff --git a/config/monitoring/metrics/prometheus/100-prometheus-scrape-kn-eventing.yaml b/config/monitoring/metrics/prometheus/100-prometheus-scrape-kn-eventing.yaml index 6da335b6235..2d6ac0c8c32 100644 --- a/config/monitoring/metrics/prometheus/100-prometheus-scrape-kn-eventing.yaml +++ b/config/monitoring/metrics/prometheus/100-prometheus-scrape-kn-eventing.yaml @@ -70,3 +70,41 @@ target_label: pod - source_labels: [__meta_kubernetes_service_name] target_label: service + +# inmemorychannel-controller +- job_name: inmemorychannel-controller + scrape_interval: 3s + scrape_timeout: 3s + kubernetes_sd_configs: + - role: pod + relabel_configs: + # Scrape only the the targets matching the following metadata + - source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_app, __meta_kubernetes_pod_container_port_name] + action: keep + regex: knative-eventing;imc-controller;metrics + # Rename metadata labels to be reader friendly + - source_labels: [__meta_kubernetes_namespace] + target_label: namespace + - source_labels: [__meta_kubernetes_pod_name] + target_label: pod + - source_labels: [__meta_kubernetes_service_name] + target_label: service + +# inmemorychannel-dispatcher +- job_name: inmemorychannel-dispatcher + scrape_interval: 3s + scrape_timeout: 3s + kubernetes_sd_configs: + - role: pod + relabel_configs: + # Scrape only the the targets matching the following metadata + - source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_app, __meta_kubernetes_pod_container_port_name] + action: keep + regex: knative-eventing;imc-dispatcher;metrics + # Rename metadata labels to be reader friendly + - source_labels: [__meta_kubernetes_namespace] + target_label: namespace + - source_labels: [__meta_kubernetes_pod_name] + target_label: pod + - source_labels: [__meta_kubernetes_service_name] + target_label: service \ No newline at end of file From 3a35dd117b0ba54616338c397d5abc05b47350ff Mon Sep 17 00:00:00 2001 From: Xiyue Yu Date: Wed, 28 Aug 2019 11:51:02 -0700 Subject: [PATCH 2/4] refined formatting and delete auto-generated files --- --selector=app=prometheus | 1 - .../metrics/prometheus/100-prometheus-scrape-kn-eventing.yaml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 --selector=app=prometheus diff --git a/--selector=app=prometheus b/--selector=app=prometheus deleted file mode 100644 index 0663dbeae2f..00000000000 --- a/--selector=app=prometheus +++ /dev/null @@ -1 +0,0 @@ -elasticsearch-logging-0 \ No newline at end of file diff --git a/config/monitoring/metrics/prometheus/100-prometheus-scrape-kn-eventing.yaml b/config/monitoring/metrics/prometheus/100-prometheus-scrape-kn-eventing.yaml index 2d6ac0c8c32..52aae08a48e 100644 --- a/config/monitoring/metrics/prometheus/100-prometheus-scrape-kn-eventing.yaml +++ b/config/monitoring/metrics/prometheus/100-prometheus-scrape-kn-eventing.yaml @@ -107,4 +107,4 @@ - source_labels: [__meta_kubernetes_pod_name] target_label: pod - source_labels: [__meta_kubernetes_service_name] - target_label: service \ No newline at end of file + target_label: service From d045f9acf84e57fdccde5bf86a83a28a135d7128 Mon Sep 17 00:00:00 2001 From: Xiyue Yu Date: Wed, 28 Aug 2019 11:58:32 -0700 Subject: [PATCH 3/4] added trailing newline --- .../metrics/prometheus/100-prometheus-scrape-kn-eventing.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/monitoring/metrics/prometheus/100-prometheus-scrape-kn-eventing.yaml b/config/monitoring/metrics/prometheus/100-prometheus-scrape-kn-eventing.yaml index 52aae08a48e..c5082e0cc0f 100644 --- a/config/monitoring/metrics/prometheus/100-prometheus-scrape-kn-eventing.yaml +++ b/config/monitoring/metrics/prometheus/100-prometheus-scrape-kn-eventing.yaml @@ -108,3 +108,4 @@ target_label: pod - source_labels: [__meta_kubernetes_service_name] target_label: service + From 407c137c2a496de8c41b4a28c0cf0239aed8b83d Mon Sep 17 00:00:00 2001 From: Xiyue Yu Date: Wed, 28 Aug 2019 14:41:32 -0700 Subject: [PATCH 4/4] removed app label and use the original label to scrape --- config/channels/in-memory-channel/500-controller.yaml | 1 - config/channels/in-memory-channel/500-dispatcher.yaml | 1 - .../prometheus/100-prometheus-scrape-kn-eventing.yaml | 8 ++++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/config/channels/in-memory-channel/500-controller.yaml b/config/channels/in-memory-channel/500-controller.yaml index a05e9c34cf8..a47a1544f9f 100644 --- a/config/channels/in-memory-channel/500-controller.yaml +++ b/config/channels/in-memory-channel/500-controller.yaml @@ -25,7 +25,6 @@ spec: matchLabels: &labels messaging.knative.dev/channel: in-memory-channel messaging.knative.dev/role: controller - app: imc-controller template: metadata: labels: *labels diff --git a/config/channels/in-memory-channel/500-dispatcher.yaml b/config/channels/in-memory-channel/500-dispatcher.yaml index a0ed8eef149..7e4422c9dde 100644 --- a/config/channels/in-memory-channel/500-dispatcher.yaml +++ b/config/channels/in-memory-channel/500-dispatcher.yaml @@ -25,7 +25,6 @@ spec: matchLabels: &labels messaging.knative.dev/channel: in-memory-channel messaging.knative.dev/role: dispatcher - app: imc-dispatcher template: metadata: labels: *labels diff --git a/config/monitoring/metrics/prometheus/100-prometheus-scrape-kn-eventing.yaml b/config/monitoring/metrics/prometheus/100-prometheus-scrape-kn-eventing.yaml index c5082e0cc0f..02641e717f9 100644 --- a/config/monitoring/metrics/prometheus/100-prometheus-scrape-kn-eventing.yaml +++ b/config/monitoring/metrics/prometheus/100-prometheus-scrape-kn-eventing.yaml @@ -79,9 +79,9 @@ - role: pod relabel_configs: # Scrape only the the targets matching the following metadata - - source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_app, __meta_kubernetes_pod_container_port_name] + - source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_messaging_knative_dev_role, __meta_kubernetes_pod_label_messaging_knative_dev_channel, __meta_kubernetes_pod_container_port_name] action: keep - regex: knative-eventing;imc-controller;metrics + regex: knative-eventing;controller;in-memory-channel;metrics # Rename metadata labels to be reader friendly - source_labels: [__meta_kubernetes_namespace] target_label: namespace @@ -98,9 +98,9 @@ - role: pod relabel_configs: # Scrape only the the targets matching the following metadata - - source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_app, __meta_kubernetes_pod_container_port_name] + - source_labels: [__meta_kubernetes_namespace,__meta_kubernetes_pod_label_messaging_knative_dev_role, __meta_kubernetes_pod_label_messaging_knative_dev_channel, __meta_kubernetes_pod_container_port_name] action: keep - regex: knative-eventing;imc-dispatcher;metrics + regex: knative-eventing;dispatcher;in-memory-channel;metrics # Rename metadata labels to be reader friendly - source_labels: [__meta_kubernetes_namespace] target_label: namespace