Skip to content

Commit

Permalink
Add scrape_samples_scraped to all metric sources (#1081)
Browse files Browse the repository at this point in the history
* Add scrape_samples_scraped to all metric sources

Signed-off-by: Pete Wall <[email protected]>

* Update examples and tests

Signed-off-by: Pete Wall <[email protected]>

---------

Signed-off-by: Pete Wall <[email protected]>
  • Loading branch information
petewall authored Jan 9, 2025
1 parent 14f2fbb commit 5d348a1
Show file tree
Hide file tree
Showing 88 changed files with 413 additions and 395 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ declare "annotation_autodiscovery" {
{{- if .Values.metricsTuning.includeMetrics }}
rule {
source_labels = ["__name__"]
regex = "up|{{ join "|" .Values.metricsTuning.includeMetrics }}"
regex = "up|scrape_samples_scraped|{{ join "|" .Values.metricsTuning.includeMetrics }}"
action = "keep"
}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ prometheus.relabel "beyla" {
{{- if $metricAllowList }}
rule {
source_labels = ["__name__"]
regex = "up|{{ $metricAllowList | join "|" }}"
regex = "up|scrape_samples_scraped|{{ $metricAllowList | join "|" }}"
action = "keep"
}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{{ define "feature.clusterMetrics.cadvisor.allowList" }}
{{- $allowList := list }}
{{ if .Values.cadvisor.metricsTuning.useDefaultAllowList }}
{{- $allowList = concat $allowList (list "up") (.Files.Get "default-allow-lists/cadvisor.yaml" | fromYamlArray) -}}
{{- $allowList = concat $allowList (list "up" "scrape_samples_scraped") (.Files.Get "default-allow-lists/cadvisor.yaml" | fromYamlArray) -}}
{{ end }}
{{ if .Values.cadvisor.metricsTuning.includeMetrics }}
{{- $allowList = concat $allowList (list "up") .Values.cadvisor.metricsTuning.includeMetrics -}}
{{- $allowList = concat $allowList (list "up" "scrape_samples_scraped") .Values.cadvisor.metricsTuning.includeMetrics -}}
{{ end }}
{{ $allowList | uniq | toYaml }}
{{ end }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{{ define "feature.clusterMetrics.kepler.allowList" }}
{{- $allowList := list }}
{{ if .Values.kepler.metricsTuning.useDefaultAllowList }}
{{- $allowList = concat $allowList (list "up") (.Files.Get "default-allow-lists/kepler.yaml" | fromYamlArray) -}}
{{- $allowList = concat $allowList (list "up" "scrape_samples_scraped") (.Files.Get "default-allow-lists/kepler.yaml" | fromYamlArray) -}}
{{ end }}
{{ if .Values.kepler.metricsTuning.includeMetrics }}
{{- $allowList = concat $allowList (list "up") .Values.kepler.metricsTuning.includeMetrics -}}
{{- $allowList = concat $allowList (list "up" "scrape_samples_scraped") .Values.kepler.metricsTuning.includeMetrics -}}
{{ end }}
{{ $allowList | uniq | toYaml }}
{{ end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ prometheus.relabel "kube_controller_manager" {
{{- if $metricAllowList }}
rule {
source_labels = ["__name__"]
regex = "up|{{ $metricAllowList | join "|" }}"
regex = "up|scrape_samples_scraped|{{ $metricAllowList | join "|" }}"
action = "keep"
}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ prometheus.relabel "kube_proxy" {
{{- if $metricAllowList }}
rule {
source_labels = ["__name__"]
regex = "up|{{ $metricAllowList | join "|" }}"
regex = "up|scrape_samples_scraped|{{ $metricAllowList | join "|" }}"
action = "keep"
}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ prometheus.relabel "kube_scheduler" {
{{- if $metricAllowList }}
rule {
source_labels = ["__name__"]
regex = "up|{{ $metricAllowList | join "|" }}"
regex = "up|scrape_samples_scraped|{{ $metricAllowList | join "|" }}"
action = "keep"
}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{{ define "feature.clusterMetrics.kube_state_metrics.allowList" }}
{{- $allowList := list }}
{{ if (index .Values "kube-state-metrics").metricsTuning.useDefaultAllowList }}
{{- $allowList = concat $allowList (list "up") (.Files.Get "default-allow-lists/kube-state-metrics.yaml" | fromYamlArray) -}}
{{- $allowList = concat $allowList (list "up" "scrape_samples_scraped") (.Files.Get "default-allow-lists/kube-state-metrics.yaml" | fromYamlArray) -}}
{{ end }}
{{ if (index .Values "kube-state-metrics").metricsTuning.includeMetrics }}
{{- $allowList = concat $allowList (list "up") (index .Values "kube-state-metrics").metricsTuning.includeMetrics -}}
{{- $allowList = concat $allowList (list "up" "scrape_samples_scraped") (index .Values "kube-state-metrics").metricsTuning.includeMetrics -}}
{{ end }}
{{ $allowList | uniq | toYaml }}
{{ end }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{{ define "feature.clusterMetrics.kubelet.allowList" }}
{{- $allowList := list }}
{{ if .Values.kubelet.metricsTuning.useDefaultAllowList }}
{{- $allowList = concat $allowList (list "up") (.Files.Get "default-allow-lists/kubelet.yaml" | fromYamlArray) -}}
{{- $allowList = concat $allowList (list "up" "scrape_samples_scraped") (.Files.Get "default-allow-lists/kubelet.yaml" | fromYamlArray) -}}
{{ end }}
{{ if .Values.kubelet.metricsTuning.includeMetrics }}
{{- $allowList = concat $allowList (list "up") .Values.kubelet.metricsTuning.includeMetrics -}}
{{- $allowList = concat $allowList (list "up" "scrape_samples_scraped") .Values.kubelet.metricsTuning.includeMetrics -}}
{{ end }}
{{ $allowList | uniq | toYaml }}
{{ end }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{{ define "feature.clusterMetrics.kubeletResource.allowList" }}
{{- $allowList := list }}
{{ if .Values.kubeletResource.metricsTuning.useDefaultAllowList }}
{{- $allowList = concat $allowList (list "up") (.Files.Get "default-allow-lists/kubelet_resource.yaml" | fromYamlArray) -}}
{{- $allowList = concat $allowList (list "up" "scrape_samples_scraped") (.Files.Get "default-allow-lists/kubelet_resource.yaml" | fromYamlArray) -}}
{{ end }}
{{ if .Values.kubeletResource.metricsTuning.includeMetrics }}
{{- $allowList = concat $allowList (list "up") .Values.kubeletResource.metricsTuning.includeMetrics -}}
{{- $allowList = concat $allowList (list "up" "scrape_samples_scraped") .Values.kubeletResource.metricsTuning.includeMetrics -}}
{{ end }}
{{ $allowList | uniq | toYaml }}
{{ end }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{{- define "feature.clusterMetrics.node_exporter.allowList" }}
{{- $allowList := list }}
{{ if (index .Values "node-exporter").metricsTuning.useDefaultAllowList }}
{{- $allowList = concat $allowList (list "up") (.Files.Get "default-allow-lists/node-exporter.yaml" | fromYamlArray) -}}
{{- $allowList = concat $allowList (list "up" "scrape_samples_scraped") (.Files.Get "default-allow-lists/node-exporter.yaml" | fromYamlArray) -}}
{{ end }}
{{ if (index .Values "node-exporter").metricsTuning.useIntegrationAllowList }}
{{- $allowList = concat $allowList (list "up") (.Files.Get "default-allow-lists/node-exporter-integration.yaml" | fromYamlArray) -}}
{{- $allowList = concat $allowList (list "up" "scrape_samples_scraped") (.Files.Get "default-allow-lists/node-exporter-integration.yaml" | fromYamlArray) -}}
{{ end }}
{{ if (index .Values "node-exporter").metricsTuning.includeMetrics }}
{{- $allowList = concat $allowList (list "up") (index .Values "node-exporter").metricsTuning.includeMetrics -}}
{{- $allowList = concat $allowList (list "up" "scrape_samples_scraped") (index .Values "node-exporter").metricsTuning.includeMetrics -}}
{{ end }}
{{ $allowList | uniq | toYaml }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{{ define "feature.clusterMetrics.opencost.allowList" }}
{{- $allowList := list }}
{{ if .Values.opencost.metricsTuning.useDefaultAllowList }}
{{- $allowList = concat $allowList (list "up") (.Files.Get "default-allow-lists/opencost.yaml" | fromYamlArray) -}}
{{- $allowList = concat $allowList (list "up" "scrape_samples_scraped") (.Files.Get "default-allow-lists/opencost.yaml" | fromYamlArray) -}}
{{ end }}
{{ if .Values.opencost.metricsTuning.includeMetrics }}
{{- $allowList = concat $allowList (list "up") .Values.opencost.metricsTuning.includeMetrics -}}
{{- $allowList = concat $allowList (list "up" "scrape_samples_scraped") .Values.opencost.metricsTuning.includeMetrics -}}
{{ end }}
{{ $allowList | uniq | toYaml }}
{{ end }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{{- define "feature.clusterMetrics.windows_exporter.allowList" }}
{{- $allowList := list }}
{{ if (index .Values "windows-exporter").metricsTuning.useDefaultAllowList }}
{{- $allowList = concat $allowList (list "up") (.Files.Get "default-allow-lists/windows-exporter.yaml" | fromYamlArray) -}}
{{- $allowList = concat $allowList (list "up" "scrape_samples_scraped") (.Files.Get "default-allow-lists/windows-exporter.yaml" | fromYamlArray) -}}
{{ end }}
{{ if (index .Values "windows-exporter").metricsTuning.useIntegrationAllowList }}
{{- $allowList = concat $allowList (list "up") (.Files.Get "default-allow-lists/windows-exporter-integration.yaml" | fromYamlArray) -}}
{{- $allowList = concat $allowList (list "up" "scrape_samples_scraped") (.Files.Get "default-allow-lists/windows-exporter-integration.yaml" | fromYamlArray) -}}
{{ end }}
{{ if (index .Values "windows-exporter").metricsTuning.includeMetrics }}
{{- $allowList = concat $allowList (list "up") (index .Values "windows-exporter").metricsTuning.includeMetrics -}}
{{- $allowList = concat $allowList (list "up" "scrape_samples_scraped") (index .Values "windows-exporter").metricsTuning.includeMetrics -}}
{{ end }}
{{ $allowList | uniq | toYaml }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ tests:
kubernetes.kubelet "scrape" {
clustering = true
keep_metrics = "up|go_goroutines|kubelet_certificate_manager_client_expiration_renew_errors|kubelet_certificate_manager_client_ttl_seconds|kubelet_certificate_manager_server_ttl_seconds|kubelet_cgroup_manager_duration_seconds_bucket|kubelet_cgroup_manager_duration_seconds_count|kubelet_node_config_error|kubelet_node_name|kubelet_pleg_relist_duration_seconds_bucket|kubelet_pleg_relist_duration_seconds_count|kubelet_pleg_relist_interval_seconds_bucket|kubelet_pod_start_duration_seconds_bucket|kubelet_pod_start_duration_seconds_count|kubelet_pod_worker_duration_seconds_bucket|kubelet_pod_worker_duration_seconds_count|kubelet_running_container_count|kubelet_running_containers|kubelet_running_pod_count|kubelet_running_pods|kubelet_runtime_operations_errors_total|kubelet_runtime_operations_total|kubelet_server_expiration_renew_errors|kubelet_volume_stats_available_bytes|kubelet_volume_stats_capacity_bytes|kubelet_volume_stats_inodes|kubelet_volume_stats_inodes_free|kubelet_volume_stats_inodes_used|kubelet_volume_stats_used_bytes|kubernetes_build_info|namespace_workload_pod|process_cpu_seconds_total|process_resident_memory_bytes|rest_client_requests_total|storage_operation_duration_seconds_count|storage_operation_errors_total|volume_manager_total_volumes"
keep_metrics = "up|scrape_samples_scraped|go_goroutines|kubelet_certificate_manager_client_expiration_renew_errors|kubelet_certificate_manager_client_ttl_seconds|kubelet_certificate_manager_server_ttl_seconds|kubelet_cgroup_manager_duration_seconds_bucket|kubelet_cgroup_manager_duration_seconds_count|kubelet_node_config_error|kubelet_node_name|kubelet_pleg_relist_duration_seconds_bucket|kubelet_pleg_relist_duration_seconds_count|kubelet_pleg_relist_interval_seconds_bucket|kubelet_pod_start_duration_seconds_bucket|kubelet_pod_start_duration_seconds_count|kubelet_pod_worker_duration_seconds_bucket|kubelet_pod_worker_duration_seconds_count|kubelet_running_container_count|kubelet_running_containers|kubelet_running_pod_count|kubelet_running_pods|kubelet_runtime_operations_errors_total|kubelet_runtime_operations_total|kubelet_server_expiration_renew_errors|kubelet_volume_stats_available_bytes|kubelet_volume_stats_capacity_bytes|kubelet_volume_stats_inodes|kubelet_volume_stats_inodes_free|kubelet_volume_stats_inodes_used|kubelet_volume_stats_used_bytes|kubernetes_build_info|namespace_workload_pod|process_cpu_seconds_total|process_resident_memory_bytes|rest_client_requests_total|storage_operation_duration_seconds_count|storage_operation_errors_total|volume_manager_total_volumes"
scrape_interval = "60s"
max_cache_size = 100000
forward_to = argument.metrics_destinations.value
Expand All @@ -37,15 +37,15 @@ tests:
kubernetes.resources "scrape" {
clustering = true
job_label = "integrations/kubernetes/resources"
keep_metrics = "up|node_cpu_usage_seconds_total|node_memory_working_set_bytes"
keep_metrics = "up|scrape_samples_scraped|node_cpu_usage_seconds_total|node_memory_working_set_bytes"
scrape_interval = "60s"
max_cache_size = 100000
forward_to = argument.metrics_destinations.value
}
kubernetes.cadvisor "scrape" {
clustering = true
keep_metrics = "up|container_cpu_cfs_periods_total|container_cpu_cfs_throttled_periods_total|container_cpu_usage_seconds_total|container_fs_reads_bytes_total|container_fs_reads_total|container_fs_writes_bytes_total|container_fs_writes_total|container_memory_cache|container_memory_rss|container_memory_swap|container_memory_working_set_bytes|container_network_receive_bytes_total|container_network_receive_packets_dropped_total|container_network_receive_packets_total|container_network_transmit_bytes_total|container_network_transmit_packets_dropped_total|container_network_transmit_packets_total|machine_memory_bytes"
keep_metrics = "up|scrape_samples_scraped|container_cpu_cfs_periods_total|container_cpu_cfs_throttled_periods_total|container_cpu_usage_seconds_total|container_fs_reads_bytes_total|container_fs_reads_total|container_fs_writes_bytes_total|container_fs_writes_total|container_memory_cache|container_memory_rss|container_memory_swap|container_memory_working_set_bytes|container_network_receive_bytes_total|container_network_receive_packets_dropped_total|container_network_receive_packets_total|container_network_transmit_bytes_total|container_network_transmit_packets_dropped_total|container_network_transmit_packets_total|machine_memory_bytes"
scrape_interval = "60s"
max_cache_size = 100000
forward_to = [prometheus.relabel.cadvisor.receiver]
Expand Down Expand Up @@ -256,7 +256,7 @@ tests:
kube_state_metrics.scrape "metrics" {
targets = kube_state_metrics.kubernetes.targets.output
clustering = true
keep_metrics = "up|kube_daemonset.*|kube_deployment_metadata_generation|kube_deployment_spec_replicas|kube_deployment_status_condition|kube_deployment_status_observed_generation|kube_deployment_status_replicas_available|kube_deployment_status_replicas_updated|kube_horizontalpodautoscaler_spec_max_replicas|kube_horizontalpodautoscaler_spec_min_replicas|kube_horizontalpodautoscaler_status_current_replicas|kube_horizontalpodautoscaler_status_desired_replicas|kube_job.*|kube_namespace_status_phase|kube_node.*|kube_persistentvolume_status_phase|kube_persistentvolumeclaim_access_mode|kube_persistentvolumeclaim_info|kube_persistentvolumeclaim_labels|kube_persistentvolumeclaim_resource_requests_storage_bytes|kube_persistentvolumeclaim_status_phase|kube_pod_container_info|kube_pod_container_resource_limits|kube_pod_container_resource_requests|kube_pod_container_status_last_terminated_reason|kube_pod_container_status_restarts_total|kube_pod_container_status_waiting_reason|kube_pod_info|kube_pod_owner|kube_pod_spec_volumes_persistentvolumeclaims_info|kube_pod_start_time|kube_pod_status_phase|kube_pod_status_reason|kube_replicaset.*|kube_resourcequota|kube_statefulset.*"
keep_metrics = "up|scrape_samples_scraped|kube_daemonset.*|kube_deployment_metadata_generation|kube_deployment_spec_replicas|kube_deployment_status_condition|kube_deployment_status_observed_generation|kube_deployment_status_replicas_available|kube_deployment_status_replicas_updated|kube_horizontalpodautoscaler_spec_max_replicas|kube_horizontalpodautoscaler_spec_min_replicas|kube_horizontalpodautoscaler_status_current_replicas|kube_horizontalpodautoscaler_status_desired_replicas|kube_job.*|kube_namespace_status_phase|kube_node.*|kube_persistentvolume_status_phase|kube_persistentvolumeclaim_access_mode|kube_persistentvolumeclaim_info|kube_persistentvolumeclaim_labels|kube_persistentvolumeclaim_resource_requests_storage_bytes|kube_persistentvolumeclaim_status_phase|kube_pod_container_info|kube_pod_container_resource_limits|kube_pod_container_resource_requests|kube_pod_container_status_last_terminated_reason|kube_pod_container_status_restarts_total|kube_pod_container_status_waiting_reason|kube_pod_info|kube_pod_owner|kube_pod_spec_volumes_persistentvolumeclaims_info|kube_pod_start_time|kube_pod_status_phase|kube_pod_status_reason|kube_replicaset.*|kube_resourcequota|kube_statefulset.*"
scrape_interval = "60s"
max_cache_size = 100000
forward_to = argument.metrics_destinations.value
Expand Down Expand Up @@ -289,7 +289,7 @@ tests:
targets = discovery.relabel.node_exporter.output
job_label = "integrations/node_exporter"
clustering = true
keep_metrics = "up|node_cpu.*|node_exporter_build_info|node_filesystem.*|node_memory.*|node_network_receive_bytes_total|node_network_receive_drop_total|node_network_transmit_bytes_total|node_network_transmit_drop_total|process_cpu_seconds_total|process_resident_memory_bytes"
keep_metrics = "up|scrape_samples_scraped|node_cpu.*|node_exporter_build_info|node_filesystem.*|node_memory.*|node_network_receive_bytes_total|node_network_receive_drop_total|node_network_transmit_bytes_total|node_network_transmit_drop_total|process_cpu_seconds_total|process_resident_memory_bytes"
scrape_interval = "60s"
max_cache_size = 100000
forward_to = argument.metrics_destinations.value
Expand Down Expand Up @@ -329,7 +329,7 @@ tests:
max_cache_size = 100000
rule {
source_labels = ["__name__"]
regex = "up|windows_.*|node_cpu_seconds_total|node_filesystem_size_bytes|node_filesystem_avail_bytes|container_cpu_usage_seconds_total"
regex = "up|scrape_samples_scraped|windows_.*|node_cpu_seconds_total|node_filesystem_size_bytes|node_filesystem_avail_bytes|container_cpu_usage_seconds_total"
action = "keep"
}
forward_to = argument.metrics_destinations.value
Expand Down
Loading

0 comments on commit 5d348a1

Please sign in to comment.