fixed scaling rules and undetected nginx_http_requests_total
This commit is contained in:
@@ -16,7 +16,7 @@ spec:
|
||||
name: cpu
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: 70 # Scale up if CPU Usage exceeds 70%
|
||||
averageUtilization: 90 # Scale up if CPU Usage exceeds 90%
|
||||
- type: Resource
|
||||
resource:
|
||||
name: memory
|
||||
@@ -29,7 +29,7 @@ spec:
|
||||
name: nginx_http_requests_total
|
||||
target:
|
||||
type: AverageValue
|
||||
averageValue: 10 # Scale up if requests > 10 per second per pod
|
||||
averageValue: "10k" # Scale up if requests > 10K per second per pod
|
||||
behavior:
|
||||
scaleDown:
|
||||
stabilizationWindowSeconds: 300 # Wait 5 minutes before removing a pod
|
||||
|
||||
@@ -46,7 +46,7 @@ data:
|
||||
role = "pod"
|
||||
}
|
||||
|
||||
// 2. Relabeling: Filter for ONLY the blog pods
|
||||
// 2. Relabeling: Filter and Label "severed-blog" pods
|
||||
discovery.relabel "blog_pods" {
|
||||
targets = discovery.kubernetes.k8s_pods.targets
|
||||
|
||||
@@ -56,6 +56,20 @@ data:
|
||||
regex = "severed-blog"
|
||||
}
|
||||
|
||||
// Explicitly set 'pod' and 'namespace' labels for the Adapter
|
||||
rule {
|
||||
action = "replace"
|
||||
source_labels = ["__meta_kubernetes_pod_name"]
|
||||
target_label = "pod"
|
||||
}
|
||||
|
||||
rule {
|
||||
action = "replace"
|
||||
source_labels = ["__meta_kubernetes_namespace"]
|
||||
target_label = "namespace"
|
||||
}
|
||||
|
||||
// Route to the sidecar exporter port
|
||||
rule {
|
||||
action = "replace"
|
||||
source_labels = ["__address__"]
|
||||
@@ -68,12 +82,13 @@ data:
|
||||
// 3. Direct Nginx Scraper
|
||||
prometheus.scrape "nginx_scraper" {
|
||||
targets = discovery.relabel.blog_pods.output
|
||||
|
||||
forward_to = [prometheus.remote_write.metrics_service.receiver]
|
||||
job_name = "integrations/nginx"
|
||||
|
||||
// Removed the restrictive metric_relabel to ensure data flows
|
||||
}
|
||||
|
||||
// 4. Host Metrics
|
||||
// 4. Host Metrics (Unix Exporter)
|
||||
prometheus.exporter.unix "host" {
|
||||
rootfs_path = "/host/root"
|
||||
sysfs_path = "/host/sys"
|
||||
@@ -163,4 +178,4 @@ spec:
|
||||
path: /sys
|
||||
- name: root
|
||||
hostPath:
|
||||
path: /
|
||||
path: /
|
||||
|
||||
@@ -3,14 +3,13 @@ prometheus:
|
||||
port: 9090
|
||||
|
||||
rules:
|
||||
default: true
|
||||
custom:
|
||||
- seriesQuery: '{__name__=~"nginx_status_requests",namespace!="",pod!=""}'
|
||||
- seriesQuery: 'nginx_http_requests_total{pod!="",namespace!=""}'
|
||||
resources:
|
||||
overrides:
|
||||
namespace: {resource: "namespace"}
|
||||
pod: {resource: "pod"}
|
||||
name:
|
||||
matches: "^nginx_status_requests"
|
||||
as: "http_requests_per_second"
|
||||
metricsQuery: 'sum(rate(<<.Series>>{<<.LabelMatchers>>}[1m])) by (<<.GroupBy>>)'
|
||||
matches: "^(.*)_total"
|
||||
as: "nginx_http_requests_total"
|
||||
metricsQuery: 'rate(<<.Series>>{<<.LabelMatchers>>}[1m])'
|
||||
|
||||
Reference in New Issue
Block a user