Skip to content

Commit

Permalink
Drop the __tmp_port label, which breaks autodiscovery deduplication
Browse files Browse the repository at this point in the history
Signed-off-by: Pete Wall <pete.wall@grafana.com>
  • Loading branch information
petewall committed Jan 4, 2025
1 parent 5746e4b commit 07a7faa
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ declare "annotation_autodiscovery" {
action = "keepequal"
target_label = "__tmp_port"
}
rule {
action = "labeldrop"
regex = "__tmp_port"
}

// If the metrics port number annotation has a value, override the target address to use it, regardless whether it is
// one of the declared ports on that Pod.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: static-metric
data:
metrics.prom: |
# HELP static_metric A static metric to serve for testing
# TYPE static_metric gauge
static_metric{} 1
---
apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: OCIRepository
metadata:
name: nginx
spec:
interval: 1m
url: oci://registry-1.docker.io/bitnamicharts/nginx
ref:
semver: 18.2.5
---
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: nginx-static-metrics
spec:
interval: 1m
chartRef:
kind: OCIRepository
name: nginx
values:
podAnnotations:
k8s.grafana.com/scrape: "true"
k8s.grafana.com/metrics.portNumber: "8080"
replicaCount: 2
service:
type: ClusterIP
serverBlock: |-
server {
listen 0.0.0.0:8080;
location /metrics {
default_type "text/plain";
alias /data/metrics.prom;
}
}
extraVolumes:
- name: static-metric
configMap:
name: static-metric
extraVolumeMounts:
- name: static-metric
mountPath: /data
extraContainerPorts:
- name: a-port
containerPort: 8081
- name: another-port
containerPort: 8082
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ spec:
- query: grafana_kubernetes_monitoring_feature_info{cluster="$CLUSTER", feature="annotationAutodiscovery"}
type: promql

# Annotation Autodiscovery by Servicell
# Annotation Autodiscovery from a Service Annotation
- query: certmanager_clock_time_seconds{cluster="$CLUSTER", job="integrations/cert-manager"}
type: promql

# Annotation Autodiscovery from a Pod Annotation
- query: static_metric{cluster="$CLUSTER"}
type: promql

# DPM check
- query: avg(count_over_time(scrape_samples_scraped{cluster="$CLUSTER"}[1m]))
type: promql
Expand Down

0 comments on commit 07a7faa

Please sign in to comment.