@@ -80,26 +80,27 @@ alloy:
8080 stage.match {
8181 selector = `{namespace="nginx-gateway", app_container="/nginx"}`
8282
83- // Set the default first
8483 stage.static_labels {
8584 values = {
8685 ngf_host = "unknown",
8786 }
8887 }
8988
90- // Try to extract host from JSON
9189 stage.json {
9290 expressions = {
9391 ngf_host = "host",
9492 upstream_addr = "upstream_addr",
93+ scheme = "scheme",
94+ status = "status",
9595 }
9696 }
9797
98- // Only overwrites ngf_host if the JSON extraction actually populated it
9998 stage.labels {
10099 values = {
101100 ngf_host = "",
102101 upstream_addr = "",
102+ scheme = "",
103+ status = "",
103104 }
104105 }
105106
@@ -110,8 +111,20 @@ alloy:
110111 }
111112 }
112113
114+ // All HTTP traffic -> fixed bucket, using scheme as a real label matcher now
113115 stage.match {
114- selector = `{namespace="nginx-gateway", app_container="/nginx", upstream_addr=""}`
116+ selector = `{namespace="nginx-gateway", app_container="/nginx", scheme="http"}`
117+
118+ stage.static_labels {
119+ values = {
120+ ngf_host = "http-redirect",
121+ }
122+ }
123+ }
124+
125+ // HTTPS + no upstream + error status -> unmatched, all as label matchers
126+ stage.match {
127+ selector = `{namespace="nginx-gateway", app_container="/nginx", scheme="https", upstream_addr="", status=~"4..|5.."}`
115128
116129 stage.static_labels {
117130 values = {
@@ -120,9 +133,8 @@ alloy:
120133 }
121134 }
122135
123- // upstream_addr itself has huge cardinality (ip:port) - should not remain a label
124136 stage.label_drop {
125- values = ["upstream_addr"]
137+ values = ["upstream_addr", "scheme", "status" ]
126138 }
127139 }
128140
0 commit comments