diff --git a/components/konflux-ui/staging/base/proxy/kustomization.yaml b/components/konflux-ui/staging/base/proxy/kustomization.yaml index 40e99829a3f..417b9d5df86 100644 --- a/components/konflux-ui/staging/base/proxy/kustomization.yaml +++ b/components/konflux-ui/staging/base/proxy/kustomization.yaml @@ -15,3 +15,6 @@ configMapGenerator: - tekton-results.conf - kubearchive.conf - kite.conf + - name: otel-collector-config + files: + - otel-collector-config.yaml diff --git a/components/konflux-ui/staging/base/proxy/nginx.conf b/components/konflux-ui/staging/base/proxy/nginx.conf index 778d9192cc5..2f206e3f83d 100644 --- a/components/konflux-ui/staging/base/proxy/nginx.conf +++ b/components/konflux-ui/staging/base/proxy/nginx.conf @@ -14,6 +14,9 @@ http { access_log /dev/stderr upstreamlog; error_log /dev/stderr; + log_format combined_custom '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"'; + access_log /var/log/nginx/access.log combined_custom; + sendfile on; tcp_nopush on; tcp_nodelay on; diff --git a/components/konflux-ui/staging/base/proxy/otel-collector-config.yaml b/components/konflux-ui/staging/base/proxy/otel-collector-config.yaml new file mode 100644 index 00000000000..c177e905753 --- /dev/null +++ b/components/konflux-ui/staging/base/proxy/otel-collector-config.yaml @@ -0,0 +1,43 @@ +receivers: + filelog/nginx: + include: + - /var/log/nginx/access.log + start_at: beginning + max_log_size: 100MiB + operators: + - type: regex_parser + regex: '^(?P[^ ]*) - (?P[^ ]*) \[(?P[^\]]*)\] "(?P[^ ]*) (?P[^ ]*) (?P[^"]*)" (?P\d+) (?P\d+) "(?P[^"]*)" "(?P[^"]*)"$' +processors: + transform/status_to_int: + log_statements: + - context: log + statements: + - set(attributes["status_int"], Int(attributes["status"])) + +exporters: + prometheus: + endpoint: "0.0.0.0:8889" + +connectors: + count: + logs: + nginx_otel_http_request_errors: + description: HTTP 4xx and 5xx errors from NGINX + conditions: + - 'attributes["status_int"] >= 400 and attributes["status_int"] < 600' + attributes: + - key: method + value: attributes["method"] + - key: status + value: attributes["status"] + +service: + pipelines: + logs: + receivers: [filelog/nginx] + processors: [transform/status_to_int] + exporters: [count] + metrics: + receivers: [count] + processors: [] + exporters: [prometheus] diff --git a/components/konflux-ui/staging/base/proxy/proxy.yaml b/components/konflux-ui/staging/base/proxy/proxy.yaml index 2050c8c78ab..31985dd76e9 100644 --- a/components/konflux-ui/staging/base/proxy/proxy.yaml +++ b/components/konflux-ui/staging/base/proxy/proxy.yaml @@ -150,6 +150,42 @@ spec: readOnlyRootFilesystem: true runAsNonRoot: true runAsUser: 1001 + - image: quay.io/factory2/otel-collector-sp/otel-binary-image:0.113.0 + name: otel-collector + command: ["/usr/local/bin/otel-collector-sp", "--config", "/conf/otel-collector-config.yaml"] + ports: + - containerPort: 8889 + name: otel-metrics + volumeMounts: + - name: logs + mountPath: /var/log/nginx + - mountPath: /conf/otel-collector-config.yaml + subPath: otel-collector-config.yaml + name: otel-collector-config + readOnly: true + readinessProbe: + httpGet: + path: / + port: 8889 + initialDelaySeconds: 5 + periodSeconds: 5 + livenessProbe: + httpGet: + path: / + port: 8889 + initialDelaySeconds: 30 + periodSeconds: 60 + securityContext: + readOnlyRootFilesystem: true + runAsNonRoot: true + runAsUser: 1001 + resources: + limits: + cpu: 150m + memory: 256Mi + requests: + cpu: 50m + memory: 128Mi - image: quay.io/oauth2-proxy/oauth2-proxy@sha256:3da33b9670c67bd782277f99acadf7026f75b9507bfba2088eb2d497266ef7fc name: oauth2-proxy env: @@ -212,6 +248,13 @@ spec: secretName: proxy - name: static-content emptyDir: {} + - configMap: + defaultMode: 420 + name: otel-collector-config + items: + - key: otel-collector-config.yaml + path: otel-collector-config.yaml + name: otel-collector-config --- apiVersion: v1 kind: Service @@ -234,6 +277,10 @@ spec: port: 9443 protocol: TCP targetPort: web-tls + - name: otel-metrics + protocol: TCP + port: 8889 + targetPort: 8889 selector: app: proxy --- @@ -300,3 +347,15 @@ subjects: - kind: ServiceAccount name: proxy namespace: konflux-ui +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: nginx-proxy-monitor +spec: + selector: + matchLabels: + app: nginx-proxy + endpoints: + - port: otel-metrics + interval: 15s