Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions observability-logs-opensearch/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2026 The OpenChoreo Authors
# SPDX-License-Identifier: Apache-2.0

FROM golang:1.26-alpine AS builder

WORKDIR /app
COPY go.mod go.sum* ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .

FROM alpine:latest

RUN apk --no-cache add ca-certificates && \
addgroup -g 10500 appuser && \
adduser -D -u 10500 -G appuser appuser

WORKDIR /home/appuser
COPY --from=builder --chown=appuser:appuser --chmod=0550 /app/main .

USER appuser
EXPOSE 9098

CMD ["./main"]
19 changes: 19 additions & 0 deletions observability-logs-opensearch/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
CFG_DIR := internal/api
OAPI_CODEGEN_VERSION ?= v2.5.1
SPEC := https://raw.githubusercontent.com/openchoreo/openchoreo.github.io/refs/heads/main/static/api-specs/observability-logs-adapter-api.yaml

.PHONY: oapi-codegen-install openapi-codegen unit-test

oapi-codegen-install:
go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@$(OAPI_CODEGEN_VERSION)

openapi-codegen: oapi-codegen-install
cd $(CFG_DIR) && $(shell go env GOPATH)/bin/oapi-codegen --config cfg-models.yaml $(SPEC)
cd $(CFG_DIR) && $(shell go env GOPATH)/bin/oapi-codegen --config cfg-server.yaml $(SPEC)
cd $(CFG_DIR) && $(shell go env GOPATH)/bin/oapi-codegen --config cfg-client.yaml $(SPEC)
Comment on lines +7 to +13
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, find and examine the Makefile
fd -t f "Makefile" observability-logs-opensearch/

Repository: openchoreo/community-modules

Length of output: 110


🏁 Script executed:

cat observability-logs-opensearch/Makefile

Repository: openchoreo/community-modules

Length of output: 924


🌐 Web query:

Go GOBIN environment variable go install behavior

💡 Result:

The GOBIN environment variable specifies the directory where the 'go install' command installs executable commands (main packages). If GOBIN is set to an absolute path, 'go install' installs executables there. If GOBIN is not set, it defaults to $GOPATH/bin or $HOME/go/bin if GOPATH is not set. Exceptions: Executables in $GOROOT (standard library tools) are installed to $GOROOT/bin or $GOTOOLDIR instead of GOBIN. Cross-compiled binaries go to $GOOS_$GOARCH subdirectories of the install dir. Special case: 'go install' on a single .go file requires GOBIN to be set; it does not fall back to the default. You can set GOBIN persistently with 'go env -w GOBIN=/path/to/bin'. The effective value (including default) can be queried indirectly via 'go list -f {{.Target}} ./...' or 'go env GOPATH' + '/bin', but 'go env GOBIN' shows only the explicit setting (empty if unset). Add the install directory to PATH to run installed binaries conveniently.

Citations:


🏁 Script executed:

# Verify Makefile $(or) syntax is valid by checking if this is standard Makefile syntax
cat > /tmp/test.mk << 'EOF'
TEST_VAR := $(or $(shell echo ""),fallback)
all:
	`@echo` "$(TEST_VAR)"
EOF

make -f /tmp/test.mk

Repository: openchoreo/community-modules

Length of output: 116


Don't hardcode oapi-codegen to GOPATH/bin.

go install ...@version installs to GOBIN when that is set, but this target always executes $(shell go env GOPATH)/bin/oapi-codegen. In environments with a custom GOBIN, the install step succeeds and codegen still fails with "file not found".

🛠️ Suggested fix
+OAPI_CODEGEN_BIN := $(or $(shell go env GOBIN),$(shell go env GOPATH)/bin)/oapi-codegen
+
 oapi-codegen-install:
 	go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@$(OAPI_CODEGEN_VERSION)
 
 openapi-codegen: oapi-codegen-install
-	cd $(CFG_DIR) && $(shell go env GOPATH)/bin/oapi-codegen --config cfg-models.yaml $(SPEC)
-	cd $(CFG_DIR) && $(shell go env GOPATH)/bin/oapi-codegen --config cfg-server.yaml $(SPEC)
-	cd $(CFG_DIR) && $(shell go env GOPATH)/bin/oapi-codegen --config cfg-client.yaml $(SPEC)
+	cd $(CFG_DIR) && $(OAPI_CODEGEN_BIN) --config cfg-models.yaml $(SPEC)
+	cd $(CFG_DIR) && $(OAPI_CODEGEN_BIN) --config cfg-server.yaml $(SPEC)
+	cd $(CFG_DIR) && $(OAPI_CODEGEN_BIN) --config cfg-client.yaml $(SPEC)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@observability-logs-opensearch/Makefile` around lines 7 - 13, The Makefile
hardcodes the oapi-codegen binary path to $(shell go env GOPATH)/bin which
breaks when GOBIN is set; update the openapi-codegen target to compute a binary
path that prefers GOBIN then falls back to GOPATH/bin (e.g., define a local
variable like OAPI_BIN that uses $(shell go env GOBIN) if non-empty else $(shell
go env GOPATH)/bin) and invoke $(OAPI_BIN)/oapi-codegen for the three codegen
calls; keep existing vars OAPI_CODEGEN_VERSION, CFG_DIR and SPEC unchanged.


MODULE_NAME := $(notdir $(CURDIR))

unit-test:
go test -coverprofile=coverage.out ./...
if [ -f coverage.out ]; then mv coverage.out ../$(MODULE_NAME)-coverage.out; fi
24 changes: 24 additions & 0 deletions observability-logs-opensearch/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module github.com/openchoreo/community-modules/observability-logs-opensearch

go 1.26

require (
github.com/getkin/kin-openapi v0.133.0
github.com/google/uuid v1.5.0
github.com/oapi-codegen/runtime v1.2.0
github.com/opensearch-project/opensearch-go/v4 v4.6.0
)

require (
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 // indirect
github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 // indirect
github.com/perimeterx/marshmallow v1.1.5 // indirect
github.com/woodsbury/decimal128 v1.3.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
66 changes: 66 additions & 0 deletions observability-logs-opensearch/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk=
github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ=
github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk=
github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/getkin/kin-openapi v0.133.0 h1:pJdmNohVIJ97r4AUFtEXRXwESr8b0bD721u/Tz6k8PQ=
github.com/getkin/kin-openapi v0.133.0/go.mod h1:boAciF6cXk5FhPqe/NQeBTeenbjqU4LhWBf09ILVvWE=
github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ=
github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY=
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM=
github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
github.com/oapi-codegen/runtime v1.2.0 h1:RvKc1CVS1QeKSNzO97FBQbSMZyQ8s6rZd+LpmzwHMP4=
github.com/oapi-codegen/runtime v1.2.0/go.mod h1:Y7ZhmmlE8ikZOmuHRRndiIm7nf3xcVv+YMweKgG1DT0=
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 h1:G7ERwszslrBzRxj//JalHPu/3yz+De2J+4aLtSRlHiY=
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037/go.mod h1:2bpvgLBZEtENV5scfDFEtB/5+1M4hkQhDQrccEJ/qGw=
github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 h1:bQx3WeLcUWy+RletIKwUIt4x3t8n2SxavmoclizMb8c=
github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90/go.mod h1:y5+oSEHCPT/DGrS++Wc/479ERge0zTFxaF8PbGKcg2o=
github.com/opensearch-project/opensearch-go/v4 v4.6.0 h1:Ac8aLtDSmLEyOmv0r1qhQLw3b4vcUhE42NE9k+Z4cRc=
github.com/opensearch-project/opensearch-go/v4 v4.6.0/go.mod h1:3iZtb4SNt3IzaxavKq0dURh1AmtVgYW71E4XqmYnIiQ=
github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s=
github.com/perimeterx/marshmallow v1.1.5/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/wI2L/jsondiff v0.7.0 h1:1lH1G37GhBPqCfp/lrs91rf/2j3DktX6qYAKZkLuCQQ=
github.com/wI2L/jsondiff v0.7.0/go.mod h1:KAEIojdQq66oJiHhDyQez2x+sRit0vIzC9KeK0yizxM=
github.com/woodsbury/decimal128 v1.3.0 h1:8pffMNWIlC0O5vbyHWFZAt5yWvWcrHA+3ovIIjVWss0=
github.com/woodsbury/decimal128 v1.3.0/go.mod h1:C5UTmyTjW3JftjUFzOVhC20BEQa2a4ZKOB5I6Zjb+ds=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
4 changes: 2 additions & 2 deletions observability-logs-opensearch/helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ apiVersion: v2
name: observability-logs-opensearch
description: A Helm chart for OpenChoreo Observability Logs module with Fluent Bit and OpenSearch
type: application
version: 0.3.11
appVersion: "0.3.11"
version: 0.4.0
appVersion: "0.4.0"
keywords:
- opensearch
- observability
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2026 The OpenChoreo Authors
# SPDX-License-Identifier: Apache-2.0

{{- if .Values.adapter.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: logs-adapter-opensearch
namespace: {{ .Release.Namespace }}
labels:
app: logs-adapter-opensearch
data:
SERVER_PORT: "9098"
OPENSEARCH_ADDRESS: "https://opensearch:9200"
OPENSEARCH_INDEX_PREFIX: "container-logs-"
OBSERVER_URL: {{ .Values.adapter.observerUrl | quote }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright 2026 The OpenChoreo Authors
# SPDX-License-Identifier: Apache-2.0

{{- if .Values.adapter.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: logs-adapter-opensearch
namespace: {{ .Release.Namespace }}
labels:
app: logs-adapter-opensearch
spec:
replicas: 1
selector:
matchLabels:
app: logs-adapter-opensearch
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/adapter/configmap.yaml") . | sha256sum }}
labels:
app: logs-adapter-opensearch
spec:
securityContext:
runAsUser: 10500
runAsGroup: 10500
runAsNonRoot: true
containers:
- name: logs-adapter-opensearch
image: "{{ .Values.adapter.image.repository }}:{{ .Values.adapter.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.adapter.image.pullPolicy | default "IfNotPresent" }}
ports:
- containerPort: 9098
envFrom:
- configMapRef:
name: logs-adapter-opensearch
env:
- name: OPENSEARCH_USERNAME
valueFrom:
secretKeyRef:
name: {{ .Values.adapter.openSearchSecretName }}
key: username
- name: OPENSEARCH_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.adapter.openSearchSecretName }}
key: password
resources:
limits:
cpu: {{ .Values.adapter.resources.limits.cpu }}
memory: {{ .Values.adapter.resources.limits.memory }}
requests:
cpu: {{ .Values.adapter.resources.requests.cpu }}
memory: {{ .Values.adapter.resources.requests.memory }}
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
{{- end }}
21 changes: 21 additions & 0 deletions observability-logs-opensearch/helm/templates/adapter/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2026 The OpenChoreo Authors
# SPDX-License-Identifier: Apache-2.0

{{- if .Values.adapter.enabled }}
apiVersion: v1
kind: Service
metadata:
name: logs-adapter
namespace: {{ .Release.Namespace }}
labels:
app: logs-adapter-opensearch
spec:
type: ClusterIP
ports:
- port: 9098
targetPort: 9098
protocol: TCP
name: http
selector:
app: logs-adapter-opensearch
{{- end }}
15 changes: 15 additions & 0 deletions observability-logs-opensearch/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,21 @@ openSearchCluster:
- "admin"
description: "Admin user"

adapter:
enabled: true
observerUrl: "http://observer-internal.openchoreo-observability-plane:8081"
openSearchSecretName: ""
image:
repository: "ghcr.io/openchoreo/observability-logs-opensearch-adapter"
tag: ""
resources:
limits:
cpu: 100m
memory: 100Mi
requests:
cpu: 50m
memory: 64Mi

openSearchSetup:
enabled: true
image:
Expand Down
4 changes: 4 additions & 0 deletions observability-logs-opensearch/internal/api/cfg-client.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package: gen
output: gen/client.gen.go
generate:
client: true
4 changes: 4 additions & 0 deletions observability-logs-opensearch/internal/api/cfg-models.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package: gen
output: gen/models.gen.go
generate:
models: true
6 changes: 6 additions & 0 deletions observability-logs-opensearch/internal/api/cfg-server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package: gen
output: gen/server.gen.go
generate:
std-http-server: true
strict-server: true
embedded-spec: true
Loading
Loading