Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event export using vector & sidecar #1142

Draft
wants to merge 55 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
b07606e
sending to datadog using triggermesh
ukrocks007 Mar 17, 2023
a2f9080
not sending raw to datadog
ukrocks007 Mar 20, 2023
99327b4
Merge branch 'main' into feature/triggermesh
ukrocks007 Mar 21, 2023
a0c5145
Merge branch 'main' into feature/triggermesh
ukrocks007 Mar 23, 2023
10e99e9
fix
ukrocks007 Mar 23, 2023
8a4300e
EE folder migration
ukrocks007 Mar 30, 2023
48b23c0
added environement variable for Volumes & data dir
ukrocks007 Mar 30, 2023
4973b5d
fix
ukrocks007 Mar 30, 2023
e3d9a5a
fix
ukrocks007 Mar 30, 2023
d714528
fix
ukrocks007 Mar 30, 2023
af654b0
fixes
ukrocks007 Mar 30, 2023
118c9b2
fix
ukrocks007 Mar 30, 2023
0b80d37
fix
ukrocks007 Mar 30, 2023
8172382
Merge branch 'main' into feature/vector
ukrocks007 Oct 9, 2023
37d3a2f
added sidecar code
ukrocks007 Oct 17, 2023
4742730
dockerfile changes
ukrocks007 Oct 17, 2023
96abd62
port related changes
ukrocks007 Oct 17, 2023
e55ff6f
added types and filename safety
ukrocks007 Oct 18, 2023
e556c56
types for componenetKind
ukrocks007 Oct 18, 2023
9b5a13f
using json schema
ukrocks007 Oct 18, 2023
d035e33
checking for available port & using for new config
ukrocks007 Oct 19, 2023
c9ab449
flow optimizations
ukrocks007 Oct 23, 2023
d451705
added new table, route, handler & models
ukrocks007 Oct 25, 2023
ba675c4
Merge branch 'main' into vector-sidecar
ukrocks007 Oct 25, 2023
30afcf0
saving to db working
ukrocks007 Oct 25, 2023
084cb65
added pg, nsq and handler
ukrocks007 Oct 26, 2023
a42e53d
moved sidecar as part of retraced source code
ukrocks007 Oct 27, 2023
458914a
using pm2 for process management
ukrocks007 Oct 31, 2023
e6fdd02
added pm2 config
ukrocks007 Nov 1, 2023
f0afa36
using common pg & nsq
ukrocks007 Nov 1, 2023
7a5138c
create, update & delete vector sink
ukrocks007 Nov 1, 2023
bce4f65
handleSinkUpdated event
ukrocks007 Nov 3, 2023
beb54fb
bootstrap script added
ukrocks007 Nov 9, 2023
cd1839f
fixes
ukrocks007 Nov 9, 2023
ec6058a
Splunk transformation
ukrocks007 Nov 15, 2023
ccbc10a
lint
ukrocks007 Nov 16, 2023
21fa424
lint fixes
ukrocks007 Nov 16, 2023
8939bd2
Merge branch 'main' into vector-sidecar
ukrocks007 Nov 16, 2023
3488707
enable postgres volume
ukrocks007 Nov 16, 2023
37b9e2d
removed vector datadog toml file
ukrocks007 Nov 16, 2023
301bf7b
types added
ukrocks007 Nov 16, 2023
c70bc90
removed envs
ukrocks007 Nov 16, 2023
d499db0
logging fix
ukrocks007 Nov 16, 2023
f7bf94f
get list & get by id api added
ukrocks007 Nov 16, 2023
d87a20f
using same config as retraced for sidecar
ukrocks007 Nov 16, 2023
6762c89
added backoff mechanism
ukrocks007 Nov 30, 2023
8a0c481
using logger instead of console
ukrocks007 Dec 4, 2023
5cb12b7
option to save group name using query
ukrocks007 Dec 7, 2023
d6662c2
added get by group api for sink
ukrocks007 Dec 7, 2023
244b63e
Add vector deployment and service
ukrocks007 Jan 3, 2024
70c8228
gh actions changes
ukrocks007 Jan 3, 2024
438df65
Refactor consumer logic and improve code readability
ukrocks007 Jan 3, 2024
b5843d9
Remove unnecessary branches from workflow
ukrocks007 Jan 3, 2024
0e296d4
Update admin-portal image version and add environment variables
ukrocks007 Jan 16, 2024
9dd6361
made name optional for vectorsink
ukrocks007 Feb 6, 2024
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
8 changes: 6 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ POSTGRES_PORT=5432
API_BASE_URL_PATH=/auditlog
RETRACED_API_BASE=http://localhost:3000/auditlog
POSTGRES_DATABASE=retraced
LOG_LEVEL=warn
LOG_LEVEL=info
ELASTICSEARCH_NODES=http://127.0.0.1:9200
NSQD_HOST=127.0.0.1
HOSTNAME=retraced-api-67856674bf-kwq7f
Expand All @@ -28,6 +28,10 @@ NEXTAUTH_SECRET=secret
RETRACED_HOST_URL=http://retraced-api:3000/auditlog
RETRACED_EXTERNAL_URL=http://localhost:3000/auditlog

# Export Logs
# EXPORT_WEBHOOK_URL=http://vector:9000
# EXPORT_WEBHOOK_USERNAME=admin
# EXPORT_WEBHOOK_PASSWORD=admin
# OpenTelemetry
# https://opentelemetry.io/docs/concepts/sdk-configuration/otlp-exporter-configuration/
# If you have any issues with using the otel exporter and want to enable debug logs
Expand All @@ -41,4 +45,4 @@ OTEL_EXPORTER_OTLP_METRICS_HEADERS=
GEOIPUPDATE_LICENSE_KEY=
GEOIPUPDATE_ACCOUNT_ID=
GEOIPUPDATE_USE_MMDB=
GEOIPUPDATE_DB_DIR=/etc/mmdb
GEOIPUPDATE_DB_DIR=/etc/mmdb
112 changes: 91 additions & 21 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,18 @@ jobs:
run: |
echo "SHA7=$(echo ${GITHUB_SHA} | cut -c1-7)" >> $GITHUB_OUTPUT
imagePath="${{ secrets.DOCKER_HUB_USERNAME }}/retraced"
sidecarPath="${{ secrets.DOCKER_HUB_USERNAME }}/vector"

if [[ "$GITHUB_REF" != *\/release ]]
then
imagePath="${{ secrets.DOCKER_HUB_USERNAME }}/retraced-beta"
sidecarPath="${{ secrets.DOCKER_HUB_USERNAME }}/vector-beta"
fi
echo "${imagePath}"
echo "${sidecarPath}"

echo "IMAGE_PATH=${imagePath}" >> $GITHUB_OUTPUT
echo "RETRACED_IMAGE_PATH=${imagePath}" >> $GITHUB_OUTPUT
echo "VECTOR_IMAGE_PATH=${sidecarPath}" >> $GITHUB_OUTPUT

- name: Set up Docker Buildx
if: github.ref == 'refs/heads/release'
Expand All @@ -178,20 +182,35 @@ jobs:
username: boxyhq
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build and push
- name: Build and push Retraced
if: github.ref == 'refs/heads/release'
id: docker_build
id: docker_build_retraced
uses: docker/build-push-action@v5
with:
context: ./
file: ./deploy/Dockerfile-slim
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.slug.outputs.IMAGE_PATH }}:${{ needs.ci.outputs.PUBLISH_TAG }},${{ steps.slug.outputs.IMAGE_PATH }}:${{ steps.slug.outputs.SHA7 }},${{ steps.slug.outputs.IMAGE_PATH }}:${{ needs.ci.outputs.NPM_VERSION }}
tags: ${{ steps.slug.outputs.RETRACED_IMAGE_PATH }}:${{ needs.ci.outputs.PUBLISH_TAG }},${{ steps.slug.outputs.RETRACED_IMAGE_PATH }}:${{ steps.slug.outputs.SHA7 }},${{ steps.slug.outputs.RETRACED_IMAGE_PATH }}:${{ needs.ci.outputs.NPM_VERSION }}

- name: Image digest
- name: Build and push Vector
if: github.ref == 'refs/heads/release'
run: echo ${{ steps.docker_build.outputs.digest }}
id: docker_build_vector
uses: docker/build-push-action@v5
with:
context: ./
file: ./deploy/vector-sidecar/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.slug.outputs.VECTOR_IMAGE_PATH }}:${{ needs.ci.outputs.PUBLISH_TAG }},${{ steps.slug.outputs.VECTOR_IMAGE_PATH }}:${{ steps.slug.outputs.SHA7 }},${{ steps.slug.outputs.VECTOR_IMAGE_PATH }}:${{ needs.ci.outputs.NPM_VERSION }}

- name: Image digest Retraced
if: github.ref == 'refs/heads/release'
run: echo ${{ steps.docker_build_retraced.outputs.digest }}

- name: Image digest Vector
if: github.ref == 'refs/heads/release'
run: echo ${{ steps.docker_build_vector.outputs.digest }}

- name: Login to GitHub Container Registry
if: github.ref == 'refs/heads/release'
Expand All @@ -213,9 +232,15 @@ jobs:
env:
COSIGN_KEY: ${{secrets.COSIGN_KEY}}

- name: Sign the image
- name: Sign the image [Retraced]
if: github.ref == 'refs/heads/release'
run: cosign sign --key /tmp/cosign.key -y ${{ steps.slug.outputs.IMAGE_PATH }}@${{ steps.docker_build.outputs.digest }}
run: cosign sign --key /tmp/cosign.key -y ${{ steps.slug.outputs.RETRACED_IMAGE_PATH }}@${{ steps.docker_build_retraced.outputs.digest }}
env:
COSIGN_PASSWORD: ${{secrets.COSIGN_PASSWORD}}

- name: Sign the image [Vector]
if: github.ref == 'refs/heads/release'
run: cosign sign --key /tmp/cosign.key -y ${{ steps.slug.outputs.VECTOR_IMAGE_PATH }}@${{ steps.docker_build_vector.outputs.digest }}
env:
COSIGN_PASSWORD: ${{secrets.COSIGN_PASSWORD}}

Expand All @@ -224,82 +249,127 @@ jobs:
with:
format: spdx
artifact-name: retraced_sbom.spdx

- name: Publish report [SPDX]
uses: anchore/sbom-action/publish-sbom@v0
with:
sbom-artifact-match: ".*\\.spdx$"

- name: Create SBOM Report [CycloneDx]
uses: anchore/sbom-action@v0
with:
format: cyclonedx
artifact-name: retraced_sbom.cyclonedx

- name: Publish report [CycloneDx]
uses: anchore/sbom-action/publish-sbom@v0
with:
sbom-artifact-match: ".*\\.cyclonedx$"

- name: Download artifact for SPDX Report
if: github.ref == 'refs/heads/release'
uses: actions/download-artifact@v3
with:
name: retraced_sbom.spdx

- name: Download artifact for CycloneDx Report
if: github.ref == 'refs/heads/release'
uses: actions/download-artifact@v3
with:
name: retraced_sbom.cyclonedx

- name: Remove older SBOMs
if: github.ref == 'refs/heads/release'
run: rm -rf ./sbom*.* || true

- name: Move SPDX Report
if: github.ref == 'refs/heads/release'
run: mv retraced_sbom.spdx "./sbom.spdx"

- name: Move CycloneDx Report
if: github.ref == 'refs/heads/release'
run: mv retraced_sbom.cyclonedx "./sbom.cyclonedx"

- name: Create SBOM Report [Docker][SPDX]
- name: Create SBOM Report [Docker][SPDX][Retraced]
if: github.ref == 'refs/heads/release'
uses: anchore/sbom-action@v0
with:
image: ${{ steps.slug.outputs.RETRACED_IMAGE_PATH }}:${{ needs.ci.outputs.PUBLISH_TAG }}
format: spdx
artifact-name: retraced_docker_sbom.spdx

- name: Create SBOM Report [Docker][SPDX][Vector]
if: github.ref == 'refs/heads/release'
uses: anchore/sbom-action@v0
with:
image: ${{ steps.slug.outputs.IMAGE_PATH }}:${{ needs.ci.outputs.PUBLISH_TAG }}
image: ${{ steps.slug.outputs.VECTOR_IMAGE_PATH }}:${{ needs.ci.outputs.PUBLISH_TAG }}
format: spdx
artifact-name: docker_sbom.spdx
artifact-name: vector_docker_sbom.spdx

- name: Publish report [Docker][SPDX]
if: github.ref == 'refs/heads/release'
uses: anchore/sbom-action/publish-sbom@v0
with:
sbom-artifact-match: ".*\\.spdx$"
- name: Create SBOM Report [Docker][CycloneDx]

- name: Create SBOM Report [Docker][CycloneDx][Retraced]
if: github.ref == 'refs/heads/release'
uses: anchore/sbom-action@v0
with:
image: ${{ steps.slug.outputs.RETRACED_IMAGE_PATH }}:${{ needs.ci.outputs.PUBLISH_TAG }}
format: cyclonedx
artifact-name: retraced_docker_sbom.cyclonedx

- name: Create SBOM Report [Docker][CycloneDx][Vector]
if: github.ref == 'refs/heads/release'
uses: anchore/sbom-action@v0
with:
image: ${{ steps.slug.outputs.IMAGE_PATH }}:${{ needs.ci.outputs.PUBLISH_TAG }}
image: ${{ steps.slug.outputs.VECTOR_IMAGE_PATH }}:${{ needs.ci.outputs.PUBLISH_TAG }}
format: cyclonedx
artifact-name: docker_sbom.cyclonedx
artifact-name: vector_docker_sbom.cyclonedx

- name: Publish report [Docker][CycloneDx]
if: github.ref == 'refs/heads/release'
uses: anchore/sbom-action/publish-sbom@v0
with:
sbom-artifact-match: ".*\\.cyclonedx$"
- name: Download artifact for SPDX Report [Docker]

- name: Download artifact for SPDX Report [Docker][Retraced]
if: github.ref == 'refs/heads/release'
uses: actions/download-artifact@v3
with:
name: docker_sbom.spdx
- name: Download artifact for CycloneDx Report [Docker]
name: retraced_docker_sbom.spdx

- name: Download artifact for SPDX Report [Docker][Vector]
if: github.ref == 'refs/heads/release'
uses: actions/download-artifact@v3
with:
name: vector_docker_sbom.spdx

- name: Download artifact for CycloneDx Report [Docker][Retraced]
if: github.ref == 'refs/heads/release'
uses: actions/download-artifact@v3
with:
name: docker_sbom.cyclonedx
name: retraced_docker_sbom.cyclonedx

- name: Download artifact for CycloneDx Report [Docker][Vector]
if: github.ref == 'refs/heads/release'
uses: actions/download-artifact@v3
with:
name: vector_docker_sbom.cyclonedx

- name: Create/Clear folder [Docker]
if: github.ref == 'refs/heads/release'
run: mkdir -p ./_docker/ && rm -rf ./_docker/*.* || true

- name: Move Report & cleanup [Docker]
if: github.ref == 'refs/heads/release'
run: |
mv docker_sbom.spdx "./_docker/sbom.spdx" || true
mv docker_sbom.cyclonedx ./_docker/sbom.cyclonedx || true
mv retraced_docker_sbom.spdx "./_docker/retraced_sbom.spdx" || true
mv retraced_docker_sbom.cyclonedx ./_docker/retraced_sbom.cyclonedx || true
mv vector_docker_sbom.spdx "./_docker/vector_sbom.spdx" || true
mv vector_docker_sbom.cyclonedx ./_docker/vector_sbom.cyclonedx || true

- name: ORAS Setup
if: github.ref == 'refs/heads/release'
run: |
Expand All @@ -320,7 +390,7 @@ jobs:
fi
cosign sign -y --key /tmp/cosign.key ghcr.io/${{ github.repository }}/sbom${{ needs.ci.outputs.IMAGE_SUFFIX }}@${ORAS_DIGEST}
cd _docker || true
result=$(../oras_install/oras push ghcr.io/${{ github.repository }}/sbom${{ needs.ci.outputs.IMAGE_SUFFIX }}:docker-${{ needs.ci.outputs.NPM_VERSION }} ./sbom.*)
result=$(../oras_install/oras push ghcr.io/${{ github.repository }}/sbom${{ needs.ci.outputs.IMAGE_SUFFIX }}:docker-${{ needs.ci.outputs.NPM_VERSION }} ./*sbom.*)
ORAS_DIGEST=$(echo $result | grep -oE 'sha256:[a-f0-9]{64}')
if [ -z "$ORAS_DIGEST" ]; then
echo "Error: ORAS_DIGEST is empty"
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,6 @@ test-results.xml
.env.development.local
.env.test.local
.env.production.local
vector/*
mmdb/**/**
GeoIP.conf
GeoIP.conf
1 change: 1 addition & 0 deletions deploy/crontab
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
* * * * * curl -d "{}" http://${NSQD_HOST}:${NSQD_HTTP_PORT}/pub?topic=every_minute
0 12 1-8 * * test -z "$RETRACED_DISABLE_GEOSYNC" && test $(date +\%u) -eq 3 && curl -d "{}" http://${NSQD_HOST}:${NSQD_HTTP_PORT}/pub?topic=first_wed_of_month
* * * * * * * curl -d "{}" http://${NSQD_HOST}:${NSQD_HTTP_PORT}/pub?topic=every_second
*/5 * * * * curl -d "{}" http://${NSQD_HOST}:${NSQD_HTTP_PORT}/pub?topic=pull_events_for_export
23 changes: 23 additions & 0 deletions deploy/vector-sidecar/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM timberio/vector:0.X-alpine as builder

FROM node:18.18.0-alpine3.18
COPY --from=builder /usr/local/bin/ /usr/local/bin/
COPY --from=builder /etc/vector/vector.yaml /etc/vector/vector.yaml
COPY --from=builder /var/lib/vector /var/lib/vector
COPY vector.json /etc/vector/config/vector.json

WORKDIR /src
COPY pm2.config.js /src/pm2.config.js
ADD package.json /src
ADD package-lock.json /src
RUN npm install
# Copy the Node.js application code
ADD . /src
RUN npm run build
RUN npm i -g pm2
ENV PORT 3002
# Expose the port used by the Node.js application
EXPOSE 3002
EXPOSE 8686
# CMD vector -w --config-dir /etc/vector/config & node /src/build/src/ee/_vector-sidecar/index.js
CMD ["pm2-runtime", "start", "/src/pm2.config.js"]
28 changes: 27 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ x-common-variables: &common-variables
GEOIPUPDATE_USE_MMDB: ${GEOIPUPDATE_USE_MMDB}
GEOIPUPDATE_ACCOUNT_ID: ${GEOIPUPDATE_ACCOUNT_ID}
PG_SEARCH: ${PG_SEARCH}
VECTOR_SIDECAR_PORT: 3002

services:
retraced-api:
Expand Down Expand Up @@ -199,7 +200,7 @@ services:
restart: "on-failure"

admin-portal:
image: boxyhq/jackson:1.14.2
image: boxyhq/jackson:1.16.1
ports:
- "5225:5225"
networks:
Expand All @@ -218,8 +219,33 @@ services:
- RETRACED_HOST_URL=http://retraced-api:3000/auditlog
- RETRACED_EXTERNAL_URL=http://localhost:3000/auditlog
- RETRACED_ADMIN_ROOT_TOKEN=dev
- BOXYHQ_HOSTED=${BOXYHQ_HOSTED}
- BOXYHQ_LICENSE_KEY=${BOXYHQ_LICENSE_KEY}
depends_on:
- "retraced-api"
restart: "always"

vector:
build:
context: .
dockerfile: ./deploy/vector-sidecar/Dockerfile
environment: *common-variables
ports:
- "8686:8686"
- "9393:9229"
- "3002:3002"
- "9999:9999"
volumes:
- ./vector/data:/var/lib/vector/
depends_on:
elasticsearch:
condition: service_started
postgres:
condition: service_started
nsqd:
condition: service_started
networks:
- retraced
volumes:
mmdb:
postgres-data:
1 change: 1 addition & 0 deletions kustomize/base/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ resources:
- ./nsqd-service.yaml
- ./processor-deployment.yaml
- ./geoipupdate.yaml
- ./vector-deployment.yaml

namespace: default
46 changes: 46 additions & 0 deletions kustomize/base/vector-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: retraced-vector-sidecar
namespace: '{{repl ConfigOption "namespace"}}'
spec:
selector:
matchLabels:
tier: vector
replicas: 1
template:
metadata:
labels:
app: auditlog
tier: vector
spec:
containers:
- name: vector
image: retracedhq/vector-local
imagePullPolicy: IfNotPresent
startupProbe:
httpGet:
port: 3002
path: /api/v1/health
periodSeconds: 10
timeoutSeconds: 10
failureThreshold: 5
readinessProbe:
httpGet:
port: 3002
path: /api/v1/vector/health
periodSeconds: 30
timeoutSeconds: 10
failureThreshold: 5
successThreshold: 2
ports:
- containerPort: 3002
- containerPort: 8686
envFrom:
- secretRef:
name: auditlog
resources:
requests:
cpu: 100m
limits:
cpu: 1000m
Loading