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

Splunk direct export of events using sidecar #1236

Open
wants to merge 76 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 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
96be71f
Add SplunkHecLogs sink implementation
ukrocks007 Jan 17, 2024
48fd8d2
Refactor sendEvents method to use async/await
ukrocks007 Jan 17, 2024
ed3d360
Splunk Sink and related changes
ukrocks007 Jan 22, 2024
7140a7f
Merge branch 'main' into sidecar-direct-delivery
ukrocks007 Jan 22, 2024
e42e919
Update Node.js version in sidecar Dockerfile
ukrocks007 Jan 22, 2024
b52cbc0
Refactor code to improve performance and readability
ukrocks007 Jan 22, 2024
2fab0ab
vector rename to sidecar
ukrocks007 Jan 22, 2024
7a490a6
Remove constructor from WithExponentialBackoff class
ukrocks007 Jan 22, 2024
697e9dd
sink migration file
ukrocks007 Jan 22, 2024
2ceb923
Merge branch 'main' into sidecar-direct-delivery
deepakprabhakara Feb 4, 2024
9dd6361
made name optional for vectorsink
ukrocks007 Feb 6, 2024
5390d63
Merge branch 'vector-sidecar' into sidecar-direct-delivery
ukrocks007 Feb 6, 2024
42a02cc
Add security_sink table and related functionality
ukrocks007 Feb 7, 2024
aaa0acd
Merge branch 'main' into sidecar-direct-delivery
ukrocks007 Mar 28, 2024
ec74953
Fix type casting issue in filterEventsByReceived function
ukrocks007 Apr 1, 2024
51cb6ff
Refactor code to use pageOffset and pageLimit in getSecuritySinkList …
ukrocks007 Apr 10, 2024
788a777
Refactor code to use pageOffset and pageLimit in getSecuritySinkList …
ukrocks007 Apr 10, 2024
bcbba9e
Refactor getSecuritySinkList and getSecuritySinkListByGroup handlers …
ukrocks007 Apr 10, 2024
ef5e421
chore: Add BOXYHQ_LICENSE_KEY to .env file
ukrocks007 Apr 15, 2024
efd922d
chore: Update npm dependencies, including @boxyhq/security-sinks to t…
ukrocks007 Apr 15, 2024
645c779
fixes
ukrocks007 Apr 15, 2024
e9a4021
Merge branch 'main' into sidecar-direct-delivery
ukrocks007 Apr 17, 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
7 changes: 6 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ 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 +46,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
114 changes: 93 additions & 21 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,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 "SIDECAR_IMAGE_PATH=${sidecarPath}" >> $GITHUB_OUTPUT

- name: Set up Docker Buildx
if: github.ref == 'refs/heads/release'
Expand All @@ -179,20 +183,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 Sidecar
if: github.ref == 'refs/heads/release'
run: echo ${{ steps.docker_build.outputs.digest }}
id: docker_build_sidecar
uses: docker/build-push-action@v5
with:
context: ./
file: ./deploy/sidecar/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.slug.outputs.SIDECAR_IMAGE_PATH }}:${{ needs.ci.outputs.PUBLISH_TAG }},${{ steps.slug.outputs.SIDECAR_IMAGE_PATH }}:${{ steps.slug.outputs.SHA7 }},${{ steps.slug.outputs.SIDECAR_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 Sidecar
if: github.ref == 'refs/heads/release'
run: echo ${{ steps.docker_build_sidecar.outputs.digest }}

- name: Login to GitHub Container Registry
if: github.ref == 'refs/heads/release'
Expand All @@ -214,9 +233,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.RETRACED_IMAGE_PATH }}@${{ steps.docker_build_retraced.outputs.digest }}
env:
COSIGN_PASSWORD: ${{secrets.COSIGN_PASSWORD}}

- name: Sign the image [Sidecar]
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.SIDECAR_IMAGE_PATH }}@${{ steps.docker_build_sidecar.outputs.digest }}
env:
COSIGN_PASSWORD: ${{secrets.COSIGN_PASSWORD}}

Expand All @@ -226,85 +251,132 @@ jobs:
format: spdx
artifact-name: retraced_sbom.spdx
upload-artifact-retention: 1

- 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
upload-artifact-retention: 1

- 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
upload-artifact-retention: 1

- name: Create SBOM Report [Docker][SPDX][Sidecar]
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.SIDECAR_IMAGE_PATH }}:${{ needs.ci.outputs.PUBLISH_TAG }}
format: spdx
artifact-name: docker_sbom.spdx
artifact-name: sidecar_docker_sbom.spdx
upload-artifact-retention: 1

- 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
upload-artifact-retention: 1

- name: Create SBOM Report [Docker][CycloneDx][Sidecar]
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.SIDECAR_IMAGE_PATH }}:${{ needs.ci.outputs.PUBLISH_TAG }}
format: cyclonedx
artifact-name: docker_sbom.cyclonedx
artifact-name: sidecar_docker_sbom.cyclonedx
upload-artifact-retention: 1

- 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: retraced_docker_sbom.spdx

- name: Download artifact for SPDX Report [Docker][Sidecar]
if: github.ref == 'refs/heads/release'
uses: actions/download-artifact@v3
with:
name: sidecar_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.spdx
- name: Download artifact for CycloneDx Report [Docker]
name: retraced_docker_sbom.cyclonedx

- name: Download artifact for CycloneDx Report [Docker][Sidecar]
if: github.ref == 'refs/heads/release'
uses: actions/download-artifact@v3
with:
name: docker_sbom.cyclonedx
name: sidecar_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 sidecar_docker_sbom.spdx "./_docker/sidecar_sbom.spdx" || true
mv sidecar_docker_sbom.cyclonedx ./_docker/sidecar_sbom.cyclonedx || true

- name: ORAS Setup
if: github.ref == 'refs/heads/release'
run: |
Expand All @@ -325,7 +397,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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@ test-results.xml
.env.test.local
.env.production.local
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
14 changes: 14 additions & 0 deletions deploy/sidecar/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:20.10.0-alpine3.19

WORKDIR /src
ADD package.json /src
ADD package-lock.json /src
RUN npm install
# Copy the Node.js application code
ADD . /src
RUN npm run build
ENV PORT 3002
# Expose the port used by the Node.js application
EXPOSE 3002
EXPOSE 9229
CMD ["node", "--inspect=0.0.0.0", "--enable-source-maps", "/src/build/src/ee/sidecar/index.js"]
24 changes: 23 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}
SIDECAR_PORT: 3002

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

admin-portal:
image: boxyhq/jackson:1.19.1
image: boxyhq/jackson:1.21.4
ports:
- "5225:5225"
networks:
Expand All @@ -218,8 +219,29 @@ 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"

sidecar:
build:
context: .
dockerfile: ./deploy/sidecar/Dockerfile
environment: *common-variables
ports:
- "9393:9229"
- "3002:3002"
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
- ./sidecar-deployment.yaml

namespace: default
46 changes: 46 additions & 0 deletions kustomize/base/sidecar-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: retraced-sidecar
namespace: '{{repl ConfigOption "namespace"}}'
spec:
selector:
matchLabels:
tier: sidecar
replicas: 1
template:
metadata:
labels:
app: auditlog
tier: sidecar
spec:
containers:
- name: sidecar
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/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
3 changes: 3 additions & 0 deletions kustomize/overlays/demo/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ patches:
- ./migratees-job.yaml
- ./migratepg-job.yaml
- ./processor-deployment.yaml
- ./sidecar-deployment.yaml

images:
- name: retracedhq/retraced
newTag: 1.8.4
- name: retracedhq/vector
newTag: 0.0.1
Loading
Loading