feat: add the new version package (#7411)

This commit is contained in:
Vibhu Pandey 2025-03-24 14:38:48 +05:30 committed by GitHub
parent 88aa29e94c
commit 9bdf194d70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
34 changed files with 452 additions and 547 deletions

View File

@ -1,48 +1,122 @@
name: build-pipeline name: build
on: on:
pull_request: push:
branches: branches:
- main - main
- release/v* tags:
- v*
jobs: jobs:
build-frontend: enterprise:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - name: checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Install dependencies - name: setup
run: cd frontend && yarn install uses: actions/setup-go@v5
- name: Build frontend static files
shell: bash
run: |
make build-frontend-static
build-signoz:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup golang
uses: actions/setup-go@v4
with: with:
go-version: "1.22" go-version: "1.22"
- name: Build signoz image - name: setup-qemu
uses: docker/setup-qemu-action@v3
- name: setup-buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
- name: docker-login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: create-env-file
run: |
echo 'INTERCOM_APP_ID="${{ secrets.INTERCOM_APP_ID }}"' > frontend/.env
echo 'SEGMENT_ID="${{ secrets.SEGMENT_ID }}"' >> frontend/.env
echo 'SENTRY_AUTH_TOKEN="${{ secrets.SENTRY_AUTH_TOKEN }}"' >> frontend/.env
echo 'SENTRY_ORG="${{ secrets.SENTRY_ORG }}"' >> frontend/.env
echo 'SENTRY_PROJECT_ID="${{ secrets.SENTRY_PROJECT_ID }}"' >> frontend/.env
echo 'SENTRY_DSN="${{ secrets.SENTRY_DSN }}"' >> frontend/.env
echo 'TUNNEL_URL="${{ secrets.TUNNEL_URL }}"' >> frontend/.env
echo 'TUNNEL_DOMAIN="${{ secrets.TUNNEL_DOMAIN }}"' >> frontend/.env
echo 'POSTHOG_KEY="${{ secrets.POSTHOG_KEY }}"' >> frontend/.env
echo 'CUSTOMERIO_ID="${{ secrets.CUSTOMERIO_ID }}"' >> frontend/.env
echo 'CUSTOMERIO_SITE_ID="${{ secrets.CUSTOMERIO_SITE_ID }}"' >> frontend/.env
- name: github-ref-info
shell: bash shell: bash
run: | run: |
make build-signoz-amd64 GH_REF=${{ github.ref }}
if [[ "${{ github.ref_type }}" == "tag" ]]; then
PREFIX="refs/tags/"
echo "GH_IS_TAG=true" >> $GITHUB_ENV
echo "GH_TAG=${GH_REF#$PREFIX}" >> $GITHUB_ENV
else
PREFIX="refs/heads/"
echo "GH_IS_TAG=false" >> $GITHUB_ENV
echo "GH_BRANCH_NAME=${GH_REF#$PREFIX}" >> $GITHUB_ENV
fi
- name: set-version
run: |
if [ '${{ env.GH_IS_TAG }}' == 'true' ]; then
echo "VERSION=${{ env.GH_TAG }}" >> $GITHUB_ENV
elif [ '${{ env.GH_BRANCH_NAME }}' == 'main' ]; then
echo "VERSION=latest" >> $GITHUB_ENV
else
echo "VERSION=${{ env.GH_BRANCH_NAME }}" >> $GITHUB_ENV
fi
- name: cross-compilation-tools
run: |
set -ex
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu musl-tools
- name: publish
run: make docker-buildx-enterprise
build-signoz-community: community:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - name: checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup golang - name: setup-go
uses: actions/setup-go@v4 uses: actions/setup-go@v5
with: with:
go-version: "1.22" go-version: "1.22"
- name: Build signoz community image - name: setup-qemu
uses: docker/setup-qemu-action@v3
- name: setup-buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
- name: docker-login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: github-ref-info
shell: bash shell: bash
run: | run: |
make build-signoz-community-amd64 GH_REF=${{ github.ref }}
if [[ "${{ github.ref_type }}" == "tag" ]]; then
PREFIX="refs/tags/"
echo "GH_IS_TAG=true" >> $GITHUB_ENV
echo "GH_TAG=${GH_REF#$PREFIX}" >> $GITHUB_ENV
else
PREFIX="refs/heads/"
echo "GH_IS_TAG=false" >> $GITHUB_ENV
echo "GH_BRANCH_NAME=${GH_REF#$PREFIX}" >> $GITHUB_ENV
fi
- name: set-version
run: |
if [ '${{ env.GH_IS_TAG }}' == 'true' ]; then
echo "VERSION=${{ env.GH_TAG }}" >> $GITHUB_ENV
elif [ '${{ env.GH_BRANCH_NAME }}' == 'main' ]; then
echo "VERSION=latest" >> $GITHUB_ENV
else
echo "VERSION=${{ env.GH_BRANCH_NAME }}" >> $GITHUB_ENV
fi
- name: cross-compilation-tools
run: |
set -ex
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu musl-tools
- name: publish
run: make docker-buildx-community

View File

@ -25,15 +25,3 @@ jobs:
else else
echo "No references to 'ee' packages found in 'pkg' directory" echo "No references to 'ee' packages found in 'pkg' directory"
fi fi
lint:
if: |
(github.event_name == 'pull_request' && ! github.event.pull_request.head.repo.fork && github.event.pull_request.user.login != 'dependabot[bot]' && ! contains(github.event.pull_request.labels.*.name, 'safe-to-test')) ||
(github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'safe-to-test'))
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: lint
uses: wagoid/commitlint-github-action@v5

View File

@ -34,3 +34,30 @@ jobs:
secrets: inherit secrets: inherit
with: with:
PRIMUS_REF: main PRIMUS_REF: main
build:
if: |
(github.event_name == 'pull_request' && ! github.event.pull_request.head.repo.fork && github.event.pull_request.user.login != 'dependabot[bot]' && ! contains(github.event.pull_request.labels.*.name, 'safe-to-test')) ||
(github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'safe-to-test'))
runs-on: ubuntu-latest
steps:
- name: self-checkout
uses: actions/checkout@v4
- name: go-install
uses: actions/setup-go@v5
with:
go-version: "1.22"
- name: qemu-install
uses: docker/setup-qemu-action@v3
- name: aarch64-install
run: |
set -ex
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu musl-tools
- name: docker-community
shell: bash
run: |
make docker-build-community
- name: docker-enterprise
shell: bash
run: |
make docker-build-enterprise

View File

@ -22,7 +22,7 @@ jobs:
run: | run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: build-frontend - name: build-frontend
run: make build-frontend-static run: make js-build
- name: upload-frontend-artifact - name: upload-frontend-artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:

View File

@ -36,7 +36,7 @@ jobs:
echo 'CUSTOMERIO_ID="${{ secrets.CUSTOMERIO_ID }}"' >> .env echo 'CUSTOMERIO_ID="${{ secrets.CUSTOMERIO_ID }}"' >> .env
echo 'CUSTOMERIO_SITE_ID="${{ secrets.CUSTOMERIO_SITE_ID }}"' >> .env echo 'CUSTOMERIO_SITE_ID="${{ secrets.CUSTOMERIO_SITE_ID }}"' >> .env
- name: build-frontend - name: build-frontend
run: make build-frontend-static run: make js-build
- name: upload-frontend-artifact - name: upload-frontend-artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:

View File

@ -1,134 +0,0 @@
name: push
on:
push:
branches:
- main
tags:
- v*
jobs:
image-build-and-push-signoz:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup
uses: actions/setup-go@v4
with:
go-version: "1.22"
- name: setup-qemu
uses: docker/setup-qemu-action@v3
- name: setup-buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
- name: docker-login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: create-env-file
run: |
echo 'INTERCOM_APP_ID="${{ secrets.INTERCOM_APP_ID }}"' > frontend/.env
echo 'SEGMENT_ID="${{ secrets.SEGMENT_ID }}"' >> frontend/.env
echo 'SENTRY_AUTH_TOKEN="${{ secrets.SENTRY_AUTH_TOKEN }}"' >> frontend/.env
echo 'SENTRY_ORG="${{ secrets.SENTRY_ORG }}"' >> frontend/.env
echo 'SENTRY_PROJECT_ID="${{ secrets.SENTRY_PROJECT_ID }}"' >> frontend/.env
echo 'SENTRY_DSN="${{ secrets.SENTRY_DSN }}"' >> frontend/.env
echo 'TUNNEL_URL="${{ secrets.TUNNEL_URL }}"' >> frontend/.env
echo 'TUNNEL_DOMAIN="${{ secrets.TUNNEL_DOMAIN }}"' >> frontend/.env
echo 'POSTHOG_KEY="${{ secrets.POSTHOG_KEY }}"' >> frontend/.env
echo 'CUSTOMERIO_ID="${{ secrets.CUSTOMERIO_ID }}"' >> frontend/.env
echo 'CUSTOMERIO_SITE_ID="${{ secrets.CUSTOMERIO_SITE_ID }}"' >> frontend/.env
- uses: benjlevesque/short-sha@v2.2
id: short-sha
- name: branch-name
id: branch-name
uses: tj-actions/branch-names@v7.0.7
- name: docker-tag
run: |
if [ '${{ steps.branch-name.outputs.is_tag }}' == 'true' ]; then
echo "DOCKER_TAG=${{ steps.branch-name.outputs.tag }}" >> $GITHUB_ENV
elif [ '${{ steps.branch-name.outputs.current_branch }}' == 'main' ]; then
echo "DOCKER_TAG=latest" >> $GITHUB_ENV
else
echo "DOCKER_TAG=${{ steps.branch-name.outputs.current_branch }}" >> $GITHUB_ENV
fi
- name: cross-compilation-tools
run: |
set -ex
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu musl-tools
- name: publish-signoz
run: make build-push-signoz
- name: qs-docker-tag
run: |
if [ '${{ steps.branch-name.outputs.is_tag }}' == 'true' ]; then
tag="${{ steps.branch-name.outputs.tag }}"
tag="${tag:1}"
echo "DOCKER_TAG=${tag}" >> $GITHUB_ENV
elif [ '${{ steps.branch-name.outputs.current_branch }}' == 'main' ]; then
echo "DOCKER_TAG=latest" >> $GITHUB_ENV
else
echo "DOCKER_TAG=${{ steps.branch-name.outputs.current_branch }}" >> $GITHUB_ENV
fi
- name: publish-query-service
run: |
SIGNOZ_DOCKER_IMAGE=query-service make build-push-signoz
image-build-and-push-signoz-community:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup-go
uses: actions/setup-go@v4
with:
go-version: "1.22"
- name: setup-qemu
uses: docker/setup-qemu-action@v3
- name: setup-buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
- name: docker-login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: benjlevesque/short-sha@v2.2
id: short-sha
- name: branch-name
id: branch-name
uses: tj-actions/branch-names@v7.0.7
- name: docker-tag
run: |
if [ '${{ steps.branch-name.outputs.is_tag }}' == 'true' ]; then
echo "DOCKER_TAG=${{ steps.branch-name.outputs.tag }}" >> $GITHUB_ENV
elif [ '${{ steps.branch-name.outputs.current_branch }}' == 'main' ]; then
echo "DOCKER_TAG=latest" >> $GITHUB_ENV
else
echo "DOCKER_TAG=${{ steps.branch-name.outputs.current_branch }}" >> $GITHUB_ENV
fi
- name: cross-compilation-tools
run: |
set -ex
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu musl-tools
- name: publish-signoz-community
run: make build-push-signoz-community
- name: qs-docker-tag
run: |
if [ '${{ steps.branch-name.outputs.is_tag }}' == 'true' ]; then
tag="${{ steps.branch-name.outputs.tag }}"
tag="${tag:1}"
echo "DOCKER_TAG=${tag}-oss" >> $GITHUB_ENV
elif [ '${{ steps.branch-name.outputs.current_branch }}' == 'main' ]; then
echo "DOCKER_TAG=latest-oss" >> $GITHUB_ENV
else
echo "DOCKER_TAG=${{ steps.branch-name.outputs.current_branch }}-oss" >> $GITHUB_ENV
fi
- name: publish-query-service-oss
run: |
SIGNOZ_COMMUNITY_DOCKER_IMAGE=query-service make build-push-signoz-community

View File

@ -35,7 +35,7 @@ jobs:
read -r -d '' COMMAND <<EOF || true read -r -d '' COMMAND <<EOF || true
echo "GITHUB_BRANCH: ${GITHUB_BRANCH}" echo "GITHUB_BRANCH: ${GITHUB_BRANCH}"
echo "GITHUB_SHA: ${GITHUB_SHA}" echo "GITHUB_SHA: ${GITHUB_SHA}"
export DOCKER_TAG="${GITHUB_SHA:0:7}" # needed for child process to access it export VERSION="${GITHUB_SHA:0:7}" # needed for child process to access it
export OTELCOL_TAG="main" export OTELCOL_TAG="main"
export PATH="/usr/local/go/bin/:$PATH" # needed for Golang to work export PATH="/usr/local/go/bin/:$PATH" # needed for Golang to work
export KAFKA_SPAN_EVAL="true" export KAFKA_SPAN_EVAL="true"
@ -49,7 +49,7 @@ jobs:
git fetch origin git fetch origin
git checkout ${GITHUB_BRANCH} git checkout ${GITHUB_BRANCH}
git pull git pull
make build-signoz-amd64 make docker-build-enterprise-amd64
make run-testing docker-compose -f deploy/docker/docker-compose.testing.yaml up --build -d
EOF EOF
gcloud beta compute ssh ${GCP_INSTANCE} --zone ${GCP_ZONE} --ssh-key-expire-after=15m --tunnel-through-iap --project ${GCP_PROJECT} --command "${COMMAND}" gcloud beta compute ssh ${GCP_INSTANCE} --zone ${GCP_ZONE} --ssh-key-expire-after=15m --tunnel-through-iap --project ${GCP_PROJECT} --command "${COMMAND}"

View File

@ -35,7 +35,7 @@ jobs:
read -r -d '' COMMAND <<EOF || true read -r -d '' COMMAND <<EOF || true
echo "GITHUB_BRANCH: ${GITHUB_BRANCH}" echo "GITHUB_BRANCH: ${GITHUB_BRANCH}"
echo "GITHUB_SHA: ${GITHUB_SHA}" echo "GITHUB_SHA: ${GITHUB_SHA}"
export DOCKER_TAG="${GITHUB_SHA:0:7}" # needed for child process to access it export VERSION="${GITHUB_SHA:0:7}" # needed for child process to access it
export DEV_BUILD="1" export DEV_BUILD="1"
export PATH="/usr/local/go/bin/:$PATH" # needed for Golang to work export PATH="/usr/local/go/bin/:$PATH" # needed for Golang to work
docker system prune --force docker system prune --force
@ -49,7 +49,7 @@ jobs:
# This is added to include the scenerio when new commit in PR is force-pushed # This is added to include the scenerio when new commit in PR is force-pushed
git branch -D ${GITHUB_BRANCH} git branch -D ${GITHUB_BRANCH}
git checkout --track origin/${GITHUB_BRANCH} git checkout --track origin/${GITHUB_BRANCH}
make build-signoz-amd64 make docker-build-enterprise-amd64
make run-testing docker-compose -f deploy/docker/docker-compose.testing.yaml up --build -d
EOF EOF
gcloud beta compute ssh ${GCP_INSTANCE} --zone ${GCP_ZONE} --ssh-key-expire-after=15m --tunnel-through-iap --project ${GCP_PROJECT} --command "${COMMAND}" gcloud beta compute ssh ${GCP_INSTANCE} --zone ${GCP_ZONE} --ssh-key-expire-after=15m --tunnel-through-iap --project ${GCP_PROJECT} --command "${COMMAND}"

290
Makefile
View File

@ -1,49 +1,44 @@
# ##############################################################
# Reference Guide - https://www.gnu.org/software/make/manual/make.html # variables
# ##############################################################
SHELL := /bin/bash
SRC ?= $(shell pwd)
NAME ?= signoz
OS ?= $(shell uname -s | tr '[A-Z]' '[a-z]')
ARCH ?= $(shell uname -m | sed 's/x86_64/amd64/g' | sed 's/aarch64/arm64/g')
COMMIT_SHORT_SHA ?= $(shell git rev-parse --short HEAD)
BRANCH_NAME ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))
VERSION ?= $(BRANCH_NAME)-$(COMMIT_SHORT_SHA)
TIMESTAMP ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
ARCHS = amd64 arm64
TARGET_DIR ?= $(shell pwd)/target
# Build variables
BUILD_VERSION ?= $(shell git describe --always --tags)
BUILD_HASH ?= $(shell git rev-parse --short HEAD)
BUILD_TIME ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
BUILD_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
LICENSE_SIGNOZ_IO ?= https://license.signoz.io/api/v1
DEV_LICENSE_SIGNOZ_IO ?= https://staging-license.signoz.io/api/v1
ZEUS_URL ?= https://api.signoz.cloud ZEUS_URL ?= https://api.signoz.cloud
DEV_ZEUS_URL ?= https://api.staging.signoz.cloud GO_BUILD_LDFLAG_ZEUS_URL = -X github.com/SigNoz/signoz/ee/query-service/constants.ZeusURL=$(ZEUS_URL)
DEV_BUILD ?= "" # set to any non-empty value to enable dev build LICENSE_URL ?= https://license.signoz.io/api/v1
GO_BUILD_LDFLAG_LICENSE_SIGNOZ_IO = -X github.com/SigNoz/signoz/ee/query-service/constants.LicenseSignozIo=$(LICENSE_URL)
# Internal variables or constants. GO_BUILD_VERSION_LDFLAGS = -X github.com/SigNoz/signoz/pkg/version.version=$(VERSION) -X github.com/SigNoz/signoz/pkg/version.hash=$(COMMIT_SHORT_SHA) -X github.com/SigNoz/signoz/pkg/version.time=$(TIMESTAMP) -X github.com/SigNoz/signoz/pkg/version.branch=$(BRANCH_NAME)
FRONTEND_DIRECTORY ?= frontend GO_BUILD_ARCHS_COMMUNITY = $(addprefix go-build-community-,$(ARCHS))
QUERY_SERVICE_DIRECTORY ?= pkg/query-service GO_BUILD_CONTEXT_COMMUNITY = $(SRC)/pkg/query-service
EE_QUERY_SERVICE_DIRECTORY ?= ee/query-service GO_BUILD_LDFLAGS_COMMUNITY = $(GO_BUILD_VERSION_LDFLAGS) -X github.com/SigNoz/signoz/pkg/version.variant=community
STANDALONE_DIRECTORY ?= deploy/docker GO_BUILD_ARCHS_ENTERPRISE = $(addprefix go-build-enterprise-,$(ARCHS))
SWARM_DIRECTORY ?= deploy/docker-swarm GO_BUILD_CONTEXT_ENTERPRISE = $(SRC)/ee/query-service
CH_HISTOGRAM_QUANTILE_DIRECTORY ?= scripts/clickhouse/histogramquantile GO_BUILD_LDFLAGS_ENTERPRISE = $(GO_BUILD_VERSION_LDFLAGS) -X github.com/SigNoz/signoz/pkg/version.variant=enterprise $(GO_BUILD_LDFLAG_ZEUS_URL) $(GO_BUILD_LDFLAG_LICENSE_SIGNOZ_IO)
GORELEASER_BIN ?= goreleaser
GOOS ?= $(shell go env GOOS) DOCKER_BUILD_ARCHS_COMMUNITY = $(addprefix docker-build-community-,$(ARCHS))
GOARCH ?= $(shell go env GOARCH) DOCKERFILE_COMMUNITY = $(SRC)/pkg/query-service/Dockerfile
GOPATH ?= $(shell go env GOPATH) DOCKER_REGISTRY_COMMUNITY ?= docker.io/signoz/signoz-community
DOCKER_BUILD_ARCHS_ENTERPRISE = $(addprefix docker-build-enterprise-,$(ARCHS))
REPONAME ?= signoz DOCKERFILE_ENTERPRISE = $(SRC)/ee/query-service/Dockerfile
DOCKER_TAG ?= $(BUILD_VERSION) DOCKER_REGISTRY_ENTERPRISE ?= docker.io/signoz/signoz
SIGNOZ_DOCKER_IMAGE ?= signoz JS_BUILD_CONTEXT = $(SRC)/frontend
SIGNOZ_COMMUNITY_DOCKER_IMAGE ?= signoz-community
# Build-time Go variables
PACKAGE?=github.com/SigNoz/signoz
buildVersion=${PACKAGE}/pkg/query-service/version.buildVersion
buildHash=${PACKAGE}/pkg/query-service/version.buildHash
buildTime=${PACKAGE}/pkg/query-service/version.buildTime
gitBranch=${PACKAGE}/pkg/query-service/version.gitBranch
licenseSignozIo=${PACKAGE}/ee/query-service/constants.LicenseSignozIo
zeusURL=${PACKAGE}/ee/query-service/constants.ZeusURL
LD_FLAGS=-X ${buildHash}=${BUILD_HASH} -X ${buildTime}=${BUILD_TIME} -X ${buildVersion}=${BUILD_VERSION} -X ${gitBranch}=${BUILD_BRANCH}
PROD_LD_FLAGS=-X ${zeusURL}=${ZEUS_URL} -X ${licenseSignozIo}=${LICENSE_SIGNOZ_IO}
DEV_LD_FLAGS=-X ${zeusURL}=${DEV_ZEUS_URL} -X ${licenseSignozIo}=${DEV_LICENSE_SIGNOZ_IO}
##############################################################
# directories
##############################################################
$(TARGET_DIR):
mkdir -p $(TARGET_DIR)
############################################################## ##############################################################
# common commands # common commands
@ -61,10 +56,10 @@ devenv-clickhouse: ## Run clickhouse in devenv
docker compose -f compose.yaml up -d docker compose -f compose.yaml up -d
############################################################## ##############################################################
# run commands # go commands
############################################################## ##############################################################
.PHONY: run-go .PHONY: go-run-enterprise
run-go: ## Runs the go backend server go-run-enterprise: ## Runs the enterprise go backend server
@SIGNOZ_INSTRUMENTATION_LOGS_LEVEL=debug \ @SIGNOZ_INSTRUMENTATION_LOGS_LEVEL=debug \
SIGNOZ_SQLSTORE_SQLITE_PATH=signoz.db \ SIGNOZ_SQLSTORE_SQLITE_PATH=signoz.db \
SIGNOZ_WEB_ENABLED=false \ SIGNOZ_WEB_ENABLED=false \
@ -73,147 +68,98 @@ run-go: ## Runs the go backend server
SIGNOZ_TELEMETRYSTORE_PROVIDER=clickhouse \ SIGNOZ_TELEMETRYSTORE_PROVIDER=clickhouse \
SIGNOZ_TELEMETRYSTORE_CLICKHOUSE_DSN=tcp://127.0.0.1:9000 \ SIGNOZ_TELEMETRYSTORE_CLICKHOUSE_DSN=tcp://127.0.0.1:9000 \
go run -race \ go run -race \
./ee/query-service/main.go \ $(GO_BUILD_CONTEXT_ENTERPRISE)/main.go \
--config ./pkg/query-service/config/prometheus.yml \ --config ./conf/prometheus.yml \
--cluster cluster \ --cluster cluster \
--use-logs-new-schema true \ --use-logs-new-schema true \
--use-trace-new-schema true --use-trace-new-schema true
all: build-push-frontend build-push-signoz .PHONY: go-run-community
go-run-community: ## Runs the community go backend server
@SIGNOZ_INSTRUMENTATION_LOGS_LEVEL=debug \
SIGNOZ_SQLSTORE_SQLITE_PATH=signoz.db \
SIGNOZ_WEB_ENABLED=false \
SIGNOZ_JWT_SECRET=secret \
SIGNOZ_ALERTMANAGER_PROVIDER=signoz \
SIGNOZ_TELEMETRYSTORE_PROVIDER=clickhouse \
SIGNOZ_TELEMETRYSTORE_CLICKHOUSE_DSN=tcp://127.0.0.1:9000 \
go run -race \
$(GO_BUILD_CONTEXT_COMMUNITY)/main.go \
--config ./conf/prometheus.yml \
--cluster cluster \
--use-logs-new-schema true \
--use-trace-new-schema true
# Steps to build static files of frontend .PHONY: go-build-community $(GO_BUILD_ARCHS_COMMUNITY)
build-frontend-static: go-build-community: ## Builds the go backend server for community
@echo "------------------" go-build-community: $(GO_BUILD_ARCHS_COMMUNITY)
@echo "--> Building frontend static files" $(GO_BUILD_ARCHS_COMMUNITY): go-build-community-%: $(TARGET_DIR)
@echo "------------------" @mkdir -p $(TARGET_DIR)/$(OS)-$*
@cd $(FRONTEND_DIRECTORY) && \ @echo ">> building binary $(TARGET_DIR)/$(OS)-$*/$(NAME)-community"
rm -rf build && \ @if [ $* = "arm64" ]; then \
CI=1 yarn install && \ CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOARCH=$* GOOS=$(OS) go build -C $(GO_BUILD_CONTEXT_COMMUNITY) -tags timetzdata -o $(TARGET_DIR)/$(OS)-$*/$(NAME)-community -ldflags "-linkmode external -extldflags '-static' -s -w $(GO_BUILD_LDFLAGS_COMMUNITY)"; \
yarn build && \
ls -l build
# Steps to build static binary of signoz
.PHONY: build-signoz-static
build-signoz-static:
@echo "------------------"
@echo "--> Building signoz static binary"
@echo "------------------"
@if [ $(DEV_BUILD) != "" ]; then \
cd $(EE_QUERY_SERVICE_DIRECTORY) && \
CGO_ENABLED=1 go build -tags timetzdata -a -o ./bin/signoz-${GOOS}-${GOARCH} \
-ldflags "-linkmode external -extldflags '-static' -s -w ${LD_FLAGS} ${DEV_LD_FLAGS}"; \
else \ else \
cd $(EE_QUERY_SERVICE_DIRECTORY) && \ CGO_ENABLED=1 GOARCH=$* GOOS=$(OS) go build -C $(GO_BUILD_CONTEXT_COMMUNITY) -tags timetzdata -o $(TARGET_DIR)/$(OS)-$*/$(NAME)-community -ldflags "-linkmode external -extldflags '-static' -s -w $(GO_BUILD_LDFLAGS_COMMUNITY)"; \
CGO_ENABLED=1 go build -tags timetzdata -a -o ./bin/signoz-${GOOS}-${GOARCH} \
-ldflags "-linkmode external -extldflags '-static' -s -w ${LD_FLAGS} ${PROD_LD_FLAGS}"; \
fi fi
.PHONY: build-signoz-static-amd64
build-signoz-static-amd64:
make GOARCH=amd64 build-signoz-static
.PHONY: build-signoz-static-arm64 .PHONY: go-build-enterprise $(GO_BUILD_ARCHS_ENTERPRISE)
build-signoz-static-arm64: go-build-enterprise: ## Builds the go backend server for enterprise
make CC=aarch64-linux-gnu-gcc GOARCH=arm64 build-signoz-static go-build-enterprise: $(GO_BUILD_ARCHS_ENTERPRISE)
$(GO_BUILD_ARCHS_ENTERPRISE): go-build-enterprise-%: $(TARGET_DIR)
# Steps to build static binary of signoz for all platforms @mkdir -p $(TARGET_DIR)/$(OS)-$*
.PHONY: build-signoz-static-all @echo ">> building binary $(TARGET_DIR)/$(OS)-$*/$(NAME)"
build-signoz-static-all: build-signoz-static-amd64 build-signoz-static-arm64 build-frontend-static @if [ $* = "arm64" ]; then \
CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOARCH=$* GOOS=$(OS) go build -C $(GO_BUILD_CONTEXT_ENTERPRISE) -tags timetzdata -o $(TARGET_DIR)/$(OS)-$*/$(NAME) -ldflags "-linkmode external -extldflags '-static' -s -w $(GO_BUILD_LDFLAGS_ENTERPRISE)"; \
# Steps to build and push docker image of signoz
.PHONY: build-signoz-amd64 build-push-signoz
# Step to build docker image of signoz in amd64 (used in build pipeline)
build-signoz-amd64: build-signoz-static-amd64 build-frontend-static
@echo "------------------"
@echo "--> Building signoz docker image for amd64"
@echo "------------------"
@docker build --file $(EE_QUERY_SERVICE_DIRECTORY)/Dockerfile \
--tag $(REPONAME)/$(SIGNOZ_DOCKER_IMAGE):$(DOCKER_TAG) \
--build-arg TARGETPLATFORM="linux/amd64" .
# Step to build and push docker image of query in amd64 and arm64 (used in push pipeline)
build-push-signoz: build-signoz-static-all
@echo "------------------"
@echo "--> Building and pushing signoz docker image"
@echo "------------------"
@docker buildx build --file $(EE_QUERY_SERVICE_DIRECTORY)/Dockerfile --progress plain \
--push --platform linux/arm64,linux/amd64 \
--tag $(REPONAME)/$(SIGNOZ_DOCKER_IMAGE):$(DOCKER_TAG) .
# Step to build docker image of signoz community in amd64 (used in build pipeline)
build-signoz-community-amd64:
@echo "------------------"
@echo "--> Building signoz docker image for amd64"
@echo "------------------"
make EE_QUERY_SERVICE_DIRECTORY=${QUERY_SERVICE_DIRECTORY} SIGNOZ_DOCKER_IMAGE=${SIGNOZ_COMMUNITY_DOCKER_IMAGE} build-signoz-amd64
# Step to build and push docker image of signoz community in amd64 and arm64 (used in push pipeline)
build-push-signoz-community:
@echo "------------------"
@echo "--> Building and pushing signoz community docker image"
@echo "------------------"
make EE_QUERY_SERVICE_DIRECTORY=${QUERY_SERVICE_DIRECTORY} SIGNOZ_DOCKER_IMAGE=${SIGNOZ_COMMUNITY_DOCKER_IMAGE} build-push-signoz
pull-signoz:
@docker-compose -f $(STANDALONE_DIRECTORY)/docker-compose.yaml pull
run-signoz:
@docker-compose -f $(STANDALONE_DIRECTORY)/docker-compose.yaml up --build -d
run-testing:
@docker-compose -f $(STANDALONE_DIRECTORY)/docker-compose.testing.yaml up --build -d
down-signoz:
@docker-compose -f $(STANDALONE_DIRECTORY)/docker-compose.yaml down -v
check-no-ee-references:
@echo "Checking for 'ee' package references in 'pkg' directory..."
@if grep -R --include="*.go" '.*/ee/.*' pkg/; then \
echo "Error: Found references to 'ee' packages in 'pkg' directory"; \
exit 1; \
else \ else \
echo "No references to 'ee' packages found in 'pkg' directory"; \ CGO_ENABLED=1 GOARCH=$* GOOS=$(OS) go build -C $(GO_BUILD_CONTEXT_ENTERPRISE) -tags timetzdata -o $(TARGET_DIR)/$(OS)-$*/$(NAME) -ldflags "-linkmode external -extldflags '-static' -s -w $(GO_BUILD_LDFLAGS_ENTERPRISE)"; \
fi fi
test: ##############################################################
go test ./pkg/... # js commands
##############################################################
.PHONY: js-build
js-build: ## Builds the js frontend
@echo ">> building js frontend"
@cd $(JS_BUILD_CONTEXT) && CI=1 yarn install && yarn build
######################################################## ##############################################################
# Goreleaser # docker commands
######################################################## ##############################################################
.PHONY: gor-snapshot gor-snapshot-histogram-quantile gor-snapshot-signoz gor-snapshot-signoz-community gor-split gor-split-histogram-quantile gor-split-signoz gor-split-signoz-community gor-merge .PHONY: docker-build-community $(DOCKER_BUILD_ARCHS_COMMUNITY)
docker-build-community: ## Builds the docker image for community
docker-build-community: $(DOCKER_BUILD_ARCHS_COMMUNITY)
$(DOCKER_BUILD_ARCHS_COMMUNITY): docker-build-community-%: go-build-community-% js-build
@echo ">> building docker image for $(NAME)-community"
@docker build -t "$(DOCKER_REGISTRY_COMMUNITY):$(VERSION)-$*" \
--build-arg TARGETARCH="$*" \
-f $(DOCKERFILE_COMMUNITY) $(SRC)
gor-snapshot: .PHONY: docker-buildx-community
@if [[ ${GORELEASER_WORKDIR} ]]; then \ docker-buildx-community: ## Builds the docker image for community using buildx
${GORELEASER_BIN} release --config ${GORELEASER_WORKDIR}/.goreleaser.yaml --clean --snapshot; \ docker-buildx-community: go-build-community js-build
else \ @echo ">> building docker image for $(NAME)-community"
${GORELEASER_BIN} release --clean --snapshot; \ @docker buildx build --file $(DOCKERFILE_COMMUNITY) \
fi --progress plain \
--platform linux/arm64,linux/amd64 \
--push \
--tag $(DOCKER_REGISTRY_COMMUNITY):$(VERSION) $(SRC)
gor-snapshot-histogram-quantile: .PHONY: docker-build-enterprise $(DOCKER_BUILD_ARCHS_ENTERPRISE)
make GORELEASER_WORKDIR=$(CH_HISTOGRAM_QUANTILE_DIRECTORY) goreleaser-snapshot docker-build-enterprise: ## Builds the docker image for enterprise
docker-build-enterprise: $(DOCKER_BUILD_ARCHS_ENTERPRISE)
$(DOCKER_BUILD_ARCHS_ENTERPRISE): docker-build-enterprise-%: go-build-enterprise-% js-build
@echo ">> building docker image for $(NAME)"
@docker build -t "$(DOCKER_REGISTRY_ENTERPRISE):$(VERSION)-$*" \
--build-arg TARGETARCH="$*" \
-f $(DOCKERFILE_ENTERPRISE) $(SRC)
gor-snapshot-signoz: build-frontend-static .PHONY: docker-buildx-enterprise
make GORELEASER_WORKDIR=$(EE_QUERY_SERVICE_DIRECTORY) goreleaser-snapshot docker-buildx-enterprise: ## Builds the docker image for enterprise using buildx
docker-buildx-enterprise: go-build-enterprise js-build
gor-snapshot-signoz-community: build-frontend-static @echo ">> building docker image for $(NAME)"
make GORELEASER_WORKDIR=$(QUERY_SERVICE_DIRECTORY) goreleaser-snapshot @docker buildx build --file $(DOCKERFILE_ENTERPRISE) \
--progress plain \
gor-split: --platform linux/arm64,linux/amd64 \
@if [[ ${GORELEASER_WORKDIR} ]]; then \ --push \
${GORELEASER_BIN} release --config ${GORELEASER_WORKDIR}/.goreleaser.yaml --clean --split; \ --tag $(DOCKER_REGISTRY_ENTERPRISE):$(VERSION) $(SRC)
else \
${GORELEASER_BIN} release --clean --split; \
fi
gor-split-histogram-quantile:
make GORELEASER_WORKDIR=$(CH_HISTOGRAM_QUANTILE_DIRECTORY) goreleaser-split
gor-split-signoz: build-frontend-static
make GORELEASER_WORKDIR=$(EE_QUERY_SERVICE_DIRECTORY) goreleaser-split
gor-split-signoz-community: build-frontend-static
make GORELEASER_WORKDIR=$(QUERY_SERVICE_DIRECTORY) goreleaser-split
gor-merge:
${GORELEASER_BIN} continue --merge

View File

@ -3,6 +3,12 @@
# Do not modify this file # Do not modify this file
# #
##################### Version #####################
version:
banner:
# Whether to enable the version banner on startup.
enabled: true
##################### Instrumentation ##################### ##################### Instrumentation #####################
instrumentation: instrumentation:
logs: logs:

View File

@ -177,7 +177,7 @@ services:
# - ../common/clickhouse/storage.xml:/etc/clickhouse-server/config.d/storage.xml # - ../common/clickhouse/storage.xml:/etc/clickhouse-server/config.d/storage.xml
signoz: signoz:
!!merge <<: *db-depend !!merge <<: *db-depend
image: signoz/signoz:${DOCKER_TAG:-v0.76.2} image: signoz/signoz:${VERSION:-v0.76.2}
container_name: signoz container_name: signoz
command: command:
- --config=/root/config/prometheus.yml - --config=/root/config/prometheus.yml

View File

@ -110,7 +110,7 @@ services:
# - ../common/clickhouse/storage.xml:/etc/clickhouse-server/config.d/storage.xml # - ../common/clickhouse/storage.xml:/etc/clickhouse-server/config.d/storage.xml
signoz: signoz:
!!merge <<: *db-depend !!merge <<: *db-depend
image: signoz/signoz:${DOCKER_TAG:-v0.76.2} image: signoz/signoz:${VERSION:-v0.76.2}
container_name: signoz container_name: signoz
command: command:
- --config=/root/config/prometheus.yml - --config=/root/config/prometheus.yml

View File

@ -110,7 +110,7 @@ services:
# - ../common/clickhouse/storage.xml:/etc/clickhouse-server/config.d/storage.xml # - ../common/clickhouse/storage.xml:/etc/clickhouse-server/config.d/storage.xml
signoz: signoz:
!!merge <<: *db-depend !!merge <<: *db-depend
image: signoz/signoz:${DOCKER_TAG:-v0.76.2} image: signoz/signoz:${VERSION:-v0.76.2}
container_name: signoz container_name: signoz
command: command:
- --config=/root/config/prometheus.yml - --config=/root/config/prometheus.yml

View File

@ -61,7 +61,7 @@ This command:
1. Run the backend server: 1. Run the backend server:
```bash ```bash
make run-go make go-run-community
``` ```
2. Verify it's working: 2. Verify it's working:

View File

@ -30,13 +30,11 @@ builds:
- v8.0 - v8.0
ldflags: ldflags:
- -s -w - -s -w
- -X github.com/SigNoz/signoz/pkg/query-service/version.version={{ .Version }} - -X github.com/SigNoz/signoz/pkg/version.version=v{{ .Version }}
- -X main.commit={{ .Commit }} -X main.date={{ .CommitDate }} - -X github.com/SigNoz/signoz/pkg/version.variant=enterprise
- -X main.builtBy=goreleaser - -X github.com/SigNoz/signoz/pkg/version.hash={{ .ShortCommit }}
- -X github.com/SigNoz/signoz/pkg/query-service/version.buildVersion={{ .Version }} - -X github.com/SigNoz/signoz/pkg/version.time={{ .CommitTimestamp }}
- -X github.com/SigNoz/signoz/pkg/query-service/version.buildHash={{ .ShortCommit }} - -X github.com/SigNoz/signoz/pkg/version.branch={{ .Branch }}
- -X github.com/SigNoz/signoz/pkg/query-service/version.buildTime={{ .Date }}
- -X github.com/SigNoz/signoz/pkg/query-service/version.gitBranch={{ .Branch }}
- -X github.com/SigNoz/signoz/ee/query-service/constants.ZeusURL=https://api.signoz.cloud - -X github.com/SigNoz/signoz/ee/query-service/constants.ZeusURL=https://api.signoz.cloud
- -X github.com/SigNoz/signoz/ee/query-service/constants.LicenseSignozIo=https://license.signoz.io/api/v1 - -X github.com/SigNoz/signoz/ee/query-service/constants.LicenseSignozIo=https://license.signoz.io/api/v1
- >- - >-

View File

@ -1,34 +1,21 @@
# use a minimal alpine image
FROM alpine:3.20.3 FROM alpine:3.20.3
# Add Maintainer Info
LABEL maintainer="signoz" LABEL maintainer="signoz"
# define arguments that can be passed during build time
ARG TARGETOS TARGETARCH
# add ca-certificates in case you need them
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
# set working directory
WORKDIR /root WORKDIR /root
# copy the signoz binary ARG OS="linux"
COPY ee/query-service/bin/signoz-${TARGETOS}-${TARGETARCH} /root/signoz ARG TARGETARCH
# copy prometheus YAML config RUN apk update && \
COPY pkg/query-service/config/prometheus.yml /root/config/prometheus.yml apk add ca-certificates && \
COPY pkg/query-service/templates /root/templates rm -rf /var/cache/apk/*
# Make signoz executable for non-root users
RUN chmod 755 /root /root/signoz
# Copy frontend COPY ./target/${OS}-${TARGETARCH}/signoz /root/signoz
COPY ./conf/prometheus.yml /root/config/prometheus.yml
COPY ./templates/email /root/templates
COPY frontend/build/ /etc/signoz/web/ COPY frontend/build/ /etc/signoz/web/
# run the binary RUN chmod 755 /root /root/signoz
ENTRYPOINT ["./signoz"] ENTRYPOINT ["./signoz"]
CMD ["-config", "/root/config/prometheus.yml"] CMD ["-config", "/root/config/prometheus.yml"]
EXPOSE 8080

View File

@ -19,9 +19,9 @@ import (
baseint "github.com/SigNoz/signoz/pkg/query-service/interfaces" baseint "github.com/SigNoz/signoz/pkg/query-service/interfaces"
basemodel "github.com/SigNoz/signoz/pkg/query-service/model" basemodel "github.com/SigNoz/signoz/pkg/query-service/model"
rules "github.com/SigNoz/signoz/pkg/query-service/rules" rules "github.com/SigNoz/signoz/pkg/query-service/rules"
"github.com/SigNoz/signoz/pkg/query-service/version"
"github.com/SigNoz/signoz/pkg/signoz" "github.com/SigNoz/signoz/pkg/signoz"
"github.com/SigNoz/signoz/pkg/types/authtypes" "github.com/SigNoz/signoz/pkg/types/authtypes"
"github.com/SigNoz/signoz/pkg/version"
"github.com/gorilla/mux" "github.com/gorilla/mux"
) )
@ -200,9 +200,8 @@ func (ah *APIHandler) RegisterCloudIntegrationsRoutes(router *mux.Router, am *ba
} }
func (ah *APIHandler) getVersion(w http.ResponseWriter, r *http.Request) { func (ah *APIHandler) getVersion(w http.ResponseWriter, r *http.Request) {
version := version.GetVersion()
versionResponse := basemodel.GetVersionResponse{ versionResponse := basemodel.GetVersionResponse{
Version: version, Version: version.Info.Version(),
EE: "Y", EE: "Y",
SetupCompleted: ah.SetupCompleted, SetupCompleted: ah.SetupCompleted,
} }

View File

@ -12,9 +12,9 @@ import (
"github.com/SigNoz/signoz/pkg/config/fileprovider" "github.com/SigNoz/signoz/pkg/config/fileprovider"
"github.com/SigNoz/signoz/pkg/query-service/auth" "github.com/SigNoz/signoz/pkg/query-service/auth"
baseconst "github.com/SigNoz/signoz/pkg/query-service/constants" baseconst "github.com/SigNoz/signoz/pkg/query-service/constants"
"github.com/SigNoz/signoz/pkg/query-service/version"
"github.com/SigNoz/signoz/pkg/signoz" "github.com/SigNoz/signoz/pkg/signoz"
"github.com/SigNoz/signoz/pkg/types/authtypes" "github.com/SigNoz/signoz/pkg/types/authtypes"
"github.com/SigNoz/signoz/pkg/version"
prommodel "github.com/prometheus/common/model" prommodel "github.com/prometheus/common/model"
@ -78,8 +78,6 @@ func main() {
zap.ReplaceGlobals(loggerMgr) zap.ReplaceGlobals(loggerMgr)
defer loggerMgr.Sync() // flushes buffer, if any defer loggerMgr.Sync() // flushes buffer, if any
version.PrintVersion()
config, err := signoz.NewConfig(context.Background(), config.ResolverConfig{ config, err := signoz.NewConfig(context.Background(), config.ResolverConfig{
Uris: []string{"env:"}, Uris: []string{"env:"},
ProviderFactories: []config.ProviderFactory{ ProviderFactories: []config.ProviderFactory{
@ -95,6 +93,8 @@ func main() {
zap.L().Fatal("Failed to create config", zap.Error(err)) zap.L().Fatal("Failed to create config", zap.Error(err))
} }
version.Info.PrettyPrint(config.Version)
signoz, err := signoz.New( signoz, err := signoz.New(
context.Background(), context.Background(),
config, config,

View File

@ -28,12 +28,12 @@ type SDK struct {
// New creates a new Instrumentation instance with configured providers. // New creates a new Instrumentation instance with configured providers.
// It sets up logging, tracing, and metrics based on the provided configuration. // It sets up logging, tracing, and metrics based on the provided configuration.
func New(ctx context.Context, build version.Build, cfg Config) (*SDK, error) { func New(ctx context.Context, cfg Config, build version.Build, serviceName string) (*SDK, error) {
// Set default resource attributes if not provided // Set default resource attributes if not provided
if cfg.Resource.Attributes == nil { if cfg.Resource.Attributes == nil {
cfg.Resource.Attributes = map[string]any{ cfg.Resource.Attributes = map[string]any{
string(semconv.ServiceNameKey): build.Name, string(semconv.ServiceNameKey): serviceName,
string(semconv.ServiceVersionKey): build.Version, string(semconv.ServiceVersionKey): build.Version(),
} }
} }

View File

@ -30,13 +30,11 @@ builds:
- v8.0 - v8.0
ldflags: ldflags:
- -s -w - -s -w
- -X github.com/SigNoz/signoz/pkg/query-service/version.version={{ .Version }} - -X github.com/SigNoz/signoz/pkg/version.version=v{{ .Version }}
- -X main.commit={{ .Commit }} -X main.date={{ .CommitDate }} - -X github.com/SigNoz/signoz/pkg/version.variant=community
- -X main.builtBy=goreleaser - -X github.com/SigNoz/signoz/pkg/version.hash={{ .ShortCommit }}
- -X github.com/SigNoz/signoz/pkg/query-service/version.buildVersion={{ .Version }} - -X github.com/SigNoz/signoz/pkg/version.time={{ .CommitTimestamp }}
- -X github.com/SigNoz/signoz/pkg/query-service/version.buildHash={{ .ShortCommit }} - -X github.com/SigNoz/signoz/pkg/version.branch={{ .Branch }}
- -X github.com/SigNoz/signoz/pkg/query-service/version.buildTime={{ .Date }}
- -X github.com/SigNoz/signoz/pkg/query-service/version.gitBranch={{ .Branch }}
- >- - >-
{{- if eq .Os "linux" }}-linkmode external -extldflags '-static'{{- end }} {{- if eq .Os "linux" }}-linkmode external -extldflags '-static'{{- end }}
mod_timestamp: "{{ .CommitTimestamp }}" mod_timestamp: "{{ .CommitTimestamp }}"

View File

@ -1,37 +1,21 @@
# use a minimal alpine image
FROM alpine:3.20.3 FROM alpine:3.20.3
# Add Maintainer Info
LABEL maintainer="signoz" LABEL maintainer="signoz"
# define arguments that can be passed during build time
ARG TARGETOS TARGETARCH
# add ca-certificates in case you need them
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
# set working directory
WORKDIR /root WORKDIR /root
# copy the signoz binary ARG OS="linux"
COPY pkg/query-service/bin/signoz-${TARGETOS}-${TARGETARCH} /root/signoz ARG TARGETARCH
# copy prometheus YAML config RUN apk update && \
COPY pkg/query-service/config/prometheus.yml /root/config/prometheus.yml apk add ca-certificates && \
COPY pkg/query-service/templates /root/templates rm -rf /var/cache/apk/*
COPY ./target/${OS}-${TARGETARCH}/signoz-community /root/signoz
COPY ./conf/prometheus.yml /root/config/prometheus.yml
COPY ./templates/email /root/templates
COPY frontend/build/ /etc/signoz/web/
# Make signoz executable for non-root users
RUN chmod 755 /root /root/signoz RUN chmod 755 /root /root/signoz
# Copy frontend
COPY frontend/build/ /etc/signoz/web/
# Copy frontend
COPY frontend/build/ /etc/signoz/web/
# run the binary
ENTRYPOINT ["./signoz"] ENTRYPOINT ["./signoz"]
CMD ["-config", "/root/config/prometheus.yml"] CMD ["-config", "/root/config/prometheus.yml"]
EXPOSE 8080

View File

@ -71,7 +71,7 @@ import (
"github.com/SigNoz/signoz/pkg/query-service/model" "github.com/SigNoz/signoz/pkg/query-service/model"
"github.com/SigNoz/signoz/pkg/query-service/rules" "github.com/SigNoz/signoz/pkg/query-service/rules"
"github.com/SigNoz/signoz/pkg/query-service/telemetry" "github.com/SigNoz/signoz/pkg/query-service/telemetry"
"github.com/SigNoz/signoz/pkg/query-service/version" "github.com/SigNoz/signoz/pkg/version"
) )
type status string type status string
@ -1899,9 +1899,8 @@ func (aH *APIHandler) getDisks(w http.ResponseWriter, r *http.Request) {
} }
func (aH *APIHandler) getVersion(w http.ResponseWriter, r *http.Request) { func (aH *APIHandler) getVersion(w http.ResponseWriter, r *http.Request) {
version := version.GetVersion()
versionResponse := model.GetVersionResponse{ versionResponse := model.GetVersionResponse{
Version: version, Version: version.Info.Version(),
EE: "Y", EE: "Y",
SetupCompleted: aH.SetupCompleted, SetupCompleted: aH.SetupCompleted,
} }

View File

@ -1,11 +0,0 @@
groups:
- name: ExampleCPULoadGroup
rules:
- alert: HighCpuLoad-dev
expr: system_cpu_load_average_1m > 0.01
for: 0m
labels:
severity: warning
annotations:
summary: High CPU load
description: "CPU load is > 0.01\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"

View File

@ -1,4 +0,0 @@
provider: "inmemory"
inmemory:
ttl: 60m
cleanupInterval: 10m

View File

@ -1,25 +0,0 @@
# my global config
global:
scrape_interval: 5s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
- 127.0.0.1:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
- 'alerts.yml'
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs: []
remote_read:
- url: tcp://localhost:9000/signoz_metrics

View File

@ -12,9 +12,9 @@ import (
"github.com/SigNoz/signoz/pkg/query-service/app" "github.com/SigNoz/signoz/pkg/query-service/app"
"github.com/SigNoz/signoz/pkg/query-service/auth" "github.com/SigNoz/signoz/pkg/query-service/auth"
"github.com/SigNoz/signoz/pkg/query-service/constants" "github.com/SigNoz/signoz/pkg/query-service/constants"
"github.com/SigNoz/signoz/pkg/query-service/version"
"github.com/SigNoz/signoz/pkg/signoz" "github.com/SigNoz/signoz/pkg/signoz"
"github.com/SigNoz/signoz/pkg/types/authtypes" "github.com/SigNoz/signoz/pkg/types/authtypes"
"github.com/SigNoz/signoz/pkg/version"
prommodel "github.com/prometheus/common/model" prommodel "github.com/prometheus/common/model"
"go.uber.org/zap" "go.uber.org/zap"
@ -75,7 +75,6 @@ func main() {
defer loggerMgr.Sync() // flushes buffer, if any defer loggerMgr.Sync() // flushes buffer, if any
logger := loggerMgr.Sugar() logger := loggerMgr.Sugar()
version.PrintVersion()
config, err := signoz.NewConfig(context.Background(), config.ResolverConfig{ config, err := signoz.NewConfig(context.Background(), config.ResolverConfig{
Uris: []string{"env:"}, Uris: []string{"env:"},
@ -92,6 +91,8 @@ func main() {
zap.L().Fatal("Failed to create config", zap.Error(err)) zap.L().Fatal("Failed to create config", zap.Error(err))
} }
version.Info.PrettyPrint(config.Version)
signoz, err := signoz.New( signoz, err := signoz.New(
context.Background(), context.Background(),
config, config,

View File

@ -19,8 +19,8 @@ import (
"github.com/SigNoz/signoz/pkg/query-service/interfaces" "github.com/SigNoz/signoz/pkg/query-service/interfaces"
"github.com/SigNoz/signoz/pkg/query-service/model" "github.com/SigNoz/signoz/pkg/query-service/model"
v3 "github.com/SigNoz/signoz/pkg/query-service/model/v3" v3 "github.com/SigNoz/signoz/pkg/query-service/model/v3"
"github.com/SigNoz/signoz/pkg/query-service/version"
"github.com/SigNoz/signoz/pkg/types" "github.com/SigNoz/signoz/pkg/types"
"github.com/SigNoz/signoz/pkg/version"
) )
const ( const (
@ -740,7 +740,7 @@ func (a *Telemetry) SendEvent(event string, data map[string]interface{}, userEma
// zap.L().Info(data) // zap.L().Info(data)
properties := analytics.NewProperties() properties := analytics.NewProperties()
properties.Set("version", version.GetVersion()) properties.Set("version", version.Info.Version)
properties.Set("deploymentType", getDeploymentType()) properties.Set("deploymentType", getDeploymentType())
properties.Set("companyDomain", a.getCompanyDomain()) properties.Set("companyDomain", a.getCompanyDomain())

View File

@ -1,14 +0,0 @@
<!DOCTYPE html>
<html>
<body>
<p>Hi {{.CustomerName}},</p>
<p>You have been invited to join SigNoz project by {{.InviterName}} ({{.InviterEmail}}).</p>
<p>Please click on the following button to accept the invitation:</p>
<a href="{{.Link}}" style="background-color: #000000; color: white; padding: 14px 20px; text-align: center; text-decoration: none; display: inline-block;">Accept Invitation</a>
<p>Button not working? Paste the following link into your browser:</p>
<p>{{.Link}}</p>
<p>Follow docs here 👉 to <a href="https://signoz.io/docs/cloud/">Get Started with SigNoz Cloud</a></p>
<p>Thanks,</p>
<p>SigNoz Team</p>
</body>
</html>

View File

@ -1,46 +0,0 @@
package version
import (
"fmt"
"runtime"
)
// These fields are set during an official build
// Global vars set from command-line arguments
var (
buildVersion = "--"
buildHash = "--"
buildTime = "--"
gitBranch = "--"
)
// BuildDetails returns a string containing details about the SigNoz query-service binary.
func BuildDetails() string {
licenseInfo := `Check SigNoz Github repo for license details`
return fmt.Sprintf(`
SigNoz version : %v
Commit SHA-1 : %v
Commit timestamp : %v
Branch : %v
Go version : %v
For SigNoz Official Documentation, visit https://signoz.io/docs/
For SigNoz Community Slack, visit http://signoz.io/slack/
For archive of discussions about SigNoz, visit https://knowledgebase.signoz.io/
%s.
Copyright 2024 SigNoz
`,
buildVersion, buildHash, buildTime, gitBranch,
runtime.Version(), licenseInfo)
}
// PrintVersion prints version and other helpful information.
func PrintVersion() {
fmt.Println(BuildDetails())
}
func GetVersion() string {
return buildVersion
}

View File

@ -18,11 +18,15 @@ import (
"github.com/SigNoz/signoz/pkg/sqlmigrator" "github.com/SigNoz/signoz/pkg/sqlmigrator"
"github.com/SigNoz/signoz/pkg/sqlstore" "github.com/SigNoz/signoz/pkg/sqlstore"
"github.com/SigNoz/signoz/pkg/telemetrystore" "github.com/SigNoz/signoz/pkg/telemetrystore"
"github.com/SigNoz/signoz/pkg/version"
"github.com/SigNoz/signoz/pkg/web" "github.com/SigNoz/signoz/pkg/web"
) )
// Config defines the entire input configuration of signoz. // Config defines the entire input configuration of signoz.
type Config struct { type Config struct {
// Version config
Version version.Config `mapstructure:"version"`
// Instrumentation config // Instrumentation config
Instrumentation instrumentation.Config `mapstructure:"instrumentation"` Instrumentation instrumentation.Config `mapstructure:"instrumentation"`
@ -61,6 +65,7 @@ type DeprecatedFlags struct {
func NewConfig(ctx context.Context, resolverConfig config.ResolverConfig, deprecatedFlags DeprecatedFlags) (Config, error) { func NewConfig(ctx context.Context, resolverConfig config.ResolverConfig, deprecatedFlags DeprecatedFlags) (Config, error) {
configFactories := []factory.ConfigFactory{ configFactories := []factory.ConfigFactory{
version.NewConfigFactory(),
instrumentation.NewConfigFactory(), instrumentation.NewConfigFactory(),
web.NewConfigFactory(), web.NewConfigFactory(),
cache.NewConfigFactory(), cache.NewConfigFactory(),

View File

@ -34,12 +34,13 @@ func New(
telemetrystoreProviderFactories factory.NamedMap[factory.ProviderFactory[telemetrystore.TelemetryStore, telemetrystore.Config]], telemetrystoreProviderFactories factory.NamedMap[factory.ProviderFactory[telemetrystore.TelemetryStore, telemetrystore.Config]],
) (*SigNoz, error) { ) (*SigNoz, error) {
// Initialize instrumentation // Initialize instrumentation
instrumentation, err := instrumentation.New(ctx, version.Build{}, config.Instrumentation) instrumentation, err := instrumentation.New(ctx, config.Instrumentation, version.Info, "signoz")
if err != nil { if err != nil {
return nil, err return nil, err
} }
instrumentation.Logger().DebugContext(ctx, "starting signoz", "config", config) instrumentation.Logger().InfoContext(ctx, "starting signoz", "version", version.Info.Version(), "variant", version.Info.Variant(), "commit", version.Info.Hash(), "branch", version.Info.Branch(), "go", version.Info.GoVersion(), "time", version.Info.Time())
instrumentation.Logger().DebugContext(ctx, "loaded signoz config", "config", config)
// Get the provider settings from instrumentation // Get the provider settings from instrumentation
providerSettings := instrumentation.ToProviderSettings() providerSettings := instrumentation.ToProviderSettings()

28
pkg/version/config.go Normal file
View File

@ -0,0 +1,28 @@
package version
import "github.com/SigNoz/signoz/pkg/factory"
type BannerConfig struct {
Enabled bool `mapstructure:"enabled"`
}
type Config struct {
Banner BannerConfig `mapstructure:"banner"`
}
func NewConfigFactory() factory.ConfigFactory {
return factory.NewConfigFactory(factory.MustNewName("version"), newConfig)
}
func newConfig() factory.Config {
return Config{
Banner: BannerConfig{
Enabled: true,
},
}
}
func (c Config) Validate() error {
return nil
}

View File

@ -1,4 +0,0 @@
// Package version is used to track the build information of the application.
// This is typically set via ldflags at build time.
// Eg: -ldflags="-X 'pkg/version.Build.Version=v1.0.0'"
package version

View File

@ -1,9 +1,111 @@
package version package version
import (
"fmt"
"runtime"
"strconv"
gotime "time"
)
// This will be set via ldflags at build time.
var (
variant string = "<unset>"
version string = "<unset>"
hash string = "<unset>"
time string = "<unset>"
branch string = "<unset>"
)
var (
Info Build = Build{
variant: variant,
version: version,
hash: hash,
time: time,
branch: branch,
goVersion: runtime.Version(),
}
)
// Build contains information about the build environment. // Build contains information about the build environment.
type Build struct { type Build struct {
// The name of the current build. // The variant of the current build.
Name string variant string
// The version of the current build. // The version of the current build.
Version string version string
// The git hash of the current build.
hash string
// The time of the current build.
time string
// The branch of the current build.
branch string
// The version of go.
goVersion string
}
func (b Build) Variant() string {
return b.variant
}
func (b Build) Version() string {
return b.version
}
func (b Build) Hash() string {
return b.hash
}
func (b Build) Time() string {
return b.time
}
func (b Build) Branch() string {
return b.branch
}
func (b Build) GoVersion() string {
return b.goVersion
}
func (b Build) PrettyPrint(cfg Config) {
if !cfg.Banner.Enabled {
return
}
year := gotime.Now().Year()
ascii := []string{
" -**********= ",
" .::-=+**********+=--:. ",
" .-=*******++=-----==+******=-. ",
" :-+*******=:. :-+******=: ",
" .-********+: .=*******=. ",
" :+********+: .=*******+: ",
" .+*********+ :+***+. -********+: ",
" -**********+. .****= =*********= " + " ____ _ _ _ ____ _ _ _ ",
" .************: +**** +**********: " + " / ___|| |_ __ _ _ __| |_(_)_ __ __ _ / ___|(_) __ _| \\ | | ___ ____ ",
".************+ .----: -***********- " + " \\___ \\| __/ _` | '__| __| | '_ \\ / _` | \\___ \\| |/ _` | \\| |/ _ \\_ / ",
"*************= :************." + " ___) | || (_| | | | |_| | | | | (_| | ___) | | (_| | |\\ | (_) / / _ _ _ ",
":************+ ----: -***********= " + " |____/ \\__\\__,_|_| \\__|_|_| |_|\\__, | |____/|_|\\__, |_| \\_|\\___/___(_|_|_)",
" :************. ***** +**********: " + " |___/ |___/ ",
" .=**********+ :****= -*********+. " + " Version: " + b.version + " (" + b.variant + ")" + " [Copyright " + strconv.Itoa(year) + " SigNoz, All rights reserved]",
" :+*********+ :+***+ -********+: ",
" :+********+. =*******+- ",
" :=********=. -*******=: ",
" :=*******+-. .-+******=-. ",
" :-+*******+=--:::--=+******+=: ",
" .:-==+***********+=-:: ",
" :**********= ",
}
fmt.Println()
for _, line := range ascii {
fmt.Print(line)
fmt.Println()
}
fmt.Println()
} }