signoz/pkg/query-service
Nityananda Gohain 2d73f91380
Fix: Multitenancy support for ORG (#7155)
* fix: support multitenancy in org

* fix: register and login working now

* fix: changes to migration

* fix: migrations run both on sqlite and postgres

* fix: remove user flags from fe and be

* fix: remove ingestion keys from update

* fix: multitenancy support for apdex settings

* fix: render ts for users correctly

* fix: fix migration to run for new tenants

* fix: clean up migrations

* fix: address comments

* Update pkg/sqlmigration/013_update_organization.go

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* fix: fix build

* fix: force invites with org id

* Update pkg/query-service/auth/auth.go

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* fix: address comments

* fix: address comments

* fix: provier with their own dialect

* fix: update dialects

* fix: remove unwanted change

* Update pkg/query-service/app/http_handler.go

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* fix: different files for types

---------

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-03-06 15:39:45 +05:30
..
2024-05-15 18:52:01 +05:30
2021-01-03 18:15:44 +05:30
2021-09-02 13:18:47 +05:30
2025-02-17 18:16:41 +05:30

Query Service

Query service is the interface between frontend and databases. It is written in Golang. It will have modules for all supported databases. Query service is responsible to:

  • parse the request from Frontend
  • create relevant Clickhouse queries (and all other supported database queries)
  • parse response from databases and handle error if any
  • clickhouse response in the format accepted by Frontend

Complete the clickhouse setup locally.

https://github.com/SigNoz/signoz/blob/main/CONTRIBUTING.md#42-to-run-clickhouse-setup-recommended-for-local-development

  • Comment out the query-service and the frontend section in signoz/deploy/docker/docker-compose.yaml
  • Change the alertmanager section in signoz/deploy/docker/docker-compose.yaml as follows:
alertmanager:
    image: signoz/alertmanager:0.23.7
    volumes:
      - ./data/alertmanager:/data
    expose:
      - "9093"
    ports:
      - "8080:9093"
    # depends_on:
    #   query-service:
    #     condition: service_healthy
    restart: unless-stopped
    command:
      - --queryService.url=http://172.17.0.1:8085
      - --storage.path=/data
  • Run the following:
cd deploy/docker
docker compose up -d

Backend Configuration

  • Open ./constants/constants.go

    • Replace const RELATIONAL_DATASOURCE_PATH = "/var/lib/signoz/signoz.db"
      with const RELATIONAL_DATASOURCE_PATH = "./signoz.db".
  • Query Service needs below env variables to run:

    export ClickHouseUrl=tcp://localhost:9001
    export STORAGE=clickhouse
    export ALERTMANAGER_API_PREFIX=http://localhost:9093/api/

Build and Run locally

cd pkg/query-service
go build -o build/query-service main.go
ClickHouseUrl=tcp://localhost:9001 STORAGE=clickhouse build/query-service --prefer-delta=true 

Frontend Configuration for local query-service.

  • Set the following environment variables
export FRONTEND_API_ENDPOINT=http://localhost:8080
  • Run the following
cd signoz\frontend\
yarn install
yarn dev

Note:

If you use go version 1.18 for development and contributions, then please checkout the following issue. https://github.com/SigNoz/signoz/issues/1371

Docker Images

The docker images of query-service is available at https://hub.docker.com/r/signoz/query-service