Skip to content

Commit

Permalink
Add query-tee to microservices Docker Compose setup
Browse files Browse the repository at this point in the history
  • Loading branch information
charleskorn committed Jun 19, 2024
1 parent 44ae290 commit 39b6524
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 14 deletions.
8 changes: 7 additions & 1 deletion development/mimir-microservices-mode/compose-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ cd "$SCRIPT_DIR" && make
# -gcflags "all=-N -l" disables optimizations that allow for better run with combination with Delve debugger.
# GOARCH is not changed.
CGO_ENABLED=0 GOOS=linux go build -mod=vendor -tags=netgo,stringlabels -gcflags "all=-N -l" -o "${SCRIPT_DIR}"/mimir "${SCRIPT_DIR}"/../../cmd/mimir

docker_compose -f "${SCRIPT_DIR}"/docker-compose.yml build --build-arg BUILD_IMAGE="${BUILD_IMAGE}" distributor-1

if [ "$(yq '.services.query-tee' "${SCRIPT_DIR}"/docker-compose.yml)" != "null" ]; then
# If query-tee is enabled, build its binary and image as well.
CGO_ENABLED=0 GOOS=linux go build -mod=vendor -tags=netgo,stringlabels -gcflags "all=-N -l" -o "${SCRIPT_DIR}"/../../cmd/query-tee "${SCRIPT_DIR}"/../../cmd/query-tee
docker_compose -f "${SCRIPT_DIR}"/docker-compose.yml build --build-arg BUILD_IMAGE="${BUILD_IMAGE}" query-tee
fi

docker_compose -f "${SCRIPT_DIR}"/docker-compose.yml up "$@"
49 changes: 36 additions & 13 deletions development/mimir-microservices-mode/docker-compose.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ std.manifestYamlDoc({
enable_grafana_agent: false,
enable_prometheus: true, // If Prometheus is disabled, recording rules will not be evaluated and so dashboards in Grafana that depend on these recorded series will display no data.
enable_otel_collector: false,

// If true, a query-tee instance with a single backend is started.
enable_query_tee: false,
},

// We explicitely list all important services here, so that it's easy to disable them by commenting out.
Expand All @@ -51,6 +54,7 @@ std.manifestYamlDoc({
(if $._config.ring == 'consul' || $._config.ring == 'multi' then self.consul else {}) +
(if $._config.cache_backend == 'redis' then self.redis else self.memcached + self.memcached_exporter) +
(if $._config.enable_load_generator then self.load_generator else {}) +
(if $._config.enable_query_tee then self.query_tee else {}) +
{},

distributor:: {
Expand Down Expand Up @@ -175,6 +179,21 @@ std.manifestYamlDoc({

local all_rings = ['-ingester.ring', '-distributor.ring', '-compactor.ring', '-store-gateway.sharding-ring', '-ruler.ring', '-alertmanager.sharding-ring'],

local jaegerEnv(appName) = {
JAEGER_AGENT_HOST: 'jaeger',
JAEGER_AGENT_PORT: 6831,
JAEGER_SAMPLER_TYPE: 'const',
JAEGER_SAMPLER_PARAM: 1,
JAEGER_TAGS: 'app=%s' % appName,
JAEGER_REPORTER_MAX_QUEUE_SIZE: 1000,
},

local formatEnv(env) = [
'%s=%s' % [key, env[key]]
for key in std.objectFields(env)
if env[key] != null
],

// This function builds docker-compose declaration for Mimir service.
// Default grpcPort is (httpPort + 1000), and default debug port is (httpPort + 10000)
local mimirService(serviceOptions) = {
Expand All @@ -189,14 +208,7 @@ std.manifestYamlDoc({
// Extra arguments passed to Mimir command line.
extraArguments: '',
dependsOn: ['minio'] + (if $._config.ring == 'consul' || $._config.ring == 'multi' then ['consul'] else if s.target != 'distributor' then ['distributor-1'] else []),
env: {
JAEGER_AGENT_HOST: 'jaeger',
JAEGER_AGENT_PORT: 6831,
JAEGER_SAMPLER_TYPE: 'const',
JAEGER_SAMPLER_PARAM: 1,
JAEGER_TAGS: 'app=%s' % s.jaegerApp,
JAEGER_REPORTER_MAX_QUEUE_SIZE: 1000,
},
env: jaegerEnv(s.jaegerApp),
extraVolumes: [],
memberlistNodeName: self.jaegerApp,
memberlistBindPort: self.httpPort + 2000,
Expand All @@ -223,11 +235,7 @@ std.manifestYamlDoc({
std.join(' ', if $._config.cache_backend == 'redis' then [x + '.backend=redis' for x in all_caches] + [x + '.redis.endpoint=redis:6379' for x in all_caches] else [x + '.backend=memcached' for x in all_caches] + [x + '.memcached.addresses=dns+memcached:11211' for x in all_caches]),
]),
],
environment: [
'%s=%s' % [key, options.env[key]]
for key in std.objectFields(options.env)
if options.env[key] != null
],
environment: formatEnv(options.env),
hostname: options.name,
// Only publish HTTP and debug port, but not gRPC one.
ports: ['%d:%d' % [options.httpPort, options.httpPort]] +
Expand Down Expand Up @@ -385,6 +393,21 @@ std.manifestYamlDoc({
},
},

query_tee:: {
'query-tee': {
local env = jaegerEnv('query-tee'),

image: 'query-tee',
build: {
context: '../../cmd/query-tee',
},
command: '-backend.endpoints=http://nginx:8080 -backend.preferred=nginx -proxy.passthrough-non-registered-routes=true -server.path-prefix=/prometheus',
environment: formatEnv(env),
hostname: 'query-tee',
ports: ['9999:80'],
},
},

// docker-compose YAML output version.
version: '3.4',

Expand Down

0 comments on commit 39b6524

Please sign in to comment.