├── data ├── minio │ ├── .keep │ └── thanos-data-bucket │ │ └── .keep ├── rule │ └── .keep ├── store │ └── .keep ├── compactor │ └── .keep └── prometheus │ ├── one │ └── .keep │ ├── two │ └── .keep │ └── alertmanager │ └── .keep ├── thanos ├── Dockerfile.debug ├── store.yml ├── Dockerfile.thanos ├── rule │ └── rules.yml └── wait-for-it.sh ├── grafana └── provisioning │ ├── dashboards │ └── dashboards.yaml │ └── datasources │ └── datasources.yaml ├── .gitignore ├── prometheus ├── prometheus_one.yml ├── prometheus_two.yml └── alertmanager.yml ├── LICENSE ├── Makefile ├── README.md └── docker-compose.yml /data/minio/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /data/rule/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /data/store/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /data/compactor/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /data/prometheus/one/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /data/prometheus/two/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /data/minio/thanos-data-bucket/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /data/prometheus/alertmanager/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /thanos/Dockerfile.debug: -------------------------------------------------------------------------------- 1 | FROM ubuntu 2 | COPY ./thanos / 3 | -------------------------------------------------------------------------------- /thanos/store.yml: -------------------------------------------------------------------------------- 1 | type: S3 2 | config: 3 | bucket: thanos-data-bucket 4 | access_key: myaccesskey 5 | secret_key: mysecretkey 6 | endpoint: localhost:9000 7 | insecure: true 8 | -------------------------------------------------------------------------------- /thanos/Dockerfile.thanos: -------------------------------------------------------------------------------- 1 | FROM alpine:3.6 as alpine 2 | RUN apk add -U --no-cache ca-certificates bash 3 | 4 | ENTRYPOINT [] 5 | WORKDIR / 6 | 7 | COPY ./thanos / 8 | COPY ./wait-for-it.sh / 9 | -------------------------------------------------------------------------------- /grafana/provisioning/dashboards/dashboards.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: 1 2 | providers: 3 | - name: 'default' 4 | orgId: 1 5 | folder: '' 6 | folderUid: '' 7 | type: file 8 | options: 9 | path: /provisioning/dashboards 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | data/prometheus/one/* 2 | data/prometheus/two/* 3 | data/prometheus/alertmanager/* 4 | data/rule/* 5 | data/compactor/* 6 | data/minio/**/* 7 | data/store/* 8 | 9 | !data/minio/thanos-data-bucket 10 | data/minio/thanos-data-bucket/* 11 | 12 | !.keep 13 | 14 | thanos/thanos 15 | 16 | grafana/provisioning/dashboards/*.json 17 | -------------------------------------------------------------------------------- /thanos/rule/rules.yml: -------------------------------------------------------------------------------- 1 | groups: 2 | - name: AllInstances 3 | rules: 4 | - alert: InstanceDown 5 | # Condition for alerting 6 | expr: up == 0 7 | for: 1m 8 | # Annotation - additional informational labels to store more information 9 | annotations: 10 | title: 'Instance {{ $labels.instance }} down' 11 | description: '{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 1 minute.' 12 | # Labels - additional labels to be attached to the alert 13 | labels: 14 | severity: 'critical' 15 | -------------------------------------------------------------------------------- /grafana/provisioning/datasources/datasources.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: 1 2 | datasources: 3 | - name: Thanos Query-Frontend 4 | type: prometheus 5 | access: proxy 6 | orgId: 1 7 | url: http://thanos_query_frontend:19090 8 | version: 1 9 | editable: true 10 | isDefault: true 11 | # - name: Thanos Querier 12 | # type: prometheus 13 | # access: proxy 14 | # orgId: 1 15 | # url: http://thanos_querier:10902 16 | # version: 1 17 | # editable: true 18 | # - name: Prometheus One 19 | # type: prometheus 20 | # access: proxy 21 | # orgId: 1 22 | # url: http://prometheus_one:9001 23 | # version: 1 24 | # editable: true 25 | # - name: Prometheus Two 26 | # type: prometheus 27 | # access: proxy 28 | # orgId: 1 29 | # url: http://prometheus_two:9002 30 | # version: 1 31 | # editable: true 32 | -------------------------------------------------------------------------------- /prometheus/prometheus_one.yml: -------------------------------------------------------------------------------- 1 | global: 2 | scrape_interval: 1s 3 | evaluation_interval: 1s 4 | external_labels: 5 | monitor: 'prometheus_one' 6 | 7 | scrape_configs: 8 | - job_name: 'prometheus' 9 | scrape_interval: 100ms 10 | static_configs: 11 | - targets: ['localhost:9001'] 12 | 13 | - job_name: 'minio' 14 | scrape_interval: 100ms 15 | metrics_path: /minio/prometheus/metrics 16 | static_configs: 17 | - targets: ['minio:9000'] 18 | 19 | - job_name: 'thanos-sidecar_one' 20 | static_configs: 21 | - targets: ['thanos_sidecar_one:10902'] 22 | 23 | - job_name: 'thanos-query' 24 | static_configs: 25 | - targets: ['thanos_querier:10902'] 26 | 27 | - job_name: 'thanos_query_frontend' 28 | scrape_interval: 100ms 29 | static_configs: 30 | - targets: ['thanos_query_frontend:19090'] 31 | 32 | - job_name: 'thanos-compact' 33 | static_configs: 34 | - targets: ['thanos_compactor:10902'] 35 | 36 | - job_name: 'thanos-store' 37 | static_configs: 38 | - targets: ['thanos_store:10902'] 39 | -------------------------------------------------------------------------------- /prometheus/prometheus_two.yml: -------------------------------------------------------------------------------- 1 | global: 2 | scrape_interval: 1s 3 | evaluation_interval: 1s 4 | external_labels: 5 | monitor: 'prometheus_two' 6 | 7 | scrape_configs: 8 | - job_name: 'prometheus' 9 | scrape_interval: 100ms 10 | static_configs: 11 | - targets: ['localhost:9002'] 12 | 13 | - job_name: 'minio' 14 | scrape_interval: 100ms 15 | metrics_path: /minio/prometheus/metrics 16 | static_configs: 17 | - targets: ['minio:9000'] 18 | 19 | - job_name: 'thanos-sidecar_two' 20 | static_configs: 21 | - targets: ['thanos_sidecar_two:10902'] 22 | 23 | - job_name: 'thanos-query' 24 | static_configs: 25 | - targets: ['thanos_querier:10902'] 26 | 27 | - job_name: "thanos_query_frontend" 28 | scrape_interval: 100ms 29 | static_configs: 30 | - targets: ["thanos_query_frontend:19090"] 31 | 32 | - job_name: 'thanos-compact' 33 | static_configs: 34 | - targets: ['thanos_compactor:10902'] 35 | 36 | - job_name: 'thanos-store' 37 | static_configs: 38 | - targets: ['thanos_store:10902'] 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Thanos Contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /prometheus/alertmanager.yml: -------------------------------------------------------------------------------- 1 | global: 2 | resolve_timeout: 1m 3 | slack_api_url: '' 4 | 5 | route: 6 | receiver: 'slack-notifications' 7 | 8 | receivers: 9 | - name: 'slack-notifications' 10 | slack_configs: 11 | - channel: '#playground' 12 | send_resolved: true 13 | title: |- 14 | [{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ .CommonLabels.alertname }} for {{ .CommonLabels.job }} 15 | {{- if gt (len .CommonLabels) (len .GroupLabels) -}} 16 | {{" "}}( 17 | {{- with .CommonLabels.Remove .GroupLabels.Names }} 18 | {{- range $index, $label := .SortedPairs -}} 19 | {{ if $index }}, {{ end }} 20 | {{- $label.Name }}="{{ $label.Value -}}" 21 | {{- end }} 22 | {{- end -}} 23 | ) 24 | {{- end }} 25 | text: >- 26 | {{ range .Alerts -}} 27 | *Alert:* {{ .Annotations.title }}{{ if .Labels.severity }} - `{{ .Labels.severity }}`{{ end }} 28 | 29 | *Description:* {{ .Annotations.description }} 30 | 31 | *Details:* 32 | {{ range .Labels.SortedPairs }} • *{{ .Name }}:* `{{ .Value }}` 33 | {{ end }} 34 | {{ end }} 35 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | THANOS_SOURCE ?= ../thanos 2 | COMPOSE_FILE ?= docker-compose.yml 3 | 4 | GOPATH ?= $(shell go env GOPATH) 5 | GOBIN ?= $(firstword $(subst :, ,${GOPATH}))/bin 6 | 7 | THANOS_BINARY ?= $(GOBIN)/thanos 8 | 9 | .PHONY: help 10 | help: ## Displays help. 11 | @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n\nTargets:\n"} /^[a-z0-9A-Z_-]+:.*?##/ { printf " \033[36m%-10s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST) 12 | 13 | .PHONY: $(THANOS_BINARY) 14 | $(THANOS_BINARY): ## Builds the Thanos binary from source code 15 | $(THANOS_BINARY): 16 | @echo ">> building the Thanos binary" 17 | @make -C "$(THANOS_SOURCE)" build 18 | 19 | .PHONY: up 20 | up: ## Bootstraps a docker-compose setup for local development/demo 21 | up: $(THANOS_BINARY) 22 | @echo ">> copying binaries to development env" 23 | @rm -f ./thanos/thanos || true 24 | cp "$(THANOS_BINARY)" ./thanos/ 25 | @echo ">> copying dashboards to development env" 26 | @rm -f ./grafana/provisioning/dashboards/*.json 27 | cp $(THANOS_SOURCE)/examples/dashboards/*.json ./grafana/provisioning/dashboards 28 | docker-compose -f "$(COMPOSE_FILE)" up -d --build 29 | 30 | .PHONY: restart 31 | restart: ## Rebuilds and restarts the container without building the binary 32 | restart: 33 | docker-compose -f "$(COMPOSE_FILE)" up -d --build 34 | 35 | .PHONY: down 36 | down: ## Brings down the docker-compose setup 37 | down: 38 | docker-compose -f "$(COMPOSE_FILE)" down 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Thanos Docker Compose 2 | 3 | Run a basic Thanos setup for local development using Docker and Docker Compose. 4 | 5 | ## Prerequisites 6 | 7 | - You need to have Docker and docker-compose installed on your machine. 8 | - We use GNU Make to run common tasks, you need to have `make` installed on your machine. You can run `make -v` to check if it is already installed. 9 | - Thanos source code. The easiest way to achieve this is by cloning the Thanos git repository locally using `git clone https://github.com/thanos-io/thanos`. 10 | - You need to have Go installed as it is required to build Thanos. 11 | - Modify the `THANOS_SOURCE` variable in the `Makefile` so that it points to the directory containing Thanos source code. This step is required to build `thanos` binary from this directory. 12 | 13 | ## Usage 14 | 15 | ### Start the dev environment 16 | 17 | - Run `make up` 18 | 19 | > NOTE: If you are using MacOS, run `GOOS=linux make up`. This target tries to build the binary by running `make build` inside the `$THANOS_SOURCE` directory defined in the Makefile, and then gets the `thanos` binary from `$GOPATH/bin/thanos`. You need to set up the `THANOS_SOURCE` variable for this to work. 20 | 21 | ### Stop the dev environment 22 | 23 | - Run `make down` 24 | 25 | ### Restarting the env with changes 26 | 27 | - We need to build the `thanos` binary again in case of changes in source code, just run `make up` to restart the containers with new changes, it takes care of building the binary for you. 28 | - If you want to skip building the binary, and just restart the docker containers (for example when you are testing different flags), you can run `make restart` to restart the containers. 29 | 30 | ### Checking status of containers 31 | 32 | - You can run `docker-compose ps` to list all containers running. 33 | - Run `docker-compose logs ` to view logs for a container. 34 | 35 | Refer to `docker-compose` documentation for a full overview. 36 | 37 | ### Connecting to minio 38 | 39 | After running `make up` you would be able to access `minio` at `http://localhost:9000`. The access key is `myaccesskey` and the secret key is `mysecretkey`. 40 | 41 | ## What does it start? 42 | 43 | | Service | | Ports | 44 | | ------------------ | ---------------------------------------------------------------------------- | ----- | 45 | | prometheus_one | The first Prometheus server | 9001 | 46 | | prometheus_two | The second Prometheus server | | 47 | | minio | A minio instance serving as Object Storage for store, compactor and sidecars | 9000 | 48 | | thanos_sidecar_one | First Thanos sidecar for prometheus_one | | 49 | | thanos_sidecar_two | Second Thanos sidecar for prometheus_two | | 50 | | thanos_querier | Thanos querier instance connected to both sidecars and Thanos store | 10902 | 51 | | thanos_query_frontend | Thanos query frontend connected to querier | 19090 | 52 | | thanos_compactor | Thanos compactor running with `--wait` and `--wait-interval=3m` | 10922 | 53 | | thanos_store | A Thanos store instance connected to minio | 10912 | 54 | 55 | ### Optional services 56 | 57 | There are some services which are commented out in the `docker-compose.yml`. You can uncomment and use them if needed. 58 | 59 | | Service | | Ports | 60 | | ------------ | -------------------------------------------------------------------------------------------------------- | ----- | 61 | | grafana | A Grafana instance with username = admin, and password = admin | 3000 | 62 | | bucket_web | Thanos Bucket Inspector WebUI | 8080 | 63 | | debug | A debug container running on ubuntu with `thanos` binary. You can use this to debug services from inside | 10902 | 64 | | alertmanager | Prometheus Alertmanager to send alerts | 9093 | 65 | | thanos_rule | Thanos Rule instance to create recording and alerting rules | 10932 | 66 | 67 | You can start a debug container and/or Thanos Bucket WebUI by uncommenting the corresponding definition in `docker-compose.yml`. 68 | 69 | For Alertmanager to work, you need to set the Slack webhook URL in `prometheus/alertmanager.yml`. 70 | 71 | ## Credits 72 | 73 | The `docker-compose.yml` is based on [PR#2583](https://github.com/thanos-io/thanos/pull/2583) on Thanos GitHub repo by [Darshan Chaudhary](https://github.com/darshanime) 74 | -------------------------------------------------------------------------------- /thanos/wait-for-it.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Use this script to test if a given TCP host/port are available 3 | 4 | WAITFORIT_cmdname=${0##*/} 5 | 6 | echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi } 7 | 8 | usage() 9 | { 10 | cat << USAGE >&2 11 | Usage: 12 | $WAITFORIT_cmdname host:port [-s] [-t timeout] [-- command args] 13 | -h HOST | --host=HOST Host or IP under test 14 | -p PORT | --port=PORT TCP port under test 15 | Alternatively, you specify the host and port as host:port 16 | -s | --strict Only execute subcommand if the test succeeds 17 | -q | --quiet Don't output any status messages 18 | -t TIMEOUT | --timeout=TIMEOUT 19 | Timeout in seconds, zero for no timeout 20 | -- COMMAND ARGS Execute command with args after the test finishes 21 | USAGE 22 | exit 1 23 | } 24 | 25 | wait_for() 26 | { 27 | if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then 28 | echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT" 29 | else 30 | echoerr "$WAITFORIT_cmdname: waiting for $WAITFORIT_HOST:$WAITFORIT_PORT without a timeout" 31 | fi 32 | WAITFORIT_start_ts=$(date +%s) 33 | while : 34 | do 35 | if [[ $WAITFORIT_ISBUSY -eq 1 ]]; then 36 | nc -z $WAITFORIT_HOST $WAITFORIT_PORT 37 | WAITFORIT_result=$? 38 | else 39 | (echo > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1 40 | WAITFORIT_result=$? 41 | fi 42 | if [[ $WAITFORIT_result -eq 0 ]]; then 43 | WAITFORIT_end_ts=$(date +%s) 44 | echoerr "$WAITFORIT_cmdname: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds" 45 | break 46 | fi 47 | sleep 1 48 | done 49 | return $WAITFORIT_result 50 | } 51 | 52 | wait_for_wrapper() 53 | { 54 | # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692 55 | if [[ $WAITFORIT_QUIET -eq 1 ]]; then 56 | timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --quiet --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT & 57 | else 58 | timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT & 59 | fi 60 | WAITFORIT_PID=$! 61 | trap "kill -INT -$WAITFORIT_PID" INT 62 | wait $WAITFORIT_PID 63 | WAITFORIT_RESULT=$? 64 | if [[ $WAITFORIT_RESULT -ne 0 ]]; then 65 | echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT" 66 | fi 67 | return $WAITFORIT_RESULT 68 | } 69 | 70 | # process arguments 71 | while [[ $# -gt 0 ]] 72 | do 73 | case "$1" in 74 | *:* ) 75 | WAITFORIT_hostport=(${1//:/ }) 76 | WAITFORIT_HOST=${WAITFORIT_hostport[0]} 77 | WAITFORIT_PORT=${WAITFORIT_hostport[1]} 78 | shift 1 79 | ;; 80 | --child) 81 | WAITFORIT_CHILD=1 82 | shift 1 83 | ;; 84 | -q | --quiet) 85 | WAITFORIT_QUIET=1 86 | shift 1 87 | ;; 88 | -s | --strict) 89 | WAITFORIT_STRICT=1 90 | shift 1 91 | ;; 92 | -h) 93 | WAITFORIT_HOST="$2" 94 | if [[ $WAITFORIT_HOST == "" ]]; then break; fi 95 | shift 2 96 | ;; 97 | --host=*) 98 | WAITFORIT_HOST="${1#*=}" 99 | shift 1 100 | ;; 101 | -p) 102 | WAITFORIT_PORT="$2" 103 | if [[ $WAITFORIT_PORT == "" ]]; then break; fi 104 | shift 2 105 | ;; 106 | --port=*) 107 | WAITFORIT_PORT="${1#*=}" 108 | shift 1 109 | ;; 110 | -t) 111 | WAITFORIT_TIMEOUT="$2" 112 | if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi 113 | shift 2 114 | ;; 115 | --timeout=*) 116 | WAITFORIT_TIMEOUT="${1#*=}" 117 | shift 1 118 | ;; 119 | --) 120 | shift 121 | WAITFORIT_CLI=("$@") 122 | break 123 | ;; 124 | --help) 125 | usage 126 | ;; 127 | *) 128 | echoerr "Unknown argument: $1" 129 | usage 130 | ;; 131 | esac 132 | done 133 | 134 | if [[ "$WAITFORIT_HOST" == "" || "$WAITFORIT_PORT" == "" ]]; then 135 | echoerr "Error: you need to provide a host and port to test." 136 | usage 137 | fi 138 | 139 | WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-15} 140 | WAITFORIT_STRICT=${WAITFORIT_STRICT:-0} 141 | WAITFORIT_CHILD=${WAITFORIT_CHILD:-0} 142 | WAITFORIT_QUIET=${WAITFORIT_QUIET:-0} 143 | 144 | # Check to see if timeout is from busybox? 145 | WAITFORIT_TIMEOUT_PATH=$(type -p timeout) 146 | WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH) 147 | 148 | WAITFORIT_BUSYTIMEFLAG="" 149 | if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then 150 | WAITFORIT_ISBUSY=1 151 | # Check if busybox timeout uses -t flag 152 | # (recent Alpine versions don't support -t anymore) 153 | if timeout &>/dev/stdout | grep -q -e '-t '; then 154 | WAITFORIT_BUSYTIMEFLAG="-t" 155 | fi 156 | else 157 | WAITFORIT_ISBUSY=0 158 | fi 159 | 160 | if [[ $WAITFORIT_CHILD -gt 0 ]]; then 161 | wait_for 162 | WAITFORIT_RESULT=$? 163 | exit $WAITFORIT_RESULT 164 | else 165 | if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then 166 | wait_for_wrapper 167 | WAITFORIT_RESULT=$? 168 | else 169 | wait_for 170 | WAITFORIT_RESULT=$? 171 | fi 172 | fi 173 | 174 | if [[ $WAITFORIT_CLI != "" ]]; then 175 | if [[ $WAITFORIT_RESULT -ne 0 && $WAITFORIT_STRICT -eq 1 ]]; then 176 | echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess" 177 | exit $WAITFORIT_RESULT 178 | fi 179 | exec "${WAITFORIT_CLI[@]}" 180 | else 181 | exit $WAITFORIT_RESULT 182 | fi 183 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.2' 2 | services: 3 | prometheus_one: 4 | image: prom/prometheus:v2.21.0 5 | container_name: prometheus_one 6 | user: root 7 | volumes: 8 | - ./prometheus:/etc/config/ 9 | - ./data/prometheus/one:/data 10 | command: 11 | - '--config.file=/etc/config/prometheus_one.yml' 12 | - '--storage.tsdb.path=/data' 13 | - '--web.console.libraries=/etc/prometheus/console_libraries' 14 | - '--web.console.templates=/etc/prometheus/consoles' 15 | - '--storage.tsdb.retention.time=2h' 16 | - '--web.enable-lifecycle' 17 | - '--web.enable-admin-api' 18 | - '--web.listen-address=:9001' 19 | - '--storage.tsdb.min-block-duration=5m' 20 | - '--storage.tsdb.max-block-duration=5m' 21 | restart: unless-stopped 22 | expose: 23 | - 9001 24 | ports: 25 | - "9001:9001" 26 | 27 | prometheus_two: 28 | image: prom/prometheus:v2.21.0 29 | container_name: prometheus_two 30 | user: root 31 | volumes: 32 | - ./prometheus:/etc/config/ 33 | - ./data/prometheus/two:/data 34 | command: 35 | - '--config.file=/etc/config/prometheus_two.yml' 36 | - '--storage.tsdb.path=/data' 37 | - '--web.console.libraries=/etc/prometheus/console_libraries' 38 | - '--web.console.templates=/etc/prometheus/consoles' 39 | - '--storage.tsdb.retention.time=2h' 40 | - '--web.enable-lifecycle' 41 | - '--web.enable-admin-api' 42 | - '--web.listen-address=:9002' 43 | - '--storage.tsdb.min-block-duration=5m' 44 | - '--storage.tsdb.max-block-duration=5m' 45 | restart: unless-stopped 46 | expose: 47 | - 9002 48 | 49 | minio: 50 | image: minio/minio:RELEASE.2020-09-10T22-02-45Z 51 | container_name: minio 52 | volumes: 53 | - ./data/minio:/data 54 | ports: 55 | - "9000:9000" 56 | environment: 57 | MINIO_PROMETHEUS_AUTH_TYPE: public 58 | MINIO_ACCESS_KEY: myaccesskey 59 | MINIO_SECRET_KEY: mysecretkey 60 | command: server /data 61 | healthcheck: 62 | test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"] 63 | interval: 30s 64 | timeout: 20s 65 | retries: 3 66 | 67 | thanos_sidecar_one: 68 | build: 69 | context: ./thanos 70 | dockerfile: Dockerfile.thanos 71 | container_name: thanos_sidecar_one 72 | volumes: 73 | - ./prometheus:/etc/config/ 74 | - ./data/prometheus/one:/data 75 | command: 76 | - "/wait-for-it.sh" 77 | - "prometheus_one:9001" 78 | - "--" 79 | - "/thanos" 80 | - "sidecar" 81 | - "--log.level=debug" 82 | - "--tsdb.path=/data" 83 | - "--prometheus.url=http://prometheus_one:9001" 84 | - "--reloader.config-file=/etc/config/prometheus_one.yml" 85 | - | 86 | --objstore.config=type: S3 87 | config: 88 | bucket: thanos-data-bucket 89 | access_key: myaccesskey 90 | secret_key: mysecretkey 91 | endpoint: minio:9000 92 | insecure: true 93 | expose: 94 | - 10902 95 | - 10901 96 | depends_on: 97 | - minio 98 | 99 | thanos_sidecar_two: 100 | build: 101 | context: ./thanos 102 | dockerfile: Dockerfile.thanos 103 | container_name: thanos_sidecar_two 104 | volumes: 105 | - ./prometheus:/etc/config/ 106 | - ./data/prometheus/two:/data 107 | command: 108 | - "/wait-for-it.sh" 109 | - "prometheus_two:9002" 110 | - "--" 111 | - "/thanos" 112 | - "sidecar" 113 | - "--log.level=debug" 114 | - "--tsdb.path=/data" 115 | - "--prometheus.url=http://prometheus_two:9002" 116 | - "--reloader.config-file=/etc/config/prometheus_two.yml" 117 | - | 118 | --objstore.config=type: S3 119 | config: 120 | bucket: thanos-data-bucket 121 | access_key: myaccesskey 122 | secret_key: mysecretkey 123 | endpoint: minio:9000 124 | insecure: true 125 | expose: 126 | - 10902 127 | - 10901 128 | depends_on: 129 | - minio 130 | 131 | thanos_querier: 132 | build: 133 | context: ./thanos 134 | dockerfile: Dockerfile.thanos 135 | container_name: thanos_querier 136 | command: 137 | - "/wait-for-it.sh" 138 | - "thanos_sidecar_one:10901" 139 | - "--" 140 | - "/thanos" 141 | - "query" 142 | - "--log.level=debug" 143 | - "--log.format=logfmt" 144 | - "--store=thanos_sidecar_one:10901" 145 | - "--store=thanos_sidecar_two:10901" 146 | - "--store=thanos_store:10901" 147 | # - "--store=thanos_rule:10901" 148 | - "--store.sd-interval=5m" 149 | - "--query.replica-label=monitor" 150 | expose: 151 | - 10902 152 | - 10901 153 | ports: 154 | - "10902:10902" 155 | depends_on: 156 | - minio 157 | 158 | thanos_query_frontend: 159 | build: 160 | context: ./thanos 161 | dockerfile: Dockerfile.thanos 162 | container_name: thanos_query_frontend 163 | command: 164 | - "/wait-for-it.sh" 165 | - "thanos_querier:10901" 166 | - "--" 167 | - "/thanos" 168 | - "query-frontend" 169 | - "--log.level=debug" 170 | - "--log.format=logfmt" 171 | - "--http-address=0.0.0.0:19090" 172 | - "--query-frontend.compress-responses" 173 | - "--query-range.partial-response" 174 | - "--query-frontend.downstream-url=http://thanos_querier:10902" 175 | - "--query-range.split-interval=24h" 176 | - "--query-range.max-retries-per-request=5" 177 | - "--query-frontend.log-queries-longer-than=5s" 178 | - "--cache-compression-type=snappy" 179 | ports: 180 | - "19090:19090" 181 | depends_on: 182 | - thanos_querier 183 | 184 | thanos_compactor: 185 | build: 186 | context: ./thanos 187 | dockerfile: Dockerfile.thanos 188 | container_name: thanos_compactor 189 | volumes: 190 | - ./data/compactor:/data 191 | command: 192 | - "/wait-for-it.sh" 193 | - "minio:9000" 194 | - "--" 195 | - "/thanos" 196 | - "compact" 197 | - "--log.level=debug" 198 | - "--log.format=logfmt" 199 | - | 200 | --objstore.config=type: S3 201 | config: 202 | bucket: thanos-data-bucket 203 | access_key: myaccesskey 204 | secret_key: mysecretkey 205 | endpoint: minio:9000 206 | insecure: true 207 | - "--data-dir=/data" 208 | - "--consistency-delay=30m" 209 | - "--retention.resolution-raw=30d" 210 | - "--retention.resolution-5m=120d" 211 | - "--retention.resolution-1h=1y" 212 | - "--block-sync-concurrency=20" 213 | - "--compact.concurrency=1" 214 | - "--delete-delay=15m" 215 | - "--wait" 216 | - "--wait-interval=3m" 217 | expose: 218 | - 10902 219 | - 10901 220 | ports: 221 | - "10922:10902" 222 | depends_on: 223 | - minio 224 | 225 | 226 | thanos_store: 227 | build: 228 | context: ./thanos 229 | dockerfile: Dockerfile.thanos 230 | container_name: thanos_store 231 | volumes: 232 | - ./data/store:/data 233 | command: 234 | - "/wait-for-it.sh" 235 | - "minio:9000" 236 | - "--" 237 | - "/thanos" 238 | - "store" 239 | - "--log.level=debug" 240 | - | 241 | --objstore.config=type: S3 242 | config: 243 | bucket: thanos-data-bucket 244 | access_key: myaccesskey 245 | secret_key: mysecretkey 246 | endpoint: minio:9000 247 | insecure: true 248 | - "--data-dir=/data" 249 | - "--log.format=logfmt" 250 | - "--index-cache-size=250MB" 251 | - "--chunk-pool-size=1GB" 252 | - "--store.grpc.series-max-concurrency=20" 253 | - "--sync-block-duration=3m" 254 | - "--block-sync-concurrency=20" 255 | restart: unless-stopped 256 | expose: 257 | - 10902 258 | - 10901 259 | depends_on: 260 | - minio 261 | ports: 262 | - '10912:10902' 263 | 264 | # alertmanager: 265 | # image: prom/alertmanager:v0.21.0 266 | # container_name: alertmanager 267 | # user: root 268 | # volumes: 269 | # - ./prometheus:/etc/config/ 270 | # - ./data/prometheus/alertmanager:/data 271 | # command: 272 | # - '--config.file=/etc/config/alertmanager.yml' 273 | # restart: unless-stopped 274 | # expose: 275 | # - 9093 276 | # ports: 277 | # - "9093:9093" 278 | 279 | # thanos_rule: 280 | # build: 281 | # context: ./thanos 282 | # dockerfile: Dockerfile.thanos 283 | # container_name: thanos_rule 284 | # volumes: 285 | # - ./data/rule:/data 286 | # - ./thanos/rule:/etc/config/ 287 | # command: 288 | # - "/wait-for-it.sh" 289 | # - "minio:9000" 290 | # - "--" 291 | # - "/thanos" 292 | # - "rule" 293 | # - "--log.level=debug" 294 | # - | 295 | # --objstore.config=type: S3 296 | # config: 297 | # bucket: thanos-data-bucket 298 | # access_key: myaccesskey 299 | # secret_key: mysecretkey 300 | # endpoint: minio:9000 301 | # insecure: true 302 | # - "--data-dir=/data" 303 | # - "--log.format=logfmt" 304 | # - "--rule-file=/etc/config/rules.yml" 305 | # - "--alert.query-url=http://localhost:10902" 306 | # - "--alertmanagers.url=http://alertmanager:9093" 307 | # - "--query=thanos_querier:10902" 308 | # expose: 309 | # - 10902 310 | # - 10901 311 | # depends_on: 312 | # - minio 313 | # ports: 314 | # - '10932:10902' 315 | 316 | # grafana: 317 | # image: grafana/grafana:7.4.5 318 | # container_name: grafana 319 | # user: root 320 | # volumes: 321 | # - ./grafana/provisioning:/provisioning 322 | # environment: 323 | # - GF_SECURITY_ADMIN_USER=${ADMIN_USER:-admin} 324 | # - GF_SECURITY_ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin} 325 | # - GF_USERS_ALLOW_SIGN_UP=false 326 | # - GF_PATHS_PROVISIONING=/provisioning 327 | # restart: unless-stopped 328 | # ports: 329 | # - "3000:3000" 330 | 331 | # bucket_web: 332 | # build: 333 | # context: ./thanos 334 | # dockerfile: Dockerfile.thanos 335 | # container_name: bucket_web 336 | # command: 337 | # - "/thanos" 338 | # - "tools" 339 | # - "bucket" 340 | # - "web" 341 | # - | 342 | # --objstore.config=type: S3 343 | # config: 344 | # bucket: thanos-data-bucket 345 | # access_key: myaccesskey 346 | # secret_key: mysecretkey 347 | # endpoint: minio:9000 348 | # insecure: true 349 | # - "--http-address=0.0.0.0:8080" 350 | # - "--label=monitor" 351 | # expose: 352 | # - 8080 353 | # ports: 354 | # - "8080:8080" 355 | 356 | # debug: 357 | # build: 358 | # context: thanos 359 | # dockerfile: Dockerfile.debug 360 | # container_name: debug 361 | # user: root 362 | # stdin_open: true 363 | # tty: true 364 | # expose: 365 | # - 10902 366 | # - 10901 367 | # ports: 368 | # - "10902:10902" 369 | --------------------------------------------------------------------------------