Skip to content

Commit dda20f0

Browse files
authored
Added website for Thanos' docs using Hugo. (#807)
Hosted in github pages. Signed-off-by: adrien-f <[email protected]> Signed-off-by: Bartek Plotka <[email protected]>
1 parent e6d5b49 commit dda20f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1150
-506
lines changed

.circleci/config.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ jobs:
6161
# Available from https://hub.docker.com/r/circleci/golang/
6262
- image: circleci/golang:1.12
6363
working_directory: /go/src/github.com/improbable-eng/thanos
64+
environment:
65+
GOBIN: "/go/src/github.com/improbable-eng/thanos/.bin"
6466
steps:
6567
- checkout
6668
- setup_remote_docker:
@@ -127,4 +129,4 @@ workflows:
127129
tags:
128130
only: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
129131
branches:
130-
ignore: /.*/
132+
ignore: /.*/

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ data/
1717

1818
/.idea
1919
/*.iml
20+
21+
website/public/
22+
website/docs-pre-processed/
23+
website/hugo-generated.yaml

CODE_OF_CONDUCT.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,4 @@ face temporary or permanent repercussions as determined by other members of the
5858

5959
## Attribution
6060

61-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
62-
63-
[homepage]: http://contributor-covenant.org
64-
[version]: http://contributor-covenant.org/version/1/4/
61+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.4, available at [http://contributor-covenant.org/version/1/4](http://contributor-covenant.org/version/1/4/)

Makefile

+82-25
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,54 @@ PREFIX ?= $(shell pwd)
22
DIRECTORIES ?= $(shell find . -path './*' -prune -type d -not -path "./vendor")
33
DOCKER_IMAGE_NAME ?= thanos
44
DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))-$(shell date +%Y-%m-%d)-$(shell git rev-parse --short HEAD)
5-
# $GOPATH/bin might not be in $PATH, so we can't assume `which` would give use
6-
# the path of promu et al. As for selecting the first GOPATH, we assume:
7-
# - most people only have one GOPATH at a time;
8-
# - if you don't have one or any of those tools installed, running `go get`
9-
# would place them in the first GOPATH.
10-
# It's possible that any of the tools would be installed in the other GOPATHs,
11-
# but for simplicity sake we just make sure they exist in the first one, and
12-
# then keep using those.
13-
FIRST_GOPATH ?= $(firstword $(subst :, ,$(shell go env GOPATH)))
5+
146
TMP_GOPATH ?= /tmp/thanos-go
15-
BIN_DIR ?= $(FIRST_GOPATH)/bin
7+
GOBIN ?= ${GOPATH}/bin
168
GO111MODULE ?= on
179
export GO111MODULE
1810

1911
# Tools.
20-
EMBEDMD ?= $(BIN_DIR)/embedmd-$(EMBEDMD_VERSION)
12+
EMBEDMD ?= $(GOBIN)/embedmd-$(EMBEDMD_VERSION)
2113
# v2.0.0
2214
EMBEDMD_VERSION ?= 97c13d6e41602fc6e397eb51c45f38069371a969
23-
ERRCHECK ?= $(BIN_DIR)/errcheck-$(ERRCHECK_VERSION)
15+
ERRCHECK ?= $(GOBIN)/errcheck-$(ERRCHECK_VERSION)
2416
# v1.2.0
2517
ERRCHECK_VERSION ?= e14f8d59a22d460d56c5ee92507cd94c78fbf274
26-
LICHE ?= $(BIN_DIR)/liche-$(LICHE_VERSION)
18+
LICHE ?= $(GOBIN)/liche-$(LICHE_VERSION)
2719
LICHE_VERSION ?= 2a2e6e56f6c615c17b2e116669c4cdb31b5453f3
28-
GOIMPORTS ?= $(BIN_DIR)/goimports-$(GOIMPORTS_VERSION)
20+
GOIMPORTS ?= $(GOBIN)/goimports-$(GOIMPORTS_VERSION)
2921
GOIMPORTS_VERSION ?= 1c3d964395ce8f04f3b03b30aaed0b096c08c3c6
30-
PROMU ?= $(BIN_DIR)/promu-$(PROMU_VERSION)
22+
PROMU ?= $(GOBIN)/promu-$(PROMU_VERSION)
3123
# v0.2.0
3224
PROMU_VERSION ?= 264dc36af9ea3103255063497636bd5713e3e9c1
33-
PROTOC ?= $(BIN_DIR)/protoc-$(PROTOC_VERSION)
25+
PROTOC ?= $(GOBIN)/protoc-$(PROTOC_VERSION)
3426
PROTOC_VERSION ?= 3.4.0
27+
# v0.54.0
28+
HUGO_VERSION ?= b1a82c61aba067952fdae2f73b826fe7d0f3fc2f
29+
HUGO ?= $(GOBIN)/hugo-$(HUGO_VERSION)
3530
GIT ?= $(shell which git)
3631
BZR ?= $(shell which bzr)
3732

33+
WEB_DIR ?= website
34+
PUBLIC_DIR ?= $(WEB_DIR)/public
35+
ME ?= $(shell whoami)
36+
3837
# E2e test deps.
3938
# Referenced by github.com/improbable-eng/thanos/blob/master/docs/getting_started.md#prometheus
4039

41-
# Limitied prom version, because testing was not possibe. This should fix it: https://github.com/improbable-eng/thanos/issues/758
40+
# Limitied prom version, because testing was not possible. This should fix it: https://github.com/improbable-eng/thanos/issues/758
4241
PROM_VERSIONS ?=v2.4.3 v2.5.0
4342
ALERTMANAGER_VERSION ?=v0.15.2
4443
MINIO_SERVER_VERSION ?=RELEASE.2018-10-06T00-15-16Z
4544

46-
# fetch_go_bin_version downloads (go gets) the binary from specific version and installs it in $(BIN_DIR)/<bin>-<version>
45+
# fetch_go_bin_version downloads (go gets) the binary from specific version and installs it in $(GOBIN)/<bin>-<version>
4746
# arguments:
4847
# $(1): Install path. (e.g github.com/campoy/embedmd)
4948
# $(2): Tag or revision for checkout.
49+
# TODO(bwplotka): Move to just using modules, however make sure to not use or edit Thanos go.mod file!
5050
define fetch_go_bin_version
51-
@mkdir -p $(BIN_DIR)
51+
@mkdir -p $(GOBIN)
52+
@mkdir -p $(TMP_GOPATH)
5253

5354
@echo ">> fetching $(1)@$(2) revision/version"
5455
@if [ ! -d '$(TMP_GOPATH)/src/$(1)' ]; then \
@@ -59,8 +60,27 @@ define fetch_go_bin_version
5960
@CDPATH='' cd -- '$(TMP_GOPATH)/src/$(1)' && git checkout -f -q '$(2)'
6061
@echo ">> installing $(1)@$(2)"
6162
@GOBIN='$(TMP_GOPATH)/bin' GOPATH='$(TMP_GOPATH)' GO111MODULE='off' go install '$(1)'
62-
@mv -- '$(TMP_GOPATH)/bin/$(shell basename $(1))' '$(BIN_DIR)/$(shell basename $(1))-$(2)'
63-
@echo ">> produced $(BIN_DIR)/$(shell basename $(1))-$(2)"
63+
@mv -- '$(TMP_GOPATH)/bin/$(shell basename $(1))' '$(GOBIN)/$(shell basename $(1))-$(2)'
64+
@echo ">> produced $(GOBIN)/$(shell basename $(1))-$(2)"
65+
66+
endef
67+
68+
define require_clean_work_tree
69+
@git update-index -q --ignore-submodules --refresh
70+
71+
@if ! git diff-files --quiet --ignore-submodules --; then \
72+
echo >&2 "cannot $1: you have unstaged changes."; \
73+
git diff-files --name-status -r --ignore-submodules -- >&2; \
74+
echo >&2 "Please commit or stash them."; \
75+
exit 1; \
76+
fi
77+
78+
@if ! git diff-index --cached --quiet HEAD --ignore-submodules --; then \
79+
echo >&2 "cannot $1: your index contains uncommitted changes."; \
80+
git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2; \
81+
echo >&2 "Please commit or stash them."; \
82+
exit 1; \
83+
fi
6484

6585
endef
6686

@@ -81,7 +101,7 @@ assets:
81101
# build builds Thanos binary using `promu`.
82102
.PHONY: build
83103
build: check-git check-bzr go-mod-tidy $(PROMU)
84-
@echo ">> building binaries"
104+
@echo ">> building binaries $(GOBIN)"
85105
@$(PROMU) build --prefix $(PREFIX)
86106

87107
# crossbuild builds all binaries for all platforms.
@@ -147,7 +167,7 @@ promu: $(PROMU)
147167
.PHONY: tarball
148168
tarball: $(PROMU)
149169
@echo ">> building release tarball"
150-
$(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR)
170+
$(PROMU) tarball --prefix $(PREFIX) $(GOBIN)
151171

152172
.PHONY: tarballs-release
153173
tarballs-release: $(PROMU)
@@ -203,6 +223,40 @@ else
203223
@echo >&2 "No bzr binary found."; exit 1
204224
endif
205225

226+
.PHONY: web-pre-process
227+
web-pre-process:
228+
@echo ">> running documentation website pre processing"
229+
@bash scripts/websitepreprocess.sh
230+
231+
.PHONY: web
232+
web: web-pre-process $(HUGO)
233+
@echo ">> building documentation website"
234+
# TODO(bwplotka): Make it --gc
235+
@cd $(WEB_DIR) && HUGO_ENV=production $(HUGO) --config hugo-generated.yaml --minify -v
236+
237+
.PHONY: web-serve
238+
web-serve: web-pre-process $(HUGO)
239+
@echo ">> serving documentation website"
240+
@cd $(WEB_DIR) && $(HUGO) --config hugo-generated.yaml -v server
241+
242+
.PHONY: web-deploy
243+
web-deploy:
244+
ifndef GOOGLE_ANALYTICS_TOKEN
245+
$(error GOOGLE_ANALYTICS_TOKEN is not set)
246+
endif
247+
# Requires git creds configured beforehand.
248+
$(call require_clean_work_tree,"deploy website")
249+
@rm -rf $(PUBLIC_DIR)
250+
@mkdir $(PUBLIC_DIR)
251+
@git worktree prune
252+
@rm -rf .git/worktrees/$(PUBLIC_DIR)/
253+
@git fetch origin
254+
@git worktree add -B gh-pages $(PUBLIC_DIR) origin/gh-pages
255+
@rm -rf $(PUBLIC_DIR)/*
256+
@make web
257+
@cd $(PUBLIC_DIR) && git add --all && git commit -m "Publishing to gh-pages as $(ME)" && cd ..
258+
@git push origin gh-pages
259+
206260
# non-phony targets
207261
$(EMBEDMD):
208262
$(call fetch_go_bin_version,github.com/campoy/embedmd,$(EMBEDMD_VERSION))
@@ -219,10 +273,13 @@ $(LICHE):
219273
$(PROMU):
220274
$(call fetch_go_bin_version,github.com/prometheus/promu,$(PROMU_VERSION))
221275

276+
$(HUGO):
277+
$(call fetch_go_bin_version,github.com/gohugoio/hugo,$(HUGO_VERSION))
278+
222279
$(PROTOC):
223280
@mkdir -p $(TMP_GOPATH)
224281
@echo ">> fetching protoc@${PROTOC_VERSION}"
225282
@PROTOC_VERSION="$(PROTOC_VERSION)" TMP_GOPATH="$(TMP_GOPATH)" scripts/installprotoc.sh
226283
@echo ">> installing protoc@${PROTOC_VERSION}"
227-
@mv -- "$(TMP_GOPATH)/bin/protoc" "$(BIN_DIR)/protoc-$(PROTOC_VERSION)"
228-
@echo ">> produced $(BIN_DIR)/protoc-$(PROTOC_VERSION)"
284+
@mv -- "$(TMP_GOPATH)/bin/protoc" "$(GOBIN)/protoc-$(PROTOC_VERSION)"
285+
@echo ">> produced $(GOBIN)/protoc-$(PROTOC_VERSION)"

docs/components/bucket.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1+
---
2+
title: Bucket
3+
type: docs
4+
menu: components
5+
---
6+
17
# Bucket
28

39
The bucket component of Thanos is a set of commands to inspect data in object storage buckets.
410
It is normally run as a stand alone command to aid with troubleshooting.
511

612
Example:
713

8-
```
14+
```bash
915
$ thanos bucket verify --objstore.config-file=bucket.yml
1016
```
1117

docs/components/compact.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1+
---
2+
title: Compact
3+
type: docs
4+
menu: components
5+
---
6+
17
# Compact
28

39
The compactor component of Thanos applies the compaction procedure of the Prometheus 2.0 storage engine to block data stored in object storage.
410
It is generally not semantically concurrency safe and must be deployed as a singleton against a bucket.
511

612
Example:
713

8-
```
14+
```bash
915
$ thanos compact --data-dir /tmp/thanos-compact --objstore.config-file=bucket.yml
1016
```
1117

docs/components/query.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1+
---
2+
title: Query
3+
type: docs
4+
menu: components
5+
---
6+
17
# Query
28

39
The query component implements the Prometheus HTTP v1 API to query data in a Thanos cluster via PromQL.
410

5-
It gathers the data needed to evaluate the query from underlying StoreAPIs. See [here](/docs/service_discovery.md)
11+
It gathers the data needed to evaluate the query from underlying StoreAPIs. See [here](../service-discovery.md)
612
on how to connect querier with desired StoreAPIs.
713

814
Querier currently is fully stateless and horizontally scalable.
915

10-
```
16+
```bash
1117
$ thanos query \
1218
--http-address "0.0.0.0:9090" \
1319
--store "<store-api>:<grpc-port>" \
14-
--store "<store-api2>:<grpc-port>" \
20+
--store "<store-api2>:<grpc-port>"
1521
```
1622

1723
## Deduplication

docs/components/rule.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
title: Rule
3+
type: docs
4+
menu: components
5+
---
6+
17
# Rule (aka Ruler)
28

39
_**NOTE:** It is recommended to ma deploying rules inside the relevant Prometheus servers locally. Use ruler only on specific cases. Read details[below](rule.md#Risk) why._
@@ -13,7 +19,7 @@ You can think of Rule as a simplified Prometheus that does not require a sidecar
1319
The data of each Rule node can be labeled to satisfy the clusters labeling scheme. High-availability pairs can be run in parallel and should be distinguished by the designated replica label, just like regular Prometheus servers.
1420
Read more about Ruler in HA in [here](rule.md#Ruler_HA)
1521

16-
```
22+
```bash
1723
$ thanos rule \
1824
--data-dir "/path/to/data" \
1925
--eval-interval "30s" \

docs/components/sidecar.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
title: Sidecar
3+
type: docs
4+
menu: components
5+
---
6+
17
# Sidecar
28

39
The sidecar component of Thanos gets deployed along with a Prometheus instance. It implements Thanos' Store API on top of Prometheus' remote-read API and advertises itself as a data source to the cluster. Thereby queriers in the cluster can treat Prometheus servers as yet another source of time series data without directly talking to its APIs.
@@ -13,14 +19,14 @@ Prometheus servers connected to the Thanos cluster via the sidecar are subject t
1319
The retention is recommended to not be lower than three times the block duration. This achieves resilience in the face of connectivity issues
1420
to the object storage since all local data will remain available within the Thanos cluster. If connectivity gets restored the backlog of blocks gets uploaded to the object storage.
1521

16-
```console
22+
```bash
1723
$ prometheus \
1824
--storage.tsdb.max-block-duration=2h \
1925
--storage.tsdb.min-block-duration=2h \
2026
--web.enable-lifecycle
2127
```
2228

23-
```console
29+
```bash
2430
$ thanos sidecar \
2531
--tsdb.path "/path/to/prometheus/data/dir" \
2632
--prometheus.url "http://localhost:9090" \

docs/components/store.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
---
2+
title: Store
3+
type: docs
4+
menu: components
5+
---
6+
17
# Store
28

39
The store component of Thanos implements the Store API on top of historical data in an object storage bucket. It acts primarily as an API gateway and therefore does not need significant amounts of local disk space. It joins a Thanos cluster on startup and advertises the data it can access.
410
It keeps a small amount of information about all remote blocks on local disk and keeps it in sync with the bucket. This data is generally safe to delete across restarts at the cost of increased startup times.
511

6-
```
12+
```bash
713
$ thanos store \
814
--data-dir "/local/state/data/dir" \
915
--cluster.peers "thanos-cluster.example.org" \

docs/troubleshooting/dev.md renamed to docs/contributing/dev.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# Troubleshooting for dev workflow
1+
---
2+
title: Troubleshooting for dev workflow
3+
type: doc
4+
menu: contributing
5+
---
26

37
## Dep `grouped write of manifest, lock and vendor: scratch directory ... already exists, please remove it`
48

0 commit comments

Comments
 (0)