Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate thanos-mixin from kube-thanos #1760

Merged
merged 23 commits into from
Dec 13, 2019
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/prometheus
/thanos
/vendor/
/mixin/vendor/

# Ignore minikube setup working dirs.
kube/bin
Expand All @@ -25,3 +26,4 @@ website/docs-pre-processed/
!website/data

tmp/bin
examples/tmp/
95 changes: 95 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ GOLANGCILINT ?= $(GOBIN)/golangci-lint-$(GOLANGCILINT_VERSION)
MISSPELL_VERSION ?= c0b55c8239520f6b5aa15a0207ca8b28027ba49e
MISSPELL ?= $(GOBIN)/misspell-$(MISSPELL_VERSION)

GOJSONTOYAML_VERSION ?= e8bd32d46b3d764bef60f12b3bada1c132c4be55
GOJSONTOYAML ?= $(GOBIN)/gojsontoyaml-$(GOJSONTOYAML_VERSION)
# v0.14.0
JSONNET_VERSION ?= fbde25be2182caa4345b03f1532450911ac7d1f3
JSONNET ?= $(GOBIN)/jsonnet-$(JSONNET_VERSION)
JSONNET_BUNDLER_VERSION ?= d7829f6c7e632e954c0e5db8b3eece8f111f9461
JSONNET_BUNDLER ?= $(GOBIN)/jb-$(JSONNET_BUNDLER_VERSION)
# Prometheus v2.14.0
PROMTOOL_VERSION ?= edeb7a44cbf745f1d8be4ea6f215e79e651bfe19
PROMTOOL ?= $(GOBIN)/promtool-$(PROMTOOL_VERSION)

MIXIN_ROOT ?= mixin/thanos
JSONNET_VENDOR_DIR ?= mixin/vendor

WEB_DIR ?= website
WEBSITE_BASE_URL ?= https://thanos.io
PUBLIC_DIR ?= $(WEB_DIR)/public
Expand Down Expand Up @@ -282,6 +296,75 @@ web-serve: web-pre-process $(HUGO)
@echo ">> serving documentation website"
@cd $(WEB_DIR) && $(HUGO) --config hugo.yaml -v server

JSONNET_CONTAINER_CMD:=docker run --rm \
-u="$(shell id -u):$(shell id -g)" \
-v "$(shell go env GOCACHE):/.cache/go-build" \
-v "$(PWD):/go/src/github.com/thanos-io/thanos:Z" \
-w "/go/src/github.com/thanos-io/thanos" \
-e USER=deadbeef \
-e GO111MODULE=on \
quay.io/coreos/jsonnet-ci

.PHONY: mixin-generate-in-container
mixin-generate-in-container:
kakkoyun marked this conversation as resolved.
Show resolved Hide resolved
@echo ">> Compiling and generating thanos-mixin"
$(JSONNET_CONTAINER_CMD) make $(MFLAGS) jsonnet-vendor
$(JSONNET_CONTAINER_CMD) make $(MFLAGS) jsonnet-format
$(JSONNET_CONTAINER_CMD) make $(MFLAGS) examples
kakkoyun marked this conversation as resolved.
Show resolved Hide resolved

.PHONY: examples
examples: examples/alerts/alerts.md examples/alerts/alerts.yaml examples/alerts/rules.yaml examples/dashboards examples/tmp
$(EMBEDMD) -w examples/alerts/alerts.md

.PHONY: examples/tmp
examples/tmp:
-rm -rf examples/tmp/
-mkdir -p examples/tmp/
$(JSONNET) -J ${JSONNET_VENDOR_DIR} -m examples/tmp/ ${MIXIN_ROOT}/separated_alerts.jsonnet | xargs -I{} sh -c 'cat {} | $(GOJSONTOYAML) > {}.yaml; rm -f {}' -- {}

.PHONY: examples/dashboards
kakkoyun marked this conversation as resolved.
Show resolved Hide resolved
examples/dashboards: $(JSONNET) ${MIXIN_ROOT}/mixin.libsonnet ${MIXIN_ROOT}/defaults.libsonnet ${MIXIN_ROOT}/dashboards/*
-rm -rf examples/dashboards/*.json
-mkdir -p examples/dashboards/
$(JSONNET) -J ${JSONNET_VENDOR_DIR} -m examples/dashboards ${MIXIN_ROOT}/dashboards.jsonnet

examples/alerts/alerts.yaml: $(JSONNET) $(GOJSONTOYAML) ${MIXIN_ROOT}/mixin.libsonnet ${MIXIN_ROOT}/defaults.libsonnet ${MIXIN_ROOT}/alerts/*
$(JSONNET) ${MIXIN_ROOT}/alerts.jsonnet | $(GOJSONTOYAML) > $@

examples/alerts/rules.yaml: $(JSONNET) $(GOJSONTOYAML) ${MIXIN_ROOT}/mixin.libsonnet ${MIXIN_ROOT}/defaults.libsonnet ${MIXIN_ROOT}/rules/*
$(JSONNET) ${MIXIN_ROOT}/rules.jsonnet | $(GOJSONTOYAML) > $@

.PHONY: jsonnet-vendor
jsonnet-vendor: $(JSONNET_BUNDLER) jsonnetfile.json jsonnetfile.lock.json
rm -rf ${JSONNET_VENDOR_DIR}
$(JSONNET_BUNDLER) install --jsonnetpkg-home="${JSONNET_VENDOR_DIR}"

JSONNET_FMT := jsonnetfmt -n 2 --max-blank-lines 2 --string-style s --comment-style s

.PHONY: jsonnet-format
kakkoyun marked this conversation as resolved.
Show resolved Hide resolved
jsonnet-format:
find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \
xargs -n 1 -- $(JSONNET_FMT) -i

.PHONY: jsonnet-format-in-container
jsonnet-format-in-container:
$(JSONNET_CONTAINER_CMD) make $(MFLAGS) jsonnet-format

.PHONY: rules-lint
rules-lint: $(PROMTOOL) examples/alerts/alerts.yaml examples/alerts/rules.yaml
$(PROMTOOL) check rules examples/alerts/alerts.yaml examples/alerts/rules.yaml

.PHONY: alerts-test
kakkoyun marked this conversation as resolved.
Show resolved Hide resolved
alerts-test: rules-lint
$(PROMTOOL) test rules examples/alerts/tests.yaml

.PHONY: examples-clean
examples-clean:
kakkoyun marked this conversation as resolved.
Show resolved Hide resolved
rm -f examples/alerts/alerts.yaml
rm -f examples/alerts/rules.yaml
rm -f examples/dashboards/*.json
rm -f examples/tmp/*.yaml

# non-phony targets
$(EMBEDMD):
$(call fetch_go_bin_version,github.com/campoy/embedmd,$(EMBEDMD_VERSION))
Expand Down Expand Up @@ -325,3 +408,15 @@ $(PROTOC):
@echo ">> installing protoc@${PROTOC_VERSION}"
@mv -- "$(TMP_GOPATH)/bin/protoc" "$(GOBIN)/protoc-$(PROTOC_VERSION)"
@echo ">> produced $(GOBIN)/protoc-$(PROTOC_VERSION)"

$(JSONNET):
$(call fetch_go_bin_version,github.com/google/go-jsonnet/cmd/jsonnet,$(JSONNET_VERSION))

$(GOJSONTOYAML):
$(call fetch_go_bin_version,github.com/brancz/gojsontoyaml,$(GOJSONTOYAML_VERSION))

$(JSONNET_BUNDLER):
$(call fetch_go_bin_version,github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb,$(JSONNET_BUNDLER_VERSION))

$(PROMTOOL):
$(call fetch_go_bin_version,github.com/prometheus/prometheus/cmd/promtool,$(PROMTOOL_VERSION))
14 changes: 7 additions & 7 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ slug: /getting-started.md

# Getting started

Thanos provides a global query view, high availability, data backup with historical, cheap data access as its core features in a single binary.
Thanos provides a global query view, high availability, data backup with historical, cheap data access as its core features in a single binary.

Those features can be deployed independently of each other. This allows you to have a subset of Thanos features ready
for immediate benefit or testing, while also making it flexible for gradual roll outs in more complex environments.
Those features can be deployed independently of each other. This allows you to have a subset of Thanos features ready
for immediate benefit or testing, while also making it flexible for gradual roll outs in more complex environments.

In this quick-start guide, we will explain:

Expand All @@ -33,7 +33,7 @@ Thanos aims for a simple deployment and maintenance model. The only dependencies

You can find the latest Thanos release [here](https://github.com/thanos-io/thanos/releases).

Master should be stable and usable. Every commit to master builds docker image named `master-<data>-<sha>` in
Master should be stable and usable. Every commit to master builds docker image named `master-<data>-<sha>` in
[quay.io/thanos/thanos](https://quay.io/repository/thanos/thanos) and [thanosio/thanos dockerhub (mirror)](https://hub.docker.com/r/thanosio/thanos)

We also perform minor releases every 6 weeks.
Expand All @@ -44,7 +44,7 @@ See [release process docs](release-process.md) for details.

## Building from source:

Thanos is built purely in [Golang](https://golang.org/), thus allowing to run Thanos on various x64 operating systems.
Thanos is built purely in [Golang](https://golang.org/), thus allowing to run Thanos on various x64 operating systems.

If you want to build Thanos from source you would need a working installation of the Go 1.12+ [toolchain](https://github.com/golang/tools) (`GOPATH`, `PATH=${GOPATH}/bin:${PATH}`).

Expand Down Expand Up @@ -91,8 +91,8 @@ If you want to add yourself to this list, let us know!

## Operating

See up to date [jsonnet mixins](https://github.com/thanos-io/kube-thanos/tree/master/jsonnet/thanos-mixin)
We also have example Grafana dashboards [here](/examples/grafana/monitoring.md) and some [alerts](/examples/alerts/alerts.md) to get you started.
See up to date [jsonnet mixins](https://github.com/thanos-io/thanos/tree/master/jsonnet/thanos-mixin)
We also have example Grafana dashboards [here](/examples/dashboards/dashboards.md) and some [alerts](/examples/alerts/alerts.md) to get you started.

## Talks

Expand Down
Loading