prometheus

Форк
0
/
Makefile 
173 строки · 5.8 Кб
1
# Copyright 2018 The Prometheus Authors
2
# Licensed under the Apache License, Version 2.0 (the "License");
3
# you may not use this file except in compliance with the License.
4
# You may obtain a copy of the License at
5
#
6
# http://www.apache.org/licenses/LICENSE-2.0
7
#
8
# Unless required by applicable law or agreed to in writing, software
9
# distributed under the License is distributed on an "AS IS" BASIS,
10
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
# See the License for the specific language governing permissions and
12
# limitations under the License.
13

14
# Needs to be defined before including Makefile.common to auto-generate targets
15
DOCKER_ARCHS ?= amd64 armv7 arm64 ppc64le s390x
16

17
UI_PATH = web/ui
18
UI_NODE_MODULES_PATH = $(UI_PATH)/node_modules
19
REACT_APP_NPM_LICENSES_TARBALL = "npm_licenses.tar.bz2"
20

21
PROMTOOL = ./promtool
22
TSDB_BENCHMARK_NUM_METRICS ?= 1000
23
TSDB_BENCHMARK_DATASET ?= ./tsdb/testdata/20kseries.json
24
TSDB_BENCHMARK_OUTPUT_DIR ?= ./benchout
25

26
GOLANGCI_LINT_OPTS ?= --timeout 4m
27
GOYACC_VERSION ?= v0.6.0
28

29
include Makefile.common
30

31
DOCKER_IMAGE_NAME       ?= prometheus
32

33
.PHONY: update-npm-deps
34
update-npm-deps:
35
	@echo ">> updating npm dependencies"
36
	./scripts/npm-deps.sh "minor"
37

38
.PHONY: upgrade-npm-deps
39
upgrade-npm-deps:
40
	@echo ">> upgrading npm dependencies"
41
	./scripts/npm-deps.sh "latest"
42

43
.PHONY: ui-bump-version
44
ui-bump-version:
45
	version=$$(sed s/2/0/ < VERSION) && ./scripts/ui_release.sh --bump-version "$${version}"
46
	cd web/ui && npm install
47
	git add "./web/ui/package-lock.json" "./**/package.json"
48

49
.PHONY: ui-install
50
ui-install:
51
	cd $(UI_PATH) && npm install
52

53
.PHONY: ui-build
54
ui-build:
55
	cd $(UI_PATH) && CI="" npm run build
56

57
.PHONY: ui-build-module
58
ui-build-module:
59
	cd $(UI_PATH) && npm run build:module
60

61
.PHONY: ui-test
62
ui-test:
63
	cd $(UI_PATH) && CI=true npm run test
64

65
.PHONY: ui-lint
66
ui-lint:
67
	cd $(UI_PATH) && npm run lint
68

69
.PHONY: assets
70
assets: ui-install ui-build
71

72
.PHONY: assets-compress
73
assets-compress: assets
74
	@echo '>> compressing assets'
75
	scripts/compress_assets.sh
76

77
.PHONY: assets-tarball
78
assets-tarball: assets
79
	@echo '>> packaging assets'
80
	scripts/package_assets.sh
81

82
.PHONY: parser
83
parser:
84
	@echo ">> running goyacc to generate the .go file."
85
ifeq (, $(shell command -v goyacc 2> /dev/null))
86
	@echo "goyacc not installed so skipping"
87
	@echo "To install: \"go install golang.org/x/tools/cmd/goyacc@$(GOYACC_VERSION)\" or run \"make install-goyacc\""
88
else
89
	$(MAKE) promql/parser/generated_parser.y.go
90
endif
91

92
promql/parser/generated_parser.y.go: promql/parser/generated_parser.y
93
	@echo ">> running goyacc to generate the .go file."
94
	@goyacc -l -o promql/parser/generated_parser.y.go promql/parser/generated_parser.y
95

96
.PHONY: clean-parser
97
clean-parser:
98
	@echo ">> cleaning generated parser"
99
	@rm -f promql/parser/generated_parser.y.go
100

101
.PHONY: check-generated-parser
102
check-generated-parser: clean-parser promql/parser/generated_parser.y.go
103
	@echo ">> checking generated parser"
104
	@git diff --exit-code -- promql/parser/generated_parser.y.go || (echo "Generated parser is out of date. Please run 'make parser' and commit the changes." && false)
105

106
.PHONY: install-goyacc
107
install-goyacc:
108
	@echo ">> installing goyacc $(GOYACC_VERSION)"
109
	@go install golang.org/x/tools/cmd/goyacc@$(GOYACC_VERSION)
110

111
.PHONY: test
112
# If we only want to only test go code we have to change the test target
113
# which is called by all.
114
ifeq ($(GO_ONLY),1)
115
test: common-test check-go-mod-version
116
else
117
test: check-generated-parser common-test ui-build-module ui-test ui-lint check-go-mod-version
118
endif
119

120
.PHONY: npm_licenses
121
npm_licenses: ui-install
122
	@echo ">> bundling npm licenses"
123
	rm -f $(REACT_APP_NPM_LICENSES_TARBALL) npm_licenses
124
	ln -s . npm_licenses
125
	find npm_licenses/$(UI_NODE_MODULES_PATH) -iname "license*" | tar cfj $(REACT_APP_NPM_LICENSES_TARBALL) --files-from=-
126
	rm -f npm_licenses
127

128
.PHONY: tarball
129
tarball: npm_licenses common-tarball
130

131
.PHONY: docker
132
docker: npm_licenses common-docker
133

134
plugins/plugins.go: plugins.yml plugins/generate.go
135
	@echo ">> creating plugins list"
136
	$(GO) generate -tags plugins ./plugins
137

138
.PHONY: plugins
139
plugins: plugins/plugins.go
140

141
.PHONY: build
142
build: assets npm_licenses assets-compress plugins common-build
143

144
.PHONY: bench_tsdb
145
bench_tsdb: $(PROMU)
146
	@echo ">> building promtool"
147
	@GO111MODULE=$(GO111MODULE) $(PROMU) build --prefix $(PREFIX) promtool
148
	@echo ">> running benchmark, writing result to $(TSDB_BENCHMARK_OUTPUT_DIR)"
149
	@$(PROMTOOL) tsdb bench write --metrics=$(TSDB_BENCHMARK_NUM_METRICS) --out=$(TSDB_BENCHMARK_OUTPUT_DIR) $(TSDB_BENCHMARK_DATASET)
150
	@$(GO) tool pprof -svg $(PROMTOOL) $(TSDB_BENCHMARK_OUTPUT_DIR)/cpu.prof > $(TSDB_BENCHMARK_OUTPUT_DIR)/cpuprof.svg
151
	@$(GO) tool pprof --inuse_space -svg $(PROMTOOL) $(TSDB_BENCHMARK_OUTPUT_DIR)/mem.prof > $(TSDB_BENCHMARK_OUTPUT_DIR)/memprof.inuse.svg
152
	@$(GO) tool pprof --alloc_space -svg $(PROMTOOL) $(TSDB_BENCHMARK_OUTPUT_DIR)/mem.prof > $(TSDB_BENCHMARK_OUTPUT_DIR)/memprof.alloc.svg
153
	@$(GO) tool pprof -svg $(PROMTOOL) $(TSDB_BENCHMARK_OUTPUT_DIR)/block.prof > $(TSDB_BENCHMARK_OUTPUT_DIR)/blockprof.svg
154
	@$(GO) tool pprof -svg $(PROMTOOL) $(TSDB_BENCHMARK_OUTPUT_DIR)/mutex.prof > $(TSDB_BENCHMARK_OUTPUT_DIR)/mutexprof.svg
155

156
.PHONY: cli-documentation
157
cli-documentation:
158
	$(GO) run ./cmd/prometheus/ --write-documentation > docs/command-line/prometheus.md
159
	$(GO) run ./cmd/promtool/ write-documentation > docs/command-line/promtool.md
160

161
.PHONY: check-go-mod-version
162
check-go-mod-version:
163
	@echo ">> checking go.mod version matching"
164
	@./scripts/check-go-mod-version.sh
165

166
.PHONY: update-all-go-deps
167
update-all-go-deps:
168
	@$(MAKE) update-go-deps
169
	@echo ">> updating Go dependencies in ./documentation/examples/remote_storage/"
170
	@cd ./documentation/examples/remote_storage/ && for m in $$($(GO) list -mod=readonly -m -f '{{ if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \
171
		$(GO) get -d $$m; \
172
	done
173
	@cd ./documentation/examples/remote_storage/ && $(GO) mod tidy
174

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.