├── .gitignore ├── LICENSE ├── Makefile ├── Makefile.common ├── README.md ├── cmd ├── metricstest │ └── app.go └── tiprometheus │ └── app.go ├── conf.toml.example ├── go.mod ├── go.sum └── pkg ├── adapter ├── reader.go └── writer.go ├── conf └── conf.go ├── lib ├── convert.go ├── error.go └── log.go ├── process └── init.go ├── simpleHTTP ├── controller.go └── server.go └── tikv └── tikv.go /.gitignore: -------------------------------------------------------------------------------- 1 | ### macOS template 2 | # General 3 | .DS_Store 4 | .AppleDouble 5 | .LSOverride 6 | 7 | # Icon must end with two \r 8 | Icon 9 | 10 | # Thumbnails 11 | ._* 12 | 13 | # Files that might appear in the root of a volume 14 | .DocumentRevisions-V100 15 | .fseventsd 16 | .Spotlight-V100 17 | .TemporaryItems 18 | .Trashes 19 | .VolumeIcon.icns 20 | .com.apple.timemachine.donotpresent 21 | 22 | # Directories potentially created on remote AFP share 23 | .AppleDB 24 | .AppleDesktop 25 | Network Trash Folder 26 | Temporary Items 27 | .apdisk 28 | ### Vim template 29 | # Swap 30 | [._]*.s[a-v][a-z] 31 | [._]*.sw[a-p] 32 | [._]s[a-v][a-z] 33 | [._]sw[a-p] 34 | 35 | # Session 36 | Session.vim 37 | 38 | # Temporary 39 | .netrwhist 40 | *~ 41 | # Auto-generated tag files 42 | tags 43 | # Persistent undo 44 | [._]*.un~ 45 | ### Go template 46 | # Binaries for programs and plugins 47 | *.exe 48 | *.exe~ 49 | *.dll 50 | *.so 51 | *.dylib 52 | 53 | # Test binary, build with `go test -c` 54 | *.test 55 | 56 | # Output of the go coverage tool, specifically when used with LiteIDE 57 | *.out 58 | ### JetBrains template 59 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 60 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 61 | 62 | # User-specific stuff 63 | .idea/**/workspace.xml 64 | .idea/**/tasks.xml 65 | .idea/**/dictionaries 66 | .idea/**/shelf 67 | 68 | # Sensitive or high-churn files 69 | .idea/**/dataSources/ 70 | .idea/**/dataSources.ids 71 | .idea/**/dataSources.local.xml 72 | .idea/**/sqlDataSources.xml 73 | .idea/**/dynamic.xml 74 | .idea/**/uiDesigner.xml 75 | .idea/**/dbnavigator.xml 76 | 77 | # Gradle 78 | .idea/**/gradle.xml 79 | .idea/**/libraries 80 | 81 | # CMake 82 | cmake-build-debug/ 83 | cmake-build-release/ 84 | 85 | # Mongo Explorer plugin 86 | .idea/**/mongoSettings.xml 87 | 88 | # File-based project format 89 | *.iws 90 | 91 | # IntelliJ 92 | out/ 93 | 94 | # mpeltonen/sbt-idea plugin 95 | .idea_modules/ 96 | 97 | # JIRA plugin 98 | atlassian-ide-plugin.xml 99 | 100 | # Cursive Clojure plugin 101 | .idea/replstate.xml 102 | 103 | # Crashlytics plugin (for Android Studio and IntelliJ) 104 | com_crashlytics_export_strings.xml 105 | crashlytics.properties 106 | crashlytics-build.properties 107 | fabric.properties 108 | 109 | # Editor-based Rest Client 110 | .idea/httpRequests 111 | 112 | # Config file 113 | /conf.toml 114 | 115 | # Built applications 116 | /app 117 | /tiprometheus 118 | /metricstest 119 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2021 The TiPrometheus 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 | include Makefile.common 15 | 16 | .PHONY: docker 17 | docker: npm_licenses common-docker 18 | 19 | .PHONY: build 20 | build: 21 | @echo ">> building binaries" 22 | $(GO) build -o tiprometheus cmd/tiprometheus/app.go 23 | 24 | 25 | .PHONY: bench_tsdb 26 | bench_tsdb: $(PROMU) 27 | @echo ">> building promtool" 28 | @GO111MODULE=$(GO111MODULE) $(PROMU) build --prefix $(PREFIX) promtool 29 | @echo ">> running benchmark, writing result to $(TSDB_BENCHMARK_OUTPUT_DIR)" 30 | @$(PROMTOOL) tsdb bench write --metrics=$(TSDB_BENCHMARK_NUM_METRICS) --out=$(TSDB_BENCHMARK_OUTPUT_DIR) $(TSDB_BENCHMARK_DATASET) 31 | @$(GO) tool pprof -svg $(PROMTOOL) $(TSDB_BENCHMARK_OUTPUT_DIR)/cpu.prof > $(TSDB_BENCHMARK_OUTPUT_DIR)/cpuprof.svg 32 | @$(GO) tool pprof --inuse_space -svg $(PROMTOOL) $(TSDB_BENCHMARK_OUTPUT_DIR)/mem.prof > $(TSDB_BENCHMARK_OUTPUT_DIR)/memprof.inuse.svg 33 | @$(GO) tool pprof --alloc_space -svg $(PROMTOOL) $(TSDB_BENCHMARK_OUTPUT_DIR)/mem.prof > $(TSDB_BENCHMARK_OUTPUT_DIR)/memprof.alloc.svg 34 | @$(GO) tool pprof -svg $(PROMTOOL) $(TSDB_BENCHMARK_OUTPUT_DIR)/block.prof > $(TSDB_BENCHMARK_OUTPUT_DIR)/blockprof.svg 35 | @$(GO) tool pprof -svg $(PROMTOOL) $(TSDB_BENCHMARK_OUTPUT_DIR)/mutex.prof > $(TSDB_BENCHMARK_OUTPUT_DIR)/mutexprof.svg 36 | -------------------------------------------------------------------------------- /Makefile.common: -------------------------------------------------------------------------------- 1 | # Copyright 2021 The TiPrometheus 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 | 15 | # Example usage : 16 | # Create the main Makefile in the root project directory. 17 | # include Makefile.common 18 | # customTarget: 19 | # @echo ">> Running customTarget" 20 | # 21 | 22 | # Ensure GOBIN is not set during build 23 | unexport GOBIN 24 | 25 | GO ?= go 26 | GOFMT ?= $(GO)fmt 27 | FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH))) 28 | GOOPTS ?= 29 | GOHOSTOS ?= $(shell $(GO) env GOHOSTOS) 30 | GOHOSTARCH ?= $(shell $(GO) env GOHOSTARCH) 31 | 32 | GO_VERSION ?= $(shell $(GO) version) 33 | GO_VERSION_NUMBER ?= $(word 3, $(GO_VERSION)) 34 | PRE_GO_111 ?= $(shell echo $(GO_VERSION_NUMBER) | grep -E 'go1\.(10|[0-9])\.') 35 | 36 | GOVENDOR := 37 | GO111MODULE := 38 | ifeq (, $(PRE_GO_111)) 39 | ifneq (,$(wildcard go.mod)) 40 | # Enforce Go modules support just in case the directory is inside GOPATH (and for Travis CI). 41 | GO111MODULE := on 42 | 43 | ifneq (,$(wildcard vendor)) 44 | # Always use the local vendor/ directory to satisfy the dependencies. 45 | GOOPTS := $(GOOPTS) -mod=vendor 46 | endif 47 | endif 48 | else 49 | ifneq (,$(wildcard go.mod)) 50 | ifneq (,$(wildcard vendor)) 51 | $(warning This repository requires Go >= 1.11 because of Go modules) 52 | $(warning Some recipes may not work as expected as the current Go runtime is '$(GO_VERSION_NUMBER)') 53 | endif 54 | else 55 | # This repository isn't using Go modules (yet). 56 | GOVENDOR := $(FIRST_GOPATH)/bin/govendor 57 | endif 58 | endif 59 | pkgs = ./... 60 | 61 | ifeq (arm, $(GOHOSTARCH)) 62 | GOHOSTARM ?= $(shell GOARM= $(GO) env GOARM) 63 | GO_BUILD_PLATFORM ?= $(GOHOSTOS)-$(GOHOSTARCH)v$(GOHOSTARM) 64 | else 65 | GO_BUILD_PLATFORM ?= $(GOHOSTOS)-$(GOHOSTARCH) 66 | endif 67 | 68 | GOTEST := $(GO) test 69 | GOTEST_DIR := 70 | ifneq ($(CIRCLE_JOB),) 71 | ifneq ($(shell which gotestsum),) 72 | GOTEST_DIR := test-results 73 | GOTEST := gotestsum --junitfile $(GOTEST_DIR)/unit-tests.xml -- 74 | endif 75 | endif 76 | 77 | GOLANGCI_LINT := 78 | GOLANGCI_LINT_OPTS ?= 79 | GOLANGCI_LINT_VERSION ?= v1.18.0 80 | # golangci-lint only supports linux, darwin and windows platforms on i386/amd64. 81 | # windows isn't included here because of the path separator being different. 82 | ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin)) 83 | ifeq ($(GOHOSTARCH),$(filter $(GOHOSTARCH),amd64 i386)) 84 | GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint 85 | endif 86 | endif 87 | 88 | PREFIX ?= $(shell pwd) 89 | BIN_DIR ?= $(shell pwd) 90 | DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD)) 91 | DOCKERFILE_PATH ?= ./Dockerfile 92 | DOCKERBUILD_CONTEXT ?= ./ 93 | DOCKER_REPO ?= ./bragfoo 94 | 95 | DOCKER_ARCHS ?= amd64 96 | 97 | BUILD_DOCKER_ARCHS = $(addprefix common-docker-,$(DOCKER_ARCHS)) 98 | PUBLISH_DOCKER_ARCHS = $(addprefix common-docker-publish-,$(DOCKER_ARCHS)) 99 | TAG_DOCKER_ARCHS = $(addprefix common-docker-tag-latest-,$(DOCKER_ARCHS)) 100 | 101 | ifeq ($(GOHOSTARCH),amd64) 102 | ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux freebsd darwin windows)) 103 | # Only supported on amd64 104 | test-flags := -race 105 | endif 106 | endif 107 | 108 | # This rule is used to forward a target like "build" to "common-build". This 109 | # allows a new "build" target to be defined in a Makefile which includes this 110 | # one and override "common-build" without override warnings. 111 | %: common-% ; 112 | 113 | .PHONY: common-all 114 | common-all: precheck style check_license lint unused build test 115 | 116 | .PHONY: common-style 117 | common-style: 118 | @echo ">> checking code style" 119 | @fmtRes=$$($(GOFMT) -d $$(find . -path ./vendor -prune -o -name '*.go' -print)); \ 120 | if [ -n "$${fmtRes}" ]; then \ 121 | echo "gofmt checking failed!"; echo "$${fmtRes}"; echo; \ 122 | echo "Please ensure you are using $$($(GO) version) for formatting code."; \ 123 | exit 1; \ 124 | fi 125 | 126 | .PHONY: common-check_license 127 | common-check_license: 128 | @echo ">> checking license header" 129 | @licRes=$$(for file in $$(find . -type f -iname '*.go' ! -path './vendor/*') ; do \ 130 | awk 'NR<=3' $$file | grep -Eq "(Copyright|generated|GENERATED)" || echo $$file; \ 131 | done); \ 132 | if [ -n "$${licRes}" ]; then \ 133 | echo "license header checking failed:"; echo "$${licRes}"; \ 134 | exit 1; \ 135 | fi 136 | 137 | .PHONY: common-deps 138 | common-deps: 139 | @echo ">> getting dependencies" 140 | ifdef GO111MODULE 141 | GO111MODULE=$(GO111MODULE) $(GO) mod download 142 | else 143 | $(GO) get $(GOOPTS) -t ./... 144 | endif 145 | 146 | .PHONY: update-go-deps 147 | update-go-deps: 148 | @echo ">> updating Go dependencies" 149 | @for m in $$($(GO) list -mod=readonly -m -f '{{ if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \ 150 | $(GO) get $$m; \ 151 | done 152 | GO111MODULE=$(GO111MODULE) $(GO) mod tidy 153 | ifneq (,$(wildcard vendor)) 154 | GO111MODULE=$(GO111MODULE) $(GO) mod vendor 155 | endif 156 | 157 | .PHONY: common-test-short 158 | common-test-short: $(GOTEST_DIR) 159 | @echo ">> running short tests" 160 | GO111MODULE=$(GO111MODULE) $(GOTEST) -short $(GOOPTS) $(pkgs) 161 | 162 | .PHONY: common-test 163 | common-test: $(GOTEST_DIR) 164 | @echo ">> running all tests" 165 | GO111MODULE=$(GO111MODULE) $(GOTEST) $(test-flags) $(GOOPTS) $(pkgs) 166 | 167 | $(GOTEST_DIR): 168 | @mkdir -p $@ 169 | 170 | .PHONY: common-format 171 | common-format: 172 | @echo ">> formatting code" 173 | GO111MODULE=$(GO111MODULE) $(GO) fmt $(pkgs) 174 | 175 | .PHONY: common-vet 176 | common-vet: 177 | @echo ">> vetting code" 178 | GO111MODULE=$(GO111MODULE) $(GO) vet $(GOOPTS) $(pkgs) 179 | 180 | .PHONY: common-lint 181 | common-lint: $(GOLANGCI_LINT) 182 | ifdef GOLANGCI_LINT 183 | @echo ">> running golangci-lint" 184 | ifdef GO111MODULE 185 | # 'go list' needs to be executed before staticcheck to prepopulate the modules cache. 186 | # Otherwise staticcheck might fail randomly for some reason not yet explained. 187 | GO111MODULE=$(GO111MODULE) $(GO) list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null 188 | GO111MODULE=$(GO111MODULE) $(GOLANGCI_LINT) run $(GOLANGCI_LINT_OPTS) $(pkgs) 189 | else 190 | $(GOLANGCI_LINT) run $(pkgs) 191 | endif 192 | endif 193 | 194 | # For backward-compatibility. 195 | .PHONY: common-staticcheck 196 | common-staticcheck: lint 197 | 198 | .PHONY: common-unused 199 | common-unused: $(GOVENDOR) 200 | ifdef GOVENDOR 201 | @echo ">> running check for unused packages" 202 | @$(GOVENDOR) list +unused | grep . && exit 1 || echo 'No unused packages' 203 | else 204 | ifdef GO111MODULE 205 | @echo ">> running check for unused/missing packages in go.mod" 206 | GO111MODULE=$(GO111MODULE) $(GO) mod tidy 207 | ifeq (,$(wildcard vendor)) 208 | @git diff --exit-code -- go.sum go.mod 209 | else 210 | @echo ">> running check for unused packages in vendor/" 211 | GO111MODULE=$(GO111MODULE) $(GO) mod vendor 212 | @git diff --exit-code -- go.sum go.mod vendor/ 213 | endif 214 | endif 215 | endif 216 | 217 | .PHONY: common-docker $(BUILD_DOCKER_ARCHS) 218 | common-docker: $(BUILD_DOCKER_ARCHS) 219 | $(BUILD_DOCKER_ARCHS): common-docker-%: 220 | docker build -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" \ 221 | -f $(DOCKERFILE_PATH) \ 222 | --build-arg ARCH="$*" \ 223 | --build-arg OS="linux" \ 224 | $(DOCKERBUILD_CONTEXT) 225 | 226 | .PHONY: common-docker-publish $(PUBLISH_DOCKER_ARCHS) 227 | common-docker-publish: $(PUBLISH_DOCKER_ARCHS) 228 | $(PUBLISH_DOCKER_ARCHS): common-docker-publish-%: 229 | docker push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" 230 | 231 | DOCKER_MAJOR_VERSION_TAG = $(firstword $(subst ., ,$(shell cat VERSION))) 232 | .PHONY: common-docker-tag-latest $(TAG_DOCKER_ARCHS) 233 | common-docker-tag-latest: $(TAG_DOCKER_ARCHS) 234 | $(TAG_DOCKER_ARCHS): common-docker-tag-latest-%: 235 | docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:latest" 236 | docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:v$(DOCKER_MAJOR_VERSION_TAG)" 237 | 238 | .PHONY: common-docker-manifest 239 | common-docker-manifest: 240 | DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create -a "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" $(foreach ARCH,$(DOCKER_ARCHS),$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$(ARCH):$(DOCKER_IMAGE_TAG)) 241 | DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" 242 | 243 | .PHONY: proto 244 | proto: 245 | @echo ">> generating code from proto files" 246 | @./scripts/genproto.sh 247 | 248 | ifdef GOLANGCI_LINT 249 | $(GOLANGCI_LINT): 250 | mkdir -p $(FIRST_GOPATH)/bin 251 | curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/$(GOLANGCI_LINT_VERSION)/install.sh \ 252 | | sed -e '/install -d/d' \ 253 | | sh -s -- -b $(FIRST_GOPATH)/bin $(GOLANGCI_LINT_VERSION) 254 | endif 255 | 256 | ifdef GOVENDOR 257 | .PHONY: $(GOVENDOR) 258 | $(GOVENDOR): 259 | GOOS= GOARCH= $(GO) get -u github.com/kardianos/govendor 260 | endif 261 | 262 | .PHONY: precheck 263 | precheck:: 264 | 265 | define PRECHECK_COMMAND_template = 266 | precheck:: $(1)_precheck 267 | 268 | PRECHECK_COMMAND_$(1) ?= $(1) $$(strip $$(PRECHECK_OPTIONS_$(1))) 269 | .PHONY: $(1)_precheck 270 | $(1)_precheck: 271 | @if ! $$(PRECHECK_COMMAND_$(1)) 1>/dev/null 2>&1; then \ 272 | echo "Execution of '$$(PRECHECK_COMMAND_$(1))' command failed. Is $(1) installed?"; \ 273 | exit 1; \ 274 | fi 275 | endef 276 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TiPrometheus 2 | 3 | A adapter/gateway for [TiKV](https://github.com/tikv/tikv). 4 | 5 | Supports remote write and read. 6 | 7 | Transport security is optional and can be enabled both between 8 | Prometheus and the adapter and for communication with the 9 | TiKV cluster. 10 | 11 | ## Quick Start 12 | 13 | Build: 14 | ``` 15 | go build -o tiprometheus cmd/tiprometheus/app.go 16 | ``` 17 | 18 | Rename the example configuration `conf.example.toml` to 19 | `conf.toml` and adapt the parameters to your needs. 20 | 21 | Run with: 22 | ``` 23 | ./tiprometheus -conf conf.toml 24 | ``` 25 | 26 | ## Configuration 27 | 28 | TiPrometheus is configured through a TOML file. 29 | See `conf.example.toml` for an example. 30 | 31 | ### Options 32 | 33 | * **PDHost** 34 | The PD cluster host to connect to. 35 | TiPrometheus does not connect directly to the TiKV cluster, 36 | but uses the PD cluster to obtain a node address. 37 | * **TimeInterval** 38 | (Unknown) 39 | * **AdapterListen** 40 | Which IP address and port the adapter should listen on, 41 | separated by `:`. 42 | To listen on 0.0.0.0, only write `:` followed by the port. 43 | * **AdapterEnableTLS** 44 | If true, TLS will be enabled on the Prometheus connection. 45 | AdapterServerCertificate and AdapterServerKey must 46 | be specified as well. 47 | * **AdapterCACertificate** 48 | The CA certificate used to validate connections from Prometheus. 49 | If not specified, all clients can connect without authentication. 50 | * **AdapterServerCertificate** 51 | The server certificate to use for the listener. 52 | * **AdapterServerKey** 53 | The key for AdapterServerCertificate 54 | * **TiKVEnableTLS** 55 | If true, TLS will be enabled on the PD/TiKV connection. 56 | TiKVCACertificate, TiKVClientCertificate and TiKVClientKey 57 | must be specified as well. 58 | * **TiKVCACertificate** 59 | The CA certificate used to validate the server certificate 60 | sent by PD/TiKV. 61 | * **TiKVClientCertificate** 62 | The client certificate to use for authentication on PD/TiKV. 63 | * **TiKVClientKey** 64 | The key for TiKVClientCertificate. 65 | 66 | ### Sections 67 | 68 | The configuration file can contain multiple sections to 69 | allow quick switching between development/production 70 | environments. 71 | 72 | Set the environment variable `RunTime` to the section 73 | you would like to enable: 74 | 75 | Run with: 76 | ``` 77 | RunTime=dev ./tiprometheus -conf conf.toml 78 | ``` 79 | 80 | -------------------------------------------------------------------------------- /cmd/metricstest/app.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The TiPrometheus 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 | package main 15 | 16 | import ( 17 | "log" 18 | "math" 19 | "math/rand" 20 | "net/http" 21 | "time" 22 | 23 | "github.com/prometheus/client_golang/prometheus" 24 | "github.com/prometheus/client_golang/prometheus/promauto" 25 | "github.com/prometheus/client_golang/prometheus/promhttp" 26 | ) 27 | 28 | var customLabels = []string{"app", "downstream"} 29 | 30 | //var customLabels []string 31 | 32 | var connections = promauto.NewGaugeVec(prometheus.GaugeOpts{ 33 | Name: "latency", 34 | Help: "caculate connections by state", 35 | }, customLabels) 36 | 37 | func decimal(value float64) float64 { 38 | return math.Trunc(value*1e2+0.5) * 1e-2 39 | } 40 | 41 | func recordMetrics() { 42 | 43 | go func() { 44 | for { 45 | tikvValue := decimal(float64(rand.Intn(10))) 46 | connections.WithLabelValues("tidb", "tikv").Set(tikvValue) 47 | time.Sleep(2 * time.Second) 48 | } 49 | }() 50 | 51 | go func() { 52 | for { 53 | boltdbValue := decimal(float64(rand.Intn(10))) 54 | connections.WithLabelValues("tidb", "boltdb").Set(boltdbValue) 55 | time.Sleep(2 * time.Second) 56 | } 57 | }() 58 | } 59 | 60 | func main() { 61 | recordMetrics() 62 | http.Handle("/metrics", promhttp.Handler()) 63 | err := http.ListenAndServe(":2330", nil) 64 | log.Fatal(err) 65 | } 66 | -------------------------------------------------------------------------------- /cmd/tiprometheus/app.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The TiPrometheus 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 | package main 15 | 16 | import ( 17 | "flag" 18 | "os" 19 | 20 | "github.com/bragfoo/TiPrometheus/pkg/conf" 21 | "github.com/bragfoo/TiPrometheus/pkg/process" 22 | "github.com/bragfoo/TiPrometheus/pkg/simpleHTTP" 23 | ) 24 | 25 | // RunTime=dev go run app.go -conf "./conf.toml" 26 | 27 | var confPath = flag.String("conf", "./conf.toml", "The configuration file name.") 28 | 29 | func main() { 30 | flag.Parse() 31 | // init 32 | process.Init(os.Getenv("RunTime"), *confPath) 33 | if conf.RunTimeInfo.AdapterEnableTLS { 34 | // start https server 35 | simpleHTTP.ServerTLS(conf.RunTimeInfo.AdapterListen, conf.RunTimeInfo.AdapterCACertificate, conf.RunTimeInfo.AdapterServerCertificate, conf.RunTimeInfo.AdapterServerKey) 36 | } else { 37 | // start http server 38 | simpleHTTP.Server(conf.RunTimeInfo.AdapterListen) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /conf.toml.example: -------------------------------------------------------------------------------- 1 | [dev] 2 | AdapterListen = "127.0.0.1:12350" 3 | PDHost = "ip:port" 4 | TimeInterval = 5 5 | AdapterEnableTLS = false 6 | TiKVEnableTLS = false 7 | 8 | [default] 9 | AdapterListen = ":12350" 10 | PDHost = "ip:port" 11 | TimeInterval = 5 12 | AdapterEnableTLS = true 13 | AdapterCACertificate = "/path/to/certs/ca.pem" 14 | AdapterServerCertificate = "/path/to/certs/adapter.pem" 15 | AdapterServerKey = "/path/to/certs/adapter.key" 16 | TiKVEnableTLS = true 17 | TiKVCACertificate = "/path/to/certs/ca.pem" 18 | TiKVClientCertificate = "/path/to/certs/client.pem" 19 | TiKVClientKey = "/path/to/certs/client.key" 20 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/bragfoo/TiPrometheus 2 | 3 | require ( 4 | github.com/BurntSushi/toml v0.3.1 5 | github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142 // indirect 6 | github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect 7 | github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548 // indirect 8 | github.com/gogo/protobuf v1.3.2 9 | github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db 10 | github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c // indirect 11 | github.com/gorilla/mux v1.6.1 // indirect 12 | github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20181112102510-3304cc886352 // indirect 13 | github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20181025070259-68e3a13e4117 // indirect 14 | github.com/onsi/gomega v1.4.2 // indirect 15 | github.com/pingcap/goleveldb v0.0.0-20171020122428-b9ff6c35079e // indirect 16 | github.com/pingcap/kvproto v0.0.0-20181219114958-faa87b5884ca // indirect 17 | github.com/pingcap/parser v0.0.0-20181221122143-651ad7108326 // indirect 18 | github.com/pingcap/tidb v0.0.0-20181221093914-1e06ccc019b8 19 | github.com/pingcap/tidb-tools v2.1.2+incompatible // indirect 20 | github.com/pingcap/tipb v0.0.0-20181126132056-a7fd2aaa9719 // indirect 21 | github.com/prometheus/client_golang v1.11.1 22 | github.com/prometheus/prometheus v2.5.0+incompatible 23 | github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446 // indirect 24 | github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 // indirect 25 | github.com/twinj/uuid v0.1.0 // indirect 26 | github.com/uber/jaeger-lib v1.5.0 // indirect 27 | go.uber.org/zap v1.9.1 28 | google.golang.org/genproto v0.0.0-20181221175505-bd9b4fb69e2f // indirect 29 | gopkg.in/natefinch/lumberjack.v2 v2.0.0-20170531160350-a96e63847dc3 // indirect 30 | ) 31 | 32 | go 1.13 33 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 2 | cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 3 | github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= 4 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 5 | github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= 6 | github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= 7 | github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= 8 | github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= 9 | github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= 10 | github.com/apache/thrift v0.0.0-20161221203622-b2a4d4ae21c7 h1:Fv9bK1Q+ly/ROk4aJsVMeuIwPel4bEnD8EPiI91nZMg= 11 | github.com/apache/thrift v0.0.0-20161221203622-b2a4d4ae21c7/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= 12 | github.com/beorn7/perks v0.0.0-20160229213445-3ac7bf7a47d1/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= 13 | github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= 14 | github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= 15 | github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= 16 | github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= 17 | github.com/blacktear23/go-proxyprotocol v0.0.0-20171102103907-62e368e1c470/go.mod h1:VKt7CNAQxpFpSDz3sXyj9hY/GbVsQCr0sB3w59nE7lU= 18 | github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= 19 | github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= 20 | github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= 21 | github.com/cockroachdb/cmux v0.0.0-20170110192607-30d10be49292 h1:dzj1/xcivGjNPwwifh/dWTczkwcuqsXXFHY1X/TZMtw= 22 | github.com/cockroachdb/cmux v0.0.0-20170110192607-30d10be49292/go.mod h1:qRiX68mZX1lGBkTWyp3CLcenw9I94W2dLeRvMzcn9N4= 23 | github.com/codahale/hdrhistogram v0.0.0-20160425231609-f8ad88b59a58 h1:hHWif/4GirK3P5uvCyyj941XSVIQDzuJhbEguCICdPE= 24 | github.com/codahale/hdrhistogram v0.0.0-20160425231609-f8ad88b59a58/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= 25 | github.com/coreos/bbolt v1.3.1-coreos.6 h1:uTXKg9gY70s9jMAKdfljFQcuh4e/BXOM+V+d00KFj3A= 26 | github.com/coreos/bbolt v1.3.1-coreos.6/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= 27 | github.com/coreos/etcd v3.2.18+incompatible h1:E8oIF72eom0bDAB74G/H31rAe1JVoiLE5NMn+WUCNLc= 28 | github.com/coreos/etcd v3.2.18+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= 29 | github.com/coreos/go-semver v0.2.0 h1:3Jm3tLmsgAYcjC+4Up7hJrFBPr+n7rAqYeSw/SZazuY= 30 | github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= 31 | github.com/coreos/go-systemd v0.0.0-20180202092358-40e2722dffea/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= 32 | github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142 h1:3jFq2xL4ZajGK4aZY8jz+DAF0FHjI51BXjjSwCzS1Dk= 33 | github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= 34 | github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= 35 | github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg= 36 | github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= 37 | github.com/cznic/mathutil v0.0.0-20160613104831-78ad7f262603/go.mod h1:e6NPNENfs9mPDVNRekM7lKScauxd5kXTr1Mfyig6TDM= 38 | github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548 h1:iwZdTE0PVqJCos1vaoKsclOGD3ADKpshg3SRtYBbwso= 39 | github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548/go.mod h1:e6NPNENfs9mPDVNRekM7lKScauxd5kXTr1Mfyig6TDM= 40 | github.com/cznic/sortutil v0.0.0-20150617083342-4c7342852e65 h1:hxuZop6tSoOi0sxFzoGGYdRqNrPubyaIf9KoBG9tPiE= 41 | github.com/cznic/sortutil v0.0.0-20150617083342-4c7342852e65/go.mod h1:q2w6Bg5jeox1B+QkJ6Wp/+Vn0G/bo3f1uY7Fn3vivIQ= 42 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 43 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 44 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 45 | github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= 46 | github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= 47 | github.com/dustin/go-humanize v0.0.0-20180421182945-02af3965c54e h1:Fw7ZmgiklsLh5EQWyHh1sumKSCG1+yjEctIpGKib87s= 48 | github.com/dustin/go-humanize v0.0.0-20180421182945-02af3965c54e/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= 49 | github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385 h1:clC1lXBpe2kTj2VHdaIu9ajZQe4kcEY9j0NsnDDBZ3o= 50 | github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= 51 | github.com/etcd-io/gofail v0.0.0-20180808172546-51ce9a71510a h1:QNEenQIsGDEEfFNSnN+h6hE1OwnHqTg7Dl9gEk1Cko4= 52 | github.com/etcd-io/gofail v0.0.0-20180808172546-51ce9a71510a/go.mod h1:49H/RkXP8pKaZy4h0d+NW16rSLhyVBt4o6VLJbmOqDE= 53 | github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= 54 | github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= 55 | github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= 56 | github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= 57 | github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= 58 | github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= 59 | github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= 60 | github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= 61 | github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= 62 | github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= 63 | github.com/go-sql-driver/mysql v0.0.0-20170715192408-3955978caca4/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= 64 | github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= 65 | github.com/gogo/protobuf v0.0.0-20180717141946-636bf0302bc9/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 66 | github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 67 | github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= 68 | github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= 69 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= 70 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= 71 | github.com/golang/groupcache v0.0.0-20181024230925-c65c006176ff h1:kOkM9whyQYodu09SJ6W3NCsHG7crFaJILQ22Gozp3lg= 72 | github.com/golang/groupcache v0.0.0-20181024230925-c65c006176ff/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 73 | github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= 74 | github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 75 | github.com/golang/protobuf v0.0.0-20180814211427-aa810b61a9c7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 76 | github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 77 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 78 | github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 79 | github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 80 | github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= 81 | github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= 82 | github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= 83 | github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= 84 | github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= 85 | github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= 86 | github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= 87 | github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= 88 | github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w= 89 | github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= 90 | github.com/google/btree v0.0.0-20161217183710-316fb6d3f031/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 91 | github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c h1:964Od4U6p2jUkFxvCydnIczKteheJEzHRToSGK3Bnlw= 92 | github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 93 | github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 94 | github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 95 | github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 96 | github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 97 | github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= 98 | github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 99 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 100 | github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f h1:9oNbS1z4rVpbnkHBdPZU4jo9bSmrLpII768arSyMFgk= 101 | github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= 102 | github.com/gorilla/mux v0.0.0-20170228224354-599cba5e7b61/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= 103 | github.com/gorilla/mux v1.6.1 h1:KOwqsTYZdeuMacU7CxjMNYEKeBvLbxW+psodrbcEa3A= 104 | github.com/gorilla/mux v1.6.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= 105 | github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20171020063731-82921fcf811d/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= 106 | github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20181112102510-3304cc886352 h1:It3yM2rJ7J4m16qXyELbYZMvzwFdiogmdlBrFuZjmFQ= 107 | github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20181112102510-3304cc886352/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= 108 | github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20160910222444-6b7015e65d36/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= 109 | github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20181025070259-68e3a13e4117 h1:v9uUYPE4RHQHA0C9XfpAX9uzWQvgIDYjPh6m/mQgrzs= 110 | github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20181025070259-68e3a13e4117/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= 111 | github.com/grpc-ecosystem/grpc-gateway v1.4.1 h1:pX7cnDwSSmG0dR9yNjCQSSpmsJOqFdT7SzVp5Yl9uVw= 112 | github.com/grpc-ecosystem/grpc-gateway v1.4.1/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= 113 | github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= 114 | github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= 115 | github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo= 116 | github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= 117 | github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= 118 | github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= 119 | github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= 120 | github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= 121 | github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= 122 | github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= 123 | github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= 124 | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= 125 | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 126 | github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8= 127 | github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 128 | github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= 129 | github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= 130 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 131 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 132 | github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= 133 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 134 | github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= 135 | github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= 136 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 137 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 138 | github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 139 | github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 140 | github.com/montanaflynn/stats v0.0.0-20151014174947-eeaced052adb h1:bsjNADsjHq0gjU7KO7zwoX5k3HtFdf6TDzB3ncl5iUs= 141 | github.com/montanaflynn/stats v0.0.0-20151014174947-eeaced052adb/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= 142 | github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= 143 | github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= 144 | github.com/ngaut/pools v0.0.0-20180318154953-b7bc8c42aac7 h1:7KAv7KMGTTqSmYZtNdcNTgsos+vFzULLwyElndwn+5c= 145 | github.com/ngaut/pools v0.0.0-20180318154953-b7bc8c42aac7/go.mod h1:iWMfgwqYW+e8n5lC/jjNEhwcjbRDpl5NT7n2h+4UNcI= 146 | github.com/ngaut/sync2 v0.0.0-20141008032647-7a24ed77b2ef h1:K0Fn+DoFqNqktdZtdV3bPQ/0cuYh2H4rkg0tytX/07k= 147 | github.com/ngaut/sync2 v0.0.0-20141008032647-7a24ed77b2ef/go.mod h1:7WjlapSfwQyo6LNmIvEWzsW1hbBQfpUO4JWnuQRmva8= 148 | github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 149 | github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= 150 | github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 151 | github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= 152 | github.com/onsi/gomega v1.4.2 h1:3mYCb7aPxS/RU7TI1y4rkEn1oKmPRjNJLNEXgw7MH2I= 153 | github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= 154 | github.com/opentracing/basictracer-go v1.0.0 h1:YyUAhaEfjoWXclZVJ9sGoNct7j4TVk7lZWlQw5UXuoo= 155 | github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= 156 | github.com/opentracing/opentracing-go v1.0.2 h1:3jA2P6O1F9UOrWVpwrIo17pu01KWvNWg4X946/Y5Zwg= 157 | github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= 158 | github.com/pingcap/check v0.0.0-20171206051426-1c287c953996 h1:ZBdiJCMan6GSo/aPAM7gywcUKa0z58gczVrnG6TQnAQ= 159 | github.com/pingcap/check v0.0.0-20171206051426-1c287c953996/go.mod h1:B1+S9LNcuMyLH/4HMTViQOJevkGiik3wW2AN9zb2fNQ= 160 | github.com/pingcap/errors v0.11.0 h1:DCJQB8jrHbQ1VVlMFIrbj2ApScNNotVmkSNplu2yUt4= 161 | github.com/pingcap/errors v0.11.0/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= 162 | github.com/pingcap/gofail v0.0.0-20181217135706-6a951c1e42c3 h1:04yuCf5NMvLU8rB2m4Qs3rynH7EYpMno3lHkewIOdMo= 163 | github.com/pingcap/gofail v0.0.0-20181217135706-6a951c1e42c3/go.mod h1:DazNTg0PTldtpsQiT9I5tVJwV1onHMKBBgXzmJUlMns= 164 | github.com/pingcap/goleveldb v0.0.0-20171020084629-8d44bfdf1030/go.mod h1:O17XtbryoCJhkKGbT62+L2OlrniwqiGLSqrmdHCMzZw= 165 | github.com/pingcap/goleveldb v0.0.0-20171020122428-b9ff6c35079e h1:P73/4dPCL96rGrobssy1nVy2VaVpNCuLpCbr+FEaTA8= 166 | github.com/pingcap/goleveldb v0.0.0-20171020122428-b9ff6c35079e/go.mod h1:O17XtbryoCJhkKGbT62+L2OlrniwqiGLSqrmdHCMzZw= 167 | github.com/pingcap/kvproto v0.0.0-20181109035735-8e3f33ac4929/go.mod h1:0gwbe1F2iBIjuQ9AH0DbQhL+Dpr5GofU8fgYyXk+ykk= 168 | github.com/pingcap/kvproto v0.0.0-20181219114958-faa87b5884ca h1:2bDKtqDtOjAWPl5+3VceBmWe8WPPOUnfaCiun97YDIQ= 169 | github.com/pingcap/kvproto v0.0.0-20181219114958-faa87b5884ca/go.mod h1:vaHRAMINJGaWG44vstD9eGT+JdUQVlRIKIK1qpUEMtU= 170 | github.com/pingcap/parser v0.0.0-20181207085916-6c21d4344dfa/go.mod h1:1FNvfp9+J0wvc4kl8eGNh7Rqrxveg15jJoWo/a0uHwA= 171 | github.com/pingcap/parser v0.0.0-20181221122143-651ad7108326 h1:CG/QuNYWKiTC/YOXMIXrlw52YZ4ZPgP4gnCdWUqTRus= 172 | github.com/pingcap/parser v0.0.0-20181221122143-651ad7108326/go.mod h1:1FNvfp9+J0wvc4kl8eGNh7Rqrxveg15jJoWo/a0uHwA= 173 | github.com/pingcap/pd v2.1.0-rc.4+incompatible h1:/buwGk04aHO5odk/+O8ZOXGs4qkUjYTJ2UpCJXna8NE= 174 | github.com/pingcap/pd v2.1.0-rc.4+incompatible/go.mod h1:nD3+EoYes4+aNNODO99ES59V83MZSI+dFbhyr667a0E= 175 | github.com/pingcap/tidb v0.0.0-20181221093914-1e06ccc019b8 h1:8fFJ7oQqtcoRXEPa6Wft7wToGWpNn5PWvGg1HRAp9KI= 176 | github.com/pingcap/tidb v0.0.0-20181221093914-1e06ccc019b8/go.mod h1:4lptEFNZFNrbHEYSu7N7SX9BIrzhX08vX174x7I0J7g= 177 | github.com/pingcap/tidb-tools v2.1.1-0.20181218072513-b2235d442b06+incompatible/go.mod h1:XGdcy9+yqlDSEMTpOXnwf3hiTeqrV6MN/u1se9N8yIM= 178 | github.com/pingcap/tidb-tools v2.1.2+incompatible h1:vWDgZRG1k6DyEeHkd0oADHjhP3jbuq1wMXf4EmphzZM= 179 | github.com/pingcap/tidb-tools v2.1.2+incompatible/go.mod h1:XGdcy9+yqlDSEMTpOXnwf3hiTeqrV6MN/u1se9N8yIM= 180 | github.com/pingcap/tipb v0.0.0-20170310053819-1043caee48da/go.mod h1:RtkHW8WbcNxj8lsbzjaILci01CtYnYbIkQhjyZWrWVI= 181 | github.com/pingcap/tipb v0.0.0-20180910045846-371b48b15d93/go.mod h1:RtkHW8WbcNxj8lsbzjaILci01CtYnYbIkQhjyZWrWVI= 182 | github.com/pingcap/tipb v0.0.0-20181126132056-a7fd2aaa9719 h1:MEHhwNcWuuoJJvYxMaWIXFp+BvK/WORPiiwmSOS0cA4= 183 | github.com/pingcap/tipb v0.0.0-20181126132056-a7fd2aaa9719/go.mod h1:RtkHW8WbcNxj8lsbzjaILci01CtYnYbIkQhjyZWrWVI= 184 | github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 185 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 186 | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= 187 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 188 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 189 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 190 | github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= 191 | github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= 192 | github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= 193 | github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= 194 | github.com/prometheus/client_golang v1.11.1 h1:+4eQaD7vAZ6DsfsxB15hbE0odUjGI5ARs9yskGu1v4s= 195 | github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= 196 | github.com/prometheus/client_model v0.0.0-20171117100541-99fa1f4be8e5/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= 197 | github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= 198 | github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 199 | github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= 200 | github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 201 | github.com/prometheus/common v0.0.0-20180426121432-d811d2e9bf89/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= 202 | github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= 203 | github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= 204 | github.com/prometheus/common v0.26.0 h1:iMAkS2TDoNWnKM+Kopnx/8tnEStIfpYA0ur0xQzzhMQ= 205 | github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= 206 | github.com/prometheus/procfs v0.0.0-20180408092902-8b1c2da0d56d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= 207 | github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= 208 | github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= 209 | github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= 210 | github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4= 211 | github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= 212 | github.com/prometheus/prometheus v2.5.0+incompatible h1:7QPitgO2kOFG8ecuRn9O/4L9+10He72rVRJvMXrE9Hg= 213 | github.com/prometheus/prometheus v2.5.0+incompatible/go.mod h1:oAIUtOny2rjMX0OWN5vPR5/q/twIROJvdqnQKDdil/s= 214 | github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446 h1:/NRJ5vAYoqz+7sG51ubIDHXeWO8DlTSrToPu6q11ziA= 215 | github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M= 216 | github.com/sirupsen/logrus v0.0.0-20170323161349-3bcb09397d6d/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= 217 | github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= 218 | github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= 219 | github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I= 220 | github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= 221 | github.com/spaolacci/murmur3 v0.0.0-20150829172844-0d12bf811670/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= 222 | github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ= 223 | github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= 224 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 225 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 226 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 227 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 228 | github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= 229 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 230 | github.com/twinj/uuid v0.0.0-20150629100731-70cac2bcd273/go.mod h1:mMgcE1RHFUFqe5AfiwlINXisXfDGro23fWdPUfOMjRY= 231 | github.com/twinj/uuid v0.1.0 h1:m4NyLH5MReF8zWQegEXvSTpnV6A7svVLG5FbZql6OAA= 232 | github.com/twinj/uuid v0.1.0/go.mod h1:mMgcE1RHFUFqe5AfiwlINXisXfDGro23fWdPUfOMjRY= 233 | github.com/uber/jaeger-client-go v2.8.0+incompatible h1:7DGH8Hqk6PirD+GE+bvCf0cLnspLuae7N1NcwMeQcyg= 234 | github.com/uber/jaeger-client-go v2.8.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= 235 | github.com/uber/jaeger-lib v1.1.0/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U= 236 | github.com/uber/jaeger-lib v1.5.0 h1:OHbgr8l656Ub3Fw5k9SWnBfIEwvoHQ+W2y+Aa9D1Uyo= 237 | github.com/uber/jaeger-lib v1.5.0/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U= 238 | github.com/ugorji/go v1.1.1 h1:gmervu+jDMvXTbcHQ0pd2wee85nEoE0BsVyEuzkfK8w= 239 | github.com/ugorji/go v1.1.1/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ= 240 | github.com/unrolled/render v0.0.0-20171102162132-65450fb6b2d3 h1:ZsIlNwu/G0zbChIZaWOeZ2TPGNmKMt46jZLXi3e8LFc= 241 | github.com/unrolled/render v0.0.0-20171102162132-65450fb6b2d3/go.mod h1:tu82oB5W2ykJRVioYsB+IQKcft7ryBr7w12qMBUPyXg= 242 | github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18 h1:MPPkRncZLN9Kh4MEFmbnK4h3BD7AUmskWv2+EeZJCCs= 243 | github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= 244 | github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 245 | github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 246 | go.uber.org/zap v1.9.1 h1:XCJQEf3W6eZaVwhRBof6ImoYGJSITeKWsyeh3HFu/5o= 247 | go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= 248 | golang.org/x/crypto v0.0.0-20180503215945-1f94bef427e3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 249 | golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 250 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 251 | golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 252 | golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= 253 | golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 254 | golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 255 | golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 256 | golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 257 | golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 258 | golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 259 | golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 260 | golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 261 | golang.org/x/net v0.0.0-20181106065722-10aee1819953/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 262 | golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 263 | golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 264 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 265 | golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 266 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 267 | golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 268 | golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= 269 | golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI= 270 | golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= 271 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 272 | golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 273 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 274 | golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 275 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 276 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 277 | golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 278 | golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 279 | golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 280 | golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 281 | golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 282 | golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 283 | golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 284 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 285 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 286 | golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 287 | golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 288 | golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 289 | golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 290 | golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 291 | golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 292 | golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 293 | golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 h1:JWgyZ1qgdTaF3N3oxC+MdTV7qvEEgHo3otj+HB5CM7Q= 294 | golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 295 | golang.org/x/text v0.0.0-20171214130843-f21a4dfb5e38/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 296 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 297 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 298 | golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= 299 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 300 | golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 h1:+DCIGbF/swA92ohVg0//6X2IVY3KZs6p9mix0ziNYJM= 301 | golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 302 | golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 303 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 304 | golang.org/x/tools v0.0.0-20181008205924-a2b3f7f249e9/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 305 | golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 306 | golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= 307 | golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= 308 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 309 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 310 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 311 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= 312 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 313 | google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 314 | google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 315 | google.golang.org/genproto v0.0.0-20180427144745-86e600f69ee4/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 316 | google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 317 | google.golang.org/genproto v0.0.0-20181004005441-af9cb2a35e7f/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 318 | google.golang.org/genproto v0.0.0-20181221175505-bd9b4fb69e2f h1:eT3B0O2ghdSPzjAOznr3oOLyN1HFeYUncYl7FRwg4VI= 319 | google.golang.org/genproto v0.0.0-20181221175505-bd9b4fb69e2f/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg= 320 | google.golang.org/grpc v0.0.0-20180607172857-7a6a684ca69e/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= 321 | google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= 322 | google.golang.org/grpc v1.16.0 h1:dz5IJGuC2BB7qXR5AyHNwAUBhZscK2xVez7mznh72sY= 323 | google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= 324 | google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= 325 | google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= 326 | google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= 327 | google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= 328 | google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= 329 | google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 330 | google.golang.org/protobuf v1.26.0-rc.1 h1:7QnIQpGRHE5RnLKnESfDoxm2dTapTZua5a0kS0A+VXQ= 331 | google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= 332 | gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= 333 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 334 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= 335 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 336 | gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= 337 | gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= 338 | gopkg.in/natefinch/lumberjack.v2 v2.0.0-20161104145732-dd45e6a67c53/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= 339 | gopkg.in/natefinch/lumberjack.v2 v2.0.0-20170531160350-a96e63847dc3 h1:AFxeG48hTWHhDTQDk/m2gorfVHUEa9vo3tp3D7TzwjI= 340 | gopkg.in/natefinch/lumberjack.v2 v2.0.0-20170531160350-a96e63847dc3/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= 341 | gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= 342 | gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= 343 | gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 344 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 345 | gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 346 | gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 347 | gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= 348 | gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 349 | honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 350 | -------------------------------------------------------------------------------- /pkg/adapter/reader.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The TiPrometheus 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 | package adapter 15 | 16 | import ( 17 | "bytes" 18 | "encoding/gob" 19 | "log" 20 | "math" 21 | "strconv" 22 | 23 | "github.com/bragfoo/TiPrometheus/pkg/conf" 24 | "github.com/bragfoo/TiPrometheus/pkg/lib" 25 | "github.com/bragfoo/TiPrometheus/pkg/tikv" 26 | "github.com/prometheus/prometheus/prompb" 27 | "go.uber.org/zap/buffer" 28 | ) 29 | 30 | var ( 31 | pool = buffer.NewPool() 32 | ) 33 | 34 | func RemoteReader(querys prompb.ReadRequest) *prompb.ReadResponse { 35 | //query 36 | query := querys.Queries[0] 37 | startTime := query.StartTimestampMs 38 | endTime := query.EndTimestampMs 39 | matchers := query.Matchers 40 | log.Println("Query:", startTime, endTime, matchers) 41 | 42 | //compute time endpoint 43 | timeEndpoinFromGet := getTimeEndpoint(startTime, endTime) 44 | 45 | //get data by matchers 46 | docTimeseries := getSameMatcher(matchers, timeEndpoinFromGet) 47 | 48 | //response 49 | var queryResult prompb.QueryResult 50 | queryResult.Timeseries = docTimeseries 51 | var queryResults []*prompb.QueryResult 52 | queryResults = append(queryResults, &queryResult) 53 | var resp prompb.ReadResponse 54 | resp.Results = queryResults 55 | 56 | return &resp 57 | } 58 | 59 | func getTimeEndpoint(startTime, endTime int64) []int64 { 60 | interval := float64(conf.RunTimeInfo.TimeInterval * 1000 * 60) 61 | startTimeCompute := (math.Floor(float64(startTime) / interval)) * interval 62 | endTimeCompute := (math.Floor(float64(endTime) / interval)) * interval 63 | //log.Println("Time compute:", int64(startTimeCompute), int64(endTimeCompute)) 64 | 65 | //get timeEndpointList 66 | timeEndpointList := getTimeEndpointList(int64(startTimeCompute), int64(endTimeCompute), int64(interval)) 67 | 68 | return timeEndpointList 69 | } 70 | 71 | func getTimeEndpointList(startTimeCompute, endTimeCompute, interval int64) []int64 { 72 | var timeEndpointList []int64 73 | //in one time interval 74 | if startTimeCompute == endTimeCompute { 75 | endTimeCompute = startTimeCompute + interval 76 | } 77 | //in time intervals 78 | timeEndpointList = append(timeEndpointList, int64(startTimeCompute)) 79 | timeEndpoint := startTimeCompute 80 | for { 81 | // TODO: use-interval-instead-of-hardcoded-value -- Incoming Change 82 | timeEndpoint = timeEndpoint + interval 83 | timeEndpointList = append(timeEndpointList, int64(timeEndpoint)) 84 | if timeEndpoint == endTimeCompute { 85 | break 86 | } 87 | } 88 | //log.Println("Time endpoint list:", timeEndpointList) 89 | return timeEndpointList 90 | } 91 | 92 | func getSameMatcher(matchers []*prompb.LabelMatcher, timeEndpointList []int64) []*prompb.TimeSeries { 93 | buf := pool.Get() 94 | defer buf.Free() 95 | 96 | //get count map 97 | countMap := getCountMap(matchers) 98 | 99 | var docTimeseries []*prompb.TimeSeries 100 | 101 | //get intersection 102 | for md, count := range countMap { 103 | if count == len(matchers) { 104 | //log.Println("Find intersection key md:", md) 105 | 106 | //get labels info 107 | buf.AppendString("doc:") 108 | buf.AppendString(md) 109 | labelInfoKey := buf.Bytes() 110 | labelInfoKV, _ := tikv.Get([]byte(labelInfoKey)) 111 | buf.Reset() 112 | 113 | //get labels 114 | labels, _ := makeLabels([]byte(labelInfoKV.Value)) 115 | 116 | //get timeseries list 117 | timeListString := getTimeList(md, timeEndpointList) 118 | timeList := lib.ReadStringByStepwidth(13, timeListString) 119 | 120 | //get values 121 | values := getValues(timeList, md) 122 | 123 | // one timeseries 124 | oneDocTimeseries := prompb.TimeSeries{ 125 | Labels: labels, 126 | Samples: values, 127 | } 128 | docTimeseries = append(docTimeseries, &oneDocTimeseries) 129 | } 130 | } 131 | 132 | log.Println("Response:", docTimeseries) 133 | return docTimeseries 134 | } 135 | 136 | func getCountMap(matchers []*prompb.LabelMatcher) map[string]int { 137 | buf := pool.Get() 138 | defer buf.Free() 139 | 140 | countMap := make(map[string]int) 141 | for _, queryLabel := range matchers { 142 | //newLabel 143 | buf.AppendString("index:label:") 144 | buf.AppendString(queryLabel.Name) 145 | buf.AppendString("#") 146 | buf.AppendString(queryLabel.Value) 147 | newLabel := buf.String() 148 | buf.Reset() 149 | 150 | //get label index list 151 | //key type index:label:newLabel 152 | newLabelValue, _ := tikv.Get([]byte(newLabel)) 153 | mdList := lib.ReadStringByStepwidth(32, newLabelValue.Value) 154 | 155 | //mark count 156 | for _, oneMD := range mdList { 157 | oldCount := countMap[oneMD] 158 | newCount := oldCount + 1 159 | countMap[oneMD] = newCount 160 | } 161 | 162 | } 163 | 164 | //log.Println("Count Map:", countMap) 165 | return countMap 166 | } 167 | 168 | func makeLabels(labelInfoByte []byte) ([]*prompb.Label, error) { 169 | var labels []*prompb.Label 170 | var buf bytes.Buffer 171 | // wtire to buffer 172 | buf.Write(labelInfoByte) 173 | dec := gob.NewDecoder(&buf) 174 | // read from buffer 175 | err := dec.Decode(&labels) 176 | if err != nil { 177 | return nil, err 178 | } 179 | //log.Println("Labels:", labels) 180 | return labels, nil 181 | } 182 | 183 | func getTimeList(md string, timeEndpointList []int64) string { 184 | buf := pool.Get() 185 | defer buf.Free() 186 | 187 | var timeList string 188 | //key type index:timeseries:5d4decf2a1d0dd0151cd893cfc752af4:1543639500000 189 | for _, oneTimeEndpoint := range timeEndpointList { 190 | buf.AppendString("index:timeseries:") 191 | buf.AppendString(md) 192 | buf.AppendString(":") 193 | buf.AppendString(strconv.FormatInt(oneTimeEndpoint, 10)) 194 | timeIndexBytes := buf.Bytes() 195 | buf.Reset() 196 | newLabelValue, _ := tikv.Get(timeIndexBytes) 197 | //log.Println("One time endpoint list:", newLabelValue.Value) 198 | 199 | if newLabelValue.Value != "" { 200 | //split with , 201 | //timeList = append(timeList, strings.Split(newLabelValue.Value, ",")...) 202 | timeList = timeList + newLabelValue.Value 203 | } 204 | 205 | } 206 | 207 | //log.Println("Time list:", timeList) 208 | return timeList 209 | } 210 | 211 | func getValues(timeList []string, md string) []prompb.Sample { 212 | var values []prompb.Sample 213 | 214 | bvChan := make(chan prompb.Sample, 1000) 215 | 216 | for _, oneTimePoint := range timeList { 217 | //get time point and value 218 | go getTimePointValue(oneTimePoint, md, bvChan) 219 | } 220 | 221 | // init count 222 | var bvNum int 223 | // read from channel 224 | for { 225 | baseValue := <-bvChan 226 | bvNum = bvNum + 1 227 | values = append(values, baseValue) 228 | if bvNum == len(timeList) { 229 | close(bvChan) 230 | break 231 | } 232 | } 233 | 234 | return values 235 | } 236 | 237 | func getTimePointValue(oneTimePoint, md string, bvChan chan prompb.Sample) { 238 | buf := pool.Get() 239 | //key type timeseries:doc:5d4decf2a1d0dd0151cd893cfc752af4:1543639730686 240 | buf.AppendString("timeseries:doc:") 241 | buf.AppendString(md) 242 | buf.AppendString(":") 243 | buf.AppendString(oneTimePoint) 244 | key := buf.Bytes() 245 | oneTimePointValue, _ := tikv.Get([]byte(key)) 246 | buf.Free() 247 | //log.Println("One doc:", oneTimeseriesValue) 248 | 249 | oneTimePointValueFloat, _ := strconv.ParseFloat(oneTimePointValue.Value, 64) 250 | oneTimePointInt, _ := strconv.ParseInt(oneTimePoint, 10, 64) 251 | 252 | baseValue := prompb.Sample{ 253 | Value: oneTimePointValueFloat, 254 | Timestamp: oneTimePointInt, 255 | } 256 | 257 | bvChan <- baseValue 258 | } 259 | -------------------------------------------------------------------------------- /pkg/adapter/writer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The TiPrometheus 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 | package adapter 15 | 16 | import ( 17 | "log" 18 | "strconv" 19 | 20 | "github.com/bragfoo/TiPrometheus/pkg/conf" 21 | "github.com/bragfoo/TiPrometheus/pkg/lib" 22 | 23 | "bytes" 24 | "time" 25 | 26 | "github.com/bragfoo/TiPrometheus/pkg/tikv" 27 | "github.com/prometheus/prometheus/prompb" 28 | "go.uber.org/zap/buffer" 29 | ) 30 | 31 | var ( 32 | buffers = buffer.NewPool() 33 | ) 34 | 35 | func RemoteWriter(data prompb.WriteRequest) { 36 | for _, oneDoc := range data.Timeseries { 37 | labels := oneDoc.Labels 38 | samples := oneDoc.Samples 39 | log.Println("Naive write data:", labels, samples) 40 | 41 | //build index and return labelID 42 | labelID := buildIndex(labels, samples) 43 | //log.Println("LabelID:", labelID) 44 | 45 | //write timeseries data 46 | writeTimeseriesData(labelID, samples) 47 | 48 | // TODO: need handle error 49 | labelsByte, _ := lib.GetBytes(labels) 50 | SaveOriDoc(labelID, labelsByte) 51 | } 52 | } 53 | 54 | //build md5 data and store to kv if not exist 55 | func buildIndex(labels []*prompb.Label, samples []prompb.Sample) string { 56 | //make md 57 | //key type key#value 58 | buf := buffers.Get() 59 | defer buf.Free() 60 | for _, v := range labels { 61 | buf.AppendString(v.Name) 62 | buf.AppendString("#") 63 | buf.AppendString(v.Value) 64 | } 65 | 66 | labelBytes := buf.Bytes() 67 | labelID := lib.MakeMDByByte(labelBytes) 68 | buf.Reset() 69 | 70 | //labels index 71 | for _, v := range labels { 72 | //key type index:label:__name__#latency 73 | buf.AppendString("index:label:") 74 | buf.AppendString(v.Name) 75 | buf.AppendString("#") 76 | buf.AppendString(v.Value) 77 | key := buf.String() 78 | buf.Reset() 79 | //log.Println("Write label md:", key, labelID) 80 | 81 | //key type index:status:__name__#latency+labelID 82 | buf.AppendString("index:status:") 83 | buf.AppendString(v.Name) 84 | buf.AppendString("#") 85 | buf.AppendString(v.Value) 86 | buf.AppendString("+") 87 | buf.AppendString(labelID) 88 | indexStatus := buf.Bytes() 89 | 90 | indexStatusKey, _ := tikv.Get([]byte(indexStatus)) 91 | //log.Println("indexStatus:", indexStatusKey) 92 | 93 | //not in index 94 | if "" == indexStatusKey.Value { 95 | // TODO: need handle error 96 | err := tikv.Puts([]byte(indexStatus), []byte("1")) 97 | if err != nil { 98 | log.Print(err) 99 | } 100 | 101 | //wtire tikv 102 | // TODO: need handle error 103 | oldKey, err := tikv.Get([]byte(key)) 104 | if err != nil { 105 | log.Print(err) 106 | } 107 | 108 | if oldKey.Value == "" { 109 | // TODO: need handle error 110 | err := tikv.Puts([]byte(key), []byte(labelID)) 111 | if err != nil { 112 | log.Print(err) 113 | } 114 | } else { 115 | b := bytes.NewBufferString(oldKey.Value) 116 | b.WriteString(labelID) 117 | v := b.Bytes() 118 | 119 | // TODO: need handle error 120 | err := tikv.Puts([]byte(key), v) 121 | if err != nil { 122 | log.Print(err) 123 | } 124 | } 125 | } 126 | 127 | buf.Reset() 128 | } 129 | 130 | buf.Reset() 131 | buf.AppendString("index:timeseries:") 132 | 133 | now := time.Now().UnixNano() / int64(time.Millisecond) 134 | 135 | interval := int64(conf.RunTimeInfo.TimeInterval * 1000 * 60) 136 | now = (now / interval) * interval 137 | 138 | buf.AppendString(labelID) 139 | buf.AppendString(":") 140 | buf.AppendString(strconv.FormatInt(now, 10)) 141 | 142 | timeIndexBytes := buf.Bytes() 143 | 144 | //timeseries index 145 | for _, v := range samples { 146 | oldKey, _ := tikv.Get(timeIndexBytes) 147 | //log.Println("Timeseries indexStatus:", oldKey) 148 | if oldKey.Value == "" { 149 | // TODO: need handle error 150 | err := tikv.Puts(timeIndexBytes, lib.Int64ToBytes(v.Timestamp)) 151 | if err != nil { 152 | log.Print(err) 153 | } 154 | } else { 155 | bs := buffers.Get() 156 | bs.AppendString(oldKey.Value) 157 | bs.AppendString(strconv.FormatInt(v.Timestamp, 10)) 158 | v := bs.Bytes() 159 | // TODO: need handle error 160 | err := tikv.Puts(timeIndexBytes, v) 161 | if err != nil { 162 | log.Print(err) 163 | } 164 | bs.Free() 165 | } 166 | } 167 | 168 | return labelID 169 | } 170 | 171 | func writeTimeseriesData(labelID string, samples []prompb.Sample) { 172 | buf := buffers.Get() 173 | defer buf.Free() 174 | for _, v := range samples { 175 | //key type timeseries:doc:labelMD#timestamp 176 | buf.AppendString("timeseries:doc:") 177 | buf.AppendString(labelID) 178 | buf.AppendString(":") 179 | buf.AppendString(strconv.FormatInt(v.Timestamp, 10)) 180 | key := buf.Bytes() 181 | 182 | //write to tikv 183 | // TODO: need handle error 184 | err := tikv.Puts(key, []byte(strconv.FormatFloat(v.Value, 'E', -1, 64))) 185 | if err != nil { 186 | log.Print(err) 187 | } 188 | //log.Println("Write timeseries:", string(key), strconv.FormatFloat(v.Value, 'E', -1, 64)) 189 | buf.Reset() 190 | } 191 | } 192 | 193 | func SaveOriDoc(labelID string, originalMsg []byte) { 194 | buf := buffers.Get() 195 | defer buf.Free() 196 | buf.AppendString("doc:") 197 | buf.AppendString(labelID) 198 | key := buf.Bytes() 199 | // TODO: need handle error 200 | err := tikv.Puts(key, originalMsg) 201 | if err != nil { 202 | log.Print(err) 203 | } 204 | //log.Println("Write meta:", string(key), string(originalMsg)) 205 | } 206 | -------------------------------------------------------------------------------- /pkg/conf/conf.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The TiPrometheus 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 | package conf 15 | 16 | // AgentConf is the agent configuration type. 17 | type AgentConf struct { 18 | PDHost string 19 | TimeInterval int 20 | AdapterListen string 21 | AdapterEnableTLS bool 22 | AdapterCACertificate string 23 | AdapterServerCertificate string 24 | AdapterServerKey string 25 | TiKVEnableTLS bool 26 | TiKVCACertificate string 27 | TiKVClientCertificate string 28 | TiKVClientKey string 29 | } 30 | 31 | // RunTimeInfo contains the active configuration. 32 | var RunTimeInfo AgentConf 33 | 34 | // RunTimeMap contains the full configuration file. 35 | var RunTimeMap map[string]AgentConf 36 | 37 | // DefaultRunTimeName specifies the name of the default TOML section 38 | // to be loaded when nothing is configured. 39 | const DefaultRunTimeName = "default" 40 | -------------------------------------------------------------------------------- /pkg/lib/convert.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The TiPrometheus 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 | package lib 15 | 16 | import ( 17 | "bytes" 18 | "crypto/md5" 19 | "encoding/binary" 20 | "encoding/gob" 21 | "encoding/hex" 22 | "strconv" 23 | 24 | "go.uber.org/zap/buffer" 25 | ) 26 | 27 | var ( 28 | buffers = buffer.NewPool() 29 | ) 30 | 31 | func GetBytes(key interface{}) ([]byte, error) { 32 | var buf bytes.Buffer 33 | enc := gob.NewEncoder(&buf) 34 | err := enc.Encode(key) 35 | return buf.Bytes(), err 36 | } 37 | 38 | func Int64ToBytes(i int64) []byte { 39 | return []byte(strconv.FormatInt(i, 10)) 40 | } 41 | 42 | func Int64WriteBytes(i int64) []byte { 43 | buf := buffers.Get() 44 | defer buf.Free() 45 | // TODO: need handle error 46 | err := binary.Write(buf, binary.BigEndian, i) 47 | if err != nil { 48 | return []byte{} 49 | } 50 | b := buf.Bytes() 51 | return b 52 | } 53 | 54 | func MakeMDByByte(initByte []byte) string { 55 | m := md5.New() 56 | // TODO: need handle error 57 | _, err := m.Write(initByte) 58 | if err != nil { 59 | return "" 60 | } 61 | md := m.Sum(nil) 62 | mdString := hex.EncodeToString(md) 63 | return mdString 64 | } 65 | 66 | func ReadStringByStepwidth(step int, str string) []string { 67 | var buf []string 68 | for i := 0; i < len(str); i += step { 69 | buf = append(buf, str[i:i+step]) 70 | } 71 | return buf 72 | } 73 | 74 | func ReadFixedLength(step int, bts []byte) []string { 75 | var buf []string 76 | for i := 0; i < len(bts); i += step { 77 | buf = append(buf, string(bts[i:i+step])) 78 | } 79 | return buf 80 | } 81 | -------------------------------------------------------------------------------- /pkg/lib/error.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The TiPrometheus 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 | package lib 15 | 16 | import ( 17 | "log" 18 | "time" 19 | ) 20 | 21 | // ErrorLogger is error log for self 22 | func ErrorLogger(errAgs error) { 23 | timeMark := time.Now() 24 | log.Println(timeMark.Format("[2006/01/02 15:04:05]"), errAgs) 25 | } 26 | -------------------------------------------------------------------------------- /pkg/lib/log.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The TiPrometheus 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 | package lib 15 | 16 | import ( 17 | "log" 18 | "os" 19 | "strings" 20 | "time" 21 | ) 22 | 23 | // InitLog is init log info 24 | func InitLog() { 25 | log.SetOutput(os.Stdout) 26 | } 27 | 28 | // CustomLogger is custom log for self 29 | func CustomLogger(args ...string) { 30 | logInfo := strings.Join(args, " ") 31 | timeMark := time.Now() 32 | log.Println(timeMark.Format("[2006/01/02 15:04:05]"), logInfo) 33 | } 34 | -------------------------------------------------------------------------------- /pkg/process/init.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The TiPrometheus 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 | package process 15 | 16 | import ( 17 | "log" 18 | 19 | "github.com/BurntSushi/toml" 20 | "github.com/bragfoo/TiPrometheus/pkg/conf" 21 | "github.com/bragfoo/TiPrometheus/pkg/lib" 22 | "github.com/bragfoo/TiPrometheus/pkg/tikv" 23 | ) 24 | 25 | // Init loads the configuration file and initializes 26 | // logging and other subsystems. 27 | func Init(runTime, confPath string) { 28 | // load the config file 29 | if _, err := toml.DecodeFile(confPath, &conf.RunTimeMap); err != nil { 30 | log.Println(err) 31 | return 32 | } 33 | // fall back to the default config section when unspecified 34 | if runTime == "" { 35 | runTime = conf.DefaultRunTimeName 36 | } 37 | conf.RunTimeInfo = conf.RunTimeMap[runTime] 38 | log.Println(conf.RunTimeInfo) 39 | // init log 40 | lib.InitLog() 41 | // init tikv client lib 42 | if conf.RunTimeInfo.TiKVEnableTLS { 43 | tikv.Init([]string{conf.RunTimeInfo.PDHost}, conf.RunTimeInfo.TiKVCACertificate, conf.RunTimeInfo.TiKVClientCertificate, conf.RunTimeInfo.TiKVClientKey) 44 | } else { 45 | tikv.Init([]string{conf.RunTimeInfo.PDHost}, "", "", "") 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /pkg/simpleHTTP/controller.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The TiPrometheus 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 | package simpleHTTP 15 | 16 | import ( 17 | "io/ioutil" 18 | "net/http" 19 | 20 | "github.com/bragfoo/TiPrometheus/pkg/adapter" 21 | "github.com/gogo/protobuf/proto" 22 | "github.com/golang/snappy" 23 | "github.com/prometheus/prometheus/prompb" 24 | ) 25 | 26 | func RemoteWrite(w http.ResponseWriter, r *http.Request) { 27 | compressed, err := ioutil.ReadAll(r.Body) 28 | if err != nil { 29 | http.Error(w, err.Error(), http.StatusInternalServerError) 30 | return 31 | } 32 | // resolve snappy 33 | reqBuf, err := snappy.Decode(nil, compressed) 34 | if err != nil { 35 | http.Error(w, err.Error(), http.StatusBadRequest) 36 | return 37 | } 38 | // resolve json 39 | var wreq prompb.WriteRequest 40 | 41 | if err := proto.Unmarshal(reqBuf, &wreq); err != nil { 42 | http.Error(w, err.Error(), http.StatusBadRequest) 43 | return 44 | } 45 | // resolve data 46 | adapter.RemoteWriter(wreq) 47 | if _, err := w.Write([]byte("ok")); err != nil { 48 | return 49 | } 50 | } 51 | 52 | func RemoteRead(w http.ResponseWriter, r *http.Request) { 53 | compressed, err := ioutil.ReadAll(r.Body) 54 | if err != nil { 55 | http.Error(w, err.Error(), http.StatusInternalServerError) 56 | return 57 | } 58 | // snappy 59 | reqBuf, err := snappy.Decode(nil, compressed) 60 | if err != nil { 61 | http.Error(w, err.Error(), http.StatusBadRequest) 62 | return 63 | } 64 | // resolve json 65 | var rreq prompb.ReadRequest 66 | if err := proto.Unmarshal(reqBuf, &rreq); err != nil { 67 | http.Error(w, err.Error(), http.StatusBadRequest) 68 | return 69 | } 70 | naiveData := adapter.RemoteReader(rreq) 71 | data, _ := proto.Marshal(naiveData) 72 | // sender 73 | w.Header().Set("Content-Type", "application/x-protobuf") 74 | w.Header().Set("Content-Encoding", "snappy") 75 | compressed = snappy.Encode(nil, data) 76 | if _, err := w.Write(compressed); err != nil { 77 | return 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /pkg/simpleHTTP/server.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The TiPrometheus 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 | package simpleHTTP 15 | 16 | import ( 17 | "crypto/tls" 18 | "crypto/x509" 19 | "fmt" 20 | "io/ioutil" 21 | "log" 22 | "net/http" 23 | ) 24 | 25 | const defaultHTTPEndpoint = ":12350" 26 | 27 | // Server starts an HTTP listener on endpoint and waits for connections. 28 | // This function simply calls ServerTLS without any certificates. 29 | func Server(endpoint string) { 30 | ServerTLS(endpoint, "", "", "") 31 | } 32 | 33 | // ServerTLS starts an HTTP or HTTPS listener on endpoint and waits for connections. 34 | // 35 | // If endpoint is unspecified, ":12350" is used. 36 | // 37 | // If a server certificate is specified, HTTPS is enabled. 38 | // Simple HTTP is used otherwise. 39 | // 40 | // If a CA certificate is specified, mTLS (mutual TLS) is enabled. 41 | // Connecting clients must pass a valid client certificate signed by the CA. 42 | func ServerTLS(endpoint string, caCertFile string, certFile string, keyFile string) { 43 | // create a muxer and register the handlers 44 | mux := http.NewServeMux() 45 | mux.HandleFunc("/write", RemoteWrite) 46 | mux.HandleFunc("/read", RemoteRead) 47 | 48 | // configure our server 49 | if endpoint == "" { 50 | // fall back to the default endpoint if none given 51 | endpoint = defaultHTTPEndpoint 52 | } 53 | server := &http.Server{ 54 | Addr: endpoint, 55 | Handler: mux, 56 | } 57 | 58 | // check if mTLS is requested 59 | if certFile != "" && keyFile != "" && caCertFile != "" { 60 | caCert, err := ioutil.ReadFile(caCertFile) 61 | if err != nil { 62 | log.Fatal(err) 63 | } 64 | caCertPool := x509.NewCertPool() 65 | caCertPool.AppendCertsFromPEM(caCert) 66 | tlsConfig := &tls.Config{ 67 | ClientCAs: caCertPool, 68 | ClientAuth: tls.RequireAndVerifyClientCert, 69 | } 70 | tlsConfig.BuildNameToCertificate() 71 | server := &http.Server{ 72 | Addr: endpoint, 73 | TLSConfig: tlsConfig, 74 | } 75 | server.TLSConfig = tlsConfig 76 | } 77 | 78 | // check if HTTPS is requested 79 | if certFile == "" || keyFile == "" { 80 | // simple HTTP 81 | // TODO: need handle error 82 | err := server.ListenAndServe() 83 | if err != nil { 84 | fmt.Println(err) 85 | } 86 | } else { 87 | // HTTPS 88 | // TODO: need handle error 89 | err := server.ListenAndServeTLS(certFile, keyFile) 90 | if err != nil { 91 | fmt.Println(err) 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /pkg/tikv/tikv.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The TiPrometheus 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 | package tikv 15 | 16 | import ( 17 | "log" 18 | 19 | "github.com/pingcap/tidb/config" 20 | "github.com/pingcap/tidb/store/tikv" 21 | ) 22 | 23 | type kv struct { 24 | Key string 25 | Value string 26 | } 27 | 28 | var Client *tikv.RawKVClient 29 | 30 | // Init initializes the global TiKV client connection. 31 | // 32 | // Multiple PD servers can be specified to support automatic failover. 33 | // 34 | // caCertFile, certFile and keyFile are required when the TiKV/PD cluster is TLS enabled. 35 | // A regular unencrypted connection is created if they are empty. 36 | func Init(pdhosts []string, caCertFile string, certFile string, keyFile string) { 37 | // set up TLS config 38 | security := config.Security{ 39 | ClusterSSLCA: caCertFile, 40 | ClusterSSLCert: certFile, 41 | ClusterSSLKey: keyFile, 42 | } 43 | var err error 44 | Client, err = tikv.NewRawKVClient(pdhosts, security) 45 | if err != nil { 46 | log.Println(err) 47 | } 48 | } 49 | 50 | // Puts 51 | func Puts(args ...[]byte) error { 52 | for i := 0; i < len(args); i += 2 { 53 | key, val := args[i], args[i+1] 54 | err := Client.Put(key, val) 55 | if err != nil { 56 | return err 57 | } 58 | } 59 | return nil 60 | } 61 | 62 | // Dels 63 | func Dels(keys ...[]byte) error { 64 | for i := 0; i < len(keys); i += 1 { 65 | err := Client.Delete(keys[i]) 66 | if err != nil { 67 | return err 68 | } 69 | } 70 | return nil 71 | } 72 | 73 | // Delall 74 | func Delall(startKey []byte, limit int) error { 75 | keys, _, err := Client.Scan(startKey, limit) 76 | if err != nil { 77 | return err 78 | } 79 | for i := 0; i < len(keys); i += 1 { 80 | // TODO: handle multi error 81 | err = Dels(keys[i]) 82 | if err != nil { 83 | return err 84 | } 85 | } 86 | return nil 87 | } 88 | 89 | // Get 90 | func Get(k []byte) (kv, error) { 91 | v, err := Client.Get(k) 92 | if err != nil { 93 | return kv{}, err 94 | } 95 | return kv{Key: string(k), Value: string(v)}, nil 96 | } 97 | 98 | // Scan 99 | func Scan(startKey []byte, limit int) ([]kv, error) { 100 | var kvs []kv 101 | keys, values, err := Client.Scan(startKey, limit) 102 | if err != nil { 103 | return kvs, err 104 | } 105 | for i := 0; i < len(keys); i += 1 { 106 | kvs = append(kvs, kv{Key: string(keys[i]), Value: string(values[i])}) 107 | } 108 | return kvs, nil 109 | } 110 | --------------------------------------------------------------------------------