From c38f9a38cfb5df4cd25870cac767966dafd8a425 Mon Sep 17 00:00:00 2001 From: Christian Simon Date: Fri, 14 Jan 2022 13:28:17 +0000 Subject: [PATCH] Remove unnecessary files from cortextool import --- .../.github/workflows/validate_pr.yml | 38 ---- cmd/cortextool/.golangci.yml | 22 -- cmd/cortextool/.goreleaser.yml | 152 ------------- cmd/cortextool/CODEOWNERS | 4 - cmd/cortextool/LICENSE | 201 ------------------ cmd/cortextool/Makefile | 89 -------- cmd/cortextool/RELEASE.md | 28 --- cmd/cortextool/docs/benchtool.md | 170 --------------- cmd/cortextool/docs/blockgen.md | 72 ------- cmd/cortextool/docs/e2ealerting.md | 90 -------- 10 files changed, 866 deletions(-) delete mode 100644 cmd/cortextool/.github/workflows/validate_pr.yml delete mode 100644 cmd/cortextool/.golangci.yml delete mode 100644 cmd/cortextool/.goreleaser.yml delete mode 100644 cmd/cortextool/CODEOWNERS delete mode 100644 cmd/cortextool/LICENSE delete mode 100644 cmd/cortextool/Makefile delete mode 100644 cmd/cortextool/RELEASE.md delete mode 100644 cmd/cortextool/docs/benchtool.md delete mode 100644 cmd/cortextool/docs/blockgen.md delete mode 100644 cmd/cortextool/docs/e2ealerting.md diff --git a/cmd/cortextool/.github/workflows/validate_pr.yml b/cmd/cortextool/.github/workflows/validate_pr.yml deleted file mode 100644 index 7fc81fe8728..00000000000 --- a/cmd/cortextool/.github/workflows/validate_pr.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Validate PR -on: - pull_request: - paths-ignore: - - 'docs/**' - - '*.md' -jobs: - lint: - name: Lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: golangci-lint - uses: golangci/golangci-lint-action@v2 - with: - version: v1.31 - unit_tests: - name: Unit-Tests - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Go 1.16 - uses: actions/setup-go@v1 - with: - go-version: 1.16 - - name: Unit Tests - run: make test - build: - name: Build Binaries - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Go 1.16 - uses: actions/setup-go@v1 - with: - go-version: 1.16 - - name: Build All - run: make all diff --git a/cmd/cortextool/.golangci.yml b/cmd/cortextool/.golangci.yml deleted file mode 100644 index 4a835f7a95b..00000000000 --- a/cmd/cortextool/.golangci.yml +++ /dev/null @@ -1,22 +0,0 @@ -run: - timeout: 10m - modules-download-mode: vendor - build-tags: - - netgo - - require_docker - -output: - format: line-number - -linters: - enable: - - goimports - - golint - - misspell - - gofmt - -linters-settings: - errcheck: - exclude: .errcheck-exclude - goimports: - local-prefixes: "github.com/grafana/cortextool" diff --git a/cmd/cortextool/.goreleaser.yml b/cmd/cortextool/.goreleaser.yml deleted file mode 100644 index 454b9a1184d..00000000000 --- a/cmd/cortextool/.goreleaser.yml +++ /dev/null @@ -1,152 +0,0 @@ -before: - hooks: - - go mod download - # you may remove this if you don't need go generate - - go generate ./... -project_name: cortextool -builds: - - id: cortextool-darwin - ldflags: - -s -w -X github.com/grafana/cortex-tools/pkg/version.Version={{.Version}} - binary: cortextool - env: - - CGO_ENABLED=0 - main: ./cmd/cortextool/main.go - goos: - - darwin - goarch: - - amd64 - - arm64 - - id: cortextool-linux - ldflags: - -s -w -X github.com/grafana/cortex-tools/pkg/version.Version={{.Version}} - binary: cortextool - env: - - CGO_ENABLED=0 - main: ./cmd/cortextool/main.go - goos: - - linux - goarch: - - amd64 - - id: cortextool-windows - ldflags: - -s -w -X github.com/grafana/cortex-tools/pkg/version.Version={{.Version}} - binary: cortextool - env: - - CGO_ENABLED=0 - main: ./cmd/cortextool/main.go - goos: - - windows - goarch: - - amd64 - - 386 - - id: benchtool-darwin - ldflags: - -s -w -X github.com/grafana/cortex-tools/pkg/version.Version={{.Version}} - binary: benchtool - env: - - CGO_ENABLED=0 - main: ./cmd/benchtool/ - goos: - - darwin - goarch: - - amd64 - - arm64 - - id: benchtool-linux - ldflags: - -s -w -X github.com/grafana/cortex-tools/pkg/version.Version={{.Version}} - binary: benchtool - env: - - CGO_ENABLED=0 - main: ./cmd/benchtool/ - goos: - - linux - goarch: - - amd64 - - id: benchtool-windows - ldflags: - -s -w -X github.com/grafana/cortex-tools/pkg/version.Version={{.Version}} - binary: benchtool - env: - - CGO_ENABLED=0 - main: ./cmd/benchtool/ - goos: - - windows - goarch: - - amd64 - - 386 -archives: - - replacements: - darwin: mac-os - linux: linux - windows: windows - 386: i386 - amd64: x86_64 - format_overrides: - - goos: windows - format: zip - files: - - none* - format: binary - - id: needed-for-homebrew - builds: - - cortextool-linux - - cortextool-darwin - format: 'tar.gz' -checksum: - name_template: 'checksums.txt' -snapshot: - name_template: "{{ .Tag }}-next" -changelog: - sort: asc - filters: - exclude: - - '^docs:' - - '^test:' -dockers: - - goos: linux - goarch: amd64 - ids: - - cortextool-linux - dockerfile: cmd/cortextool/GR.Dockerfile - image_templates: - - "grafana/cortex-tools:latest" - - "grafana/cortex-tools:{{ .Tag }}" - build_flag_templates: - - "--pull" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.name={{.ProjectName}}" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - - "--label=repository=https://github.com/grafana/cortex-tools" - - "--label=homepage=https://grafana.com" - - goos: linux - goarch: amd64 - ids: - - benchtool-linux - dockerfile: cmd/benchtool/GR.Dockerfile - image_templates: - - "grafana/benchtool:latest" - - "grafana/benchtool:{{ .Tag }}" - build_flag_templates: - - "--pull" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.name=benchtool" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - - "--label=repository=https://github.com/grafana/cortex-tools/tree/main/cmd/benchtool" - - "--label=homepage=https://grafana.com" -brews: - - - ids: - - needed-for-homebrew - tap: - owner: grafana - name: homebrew-grafana - commit_author: - name: cortex-tools-ci - email: support@grafana.com - homepage: https://grafana.com - description: Tools for interacting with Cortex - install: | - bin.install "cortextool" diff --git a/cmd/cortextool/CODEOWNERS b/cmd/cortextool/CODEOWNERS deleted file mode 100644 index 0296909ac3c..00000000000 --- a/cmd/cortextool/CODEOWNERS +++ /dev/null @@ -1,4 +0,0 @@ -# https://help.github.com/articles/about-codeowners/ -# https://git-scm.com/docs/gitignore#_pattern_format - -* @grafana/cortex-team diff --git a/cmd/cortextool/LICENSE b/cmd/cortextool/LICENSE deleted file mode 100644 index f5fbe58f242..00000000000 --- a/cmd/cortextool/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2019 grafana - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file diff --git a/cmd/cortextool/Makefile b/cmd/cortextool/Makefile deleted file mode 100644 index 727d5121494..00000000000 --- a/cmd/cortextool/Makefile +++ /dev/null @@ -1,89 +0,0 @@ -.PHONY: all images lint test clean cross - -.DEFAULT_GOAL := all -IMAGE_PREFIX ?= grafana -IMAGE_TAG := $(shell ./tools/image-tag) -GIT_REVISION := $(shell git rev-parse --short HEAD) -GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD) -GO_FLAGS := -mod=vendor -ldflags "-extldflags \"-static\" -s -w -X $(VPREFIX).Branch=$(GIT_BRANCH) -X $(VPREFIX).Version=$(IMAGE_TAG) -X $(VPREFIX).Revision=$(GIT_REVISION)" -tags netgo - -all: cortextool chunktool logtool -images: cortextool-image chunktool-image logtool-image benchtool-image -benchtool: cmd/benchtool/benchtool -cortextool: cmd/cortextool/cortextool -chunktool: cmd/chunktool/chunktool -logtool: cmd/logtool/logtool -e2ealerting: cmd/e2ealerting/e2ealerting -blockscopy: cmd/blockscopy/blockscopy - -benchtool-image: - $(SUDO) docker build -t $(IMAGE_PREFIX)/benchtool -f cmd/benchtool/Dockerfile . - $(SUDO) docker tag $(IMAGE_PREFIX)/benchtool $(IMAGE_PREFIX)/benchtool:$(IMAGE_TAG) - -cortextool-image: - $(SUDO) docker build -t $(IMAGE_PREFIX)/cortextool -f cmd/cortextool/Dockerfile . - $(SUDO) docker tag $(IMAGE_PREFIX)/cortextool $(IMAGE_PREFIX)/cortextool:$(IMAGE_TAG) - -chunktool-image: - $(SUDO) docker build -t $(IMAGE_PREFIX)/chunktool -f cmd/chunktool/Dockerfile . - $(SUDO) docker tag $(IMAGE_PREFIX)/chunktool $(IMAGE_PREFIX)/chunktool:$(IMAGE_TAG) - -logtool-image: - $(SUDO) docker build -t $(IMAGE_PREFIX)/logtool -f cmd/logtool/Dockerfile . - $(SUDO) docker tag $(IMAGE_PREFIX)/logtool $(IMAGE_PREFIX)/logtool:$(IMAGE_TAG) - -e2ealerting-image: - $(SUDO) docker build -t $(IMAGE_PREFIX)/e2ealerting -f cmd/e2ealerting/Dockerfile . - $(SUDO) docker tag $(IMAGE_PREFIX)/e2ealerting $(IMAGE_PREFIX)/e2ealerting:$(IMAGE_TAG) -push-e2ealerting-image: e2ealerting-image - $(SUDO) docker push $(IMAGE_PREFIX)/e2ealerting:$(IMAGE_TAG) - -blockscopy-image: - $(SUDO) docker build -t $(IMAGE_PREFIX)/blockscopy -f cmd/blockscopy/Dockerfile . - $(SUDO) docker tag $(IMAGE_PREFIX)/blockscopy $(IMAGE_PREFIX)/blockscopy:$(IMAGE_TAG) - -cmd/benchtool/benchtool: $(APP_GO_FILES) cmd/benchtool/main.go - CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D) - -cmd/cortextool/cortextool: $(APP_GO_FILES) cmd/cortextool/main.go - CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D) - -cmd/chunktool/chunktool: $(APP_GO_FILES) cmd/chunktool/main.go - CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D) - -cmd/logtool/logtool: $(APP_GO_FILES) cmd/logtool/main.go - CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D) - -cmd/e2ealerting/e2ealerting: $(APP_GO_FILES) cmd/e2ealerting/main.go - CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D) - -cmd/rules-migrator/rules-migrator: $(APP_GO_FILES) cmd/rules-migrator/main.go - CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D) - -cmd/blockscopy/blockscopy: $(APP_GO_FILES) cmd/blockscopy/main.go - CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D) - -lint: - golangci-lint run -v - -cross: - CGO_ENABLED=0 gox -output="dist/{{.Dir}}-{{.OS}}-{{.Arch}}" -ldflags=${LDFLAGS} -arch="amd64" -os="linux windows darwin" -osarch="darwin/arm64" ./cmd/benchtool - CGO_ENABLED=0 gox -output="dist/{{.Dir}}-{{.OS}}-{{.Arch}}" -ldflags=${LDFLAGS} -arch="amd64" -os="linux windows darwin" -osarch="darwin/arm64" ./cmd/blockgen - CGO_ENABLED=0 gox -output="dist/{{.Dir}}-{{.OS}}-{{.Arch}}" -ldflags=${LDFLAGS} -arch="amd64" -os="linux windows darwin" -osarch="darwin/arm64" ./cmd/blockscopy - CGO_ENABLED=0 gox -output="dist/{{.Dir}}-{{.OS}}-{{.Arch}}" -ldflags=${LDFLAGS} -arch="amd64" -os="linux windows darwin" -osarch="darwin/arm64" ./cmd/chunktool - CGO_ENABLED=0 gox -output="dist/{{.Dir}}-{{.OS}}-{{.Arch}}" -ldflags=${LDFLAGS} -arch="amd64" -os="linux windows darwin" -osarch="darwin/arm64" ./cmd/cortextool - CGO_ENABLED=0 gox -output="dist/{{.Dir}}-{{.OS}}-{{.Arch}}" -ldflags=${LDFLAGS} -arch="amd64" -os="linux windows darwin" -osarch="darwin/arm64" ./cmd/e2ealerting - CGO_ENABLED=0 gox -output="dist/{{.Dir}}-{{.OS}}-{{.Arch}}" -ldflags=${LDFLAGS} -arch="amd64" -os="linux windows darwin" -osarch="darwin/arm64" ./cmd/logtool - CGO_ENABLED=0 gox -output="dist/{{.Dir}}-{{.OS}}-{{.Arch}}" -ldflags=${LDFLAGS} -arch="amd64" -os="linux windows darwin" -osarch="darwin/arm64" ./cmd/rules-migrator - CGO_ENABLED=0 gox -output="dist/{{.Dir}}-{{.OS}}-{{.Arch}}" -ldflags=${LDFLAGS} -arch="amd64" -os="linux windows darwin" -osarch="darwin/arm64" ./cmd/sim - -test: - go test -mod=vendor -p=8 ./pkg/... - -clean: - rm -rf cmd/benchtool/benchtool - rm -rf cmd/cortextool/cortextool - rm -rf cmd/chunktool/chunktool - rm -rf cmd/logtool/logtool - rm -rf cmd/e2ealerting/e2ealerting - rm -rf cmd/blockscopy/blockscopy diff --git a/cmd/cortextool/RELEASE.md b/cmd/cortextool/RELEASE.md deleted file mode 100644 index 8965064f838..00000000000 --- a/cmd/cortextool/RELEASE.md +++ /dev/null @@ -1,28 +0,0 @@ -# Release processes - -## GoReleaser (`cortextool` only) - -1. Create a changelog file in `changelog/` with the name of the tag e.g. `changelog/v0.3.0.md`. This will be used as the template for the release page in GitHub. -2. Create a new tag that follows semantic versioning: - -```bash -$ tag=v0.3.0 -$ git tag -s "${tag}" -m "${tag}" -$ git push origin "${tag}" -``` - -3. Run `$ goreleaser release --release-notes=changelogs/v0.3.0.md --rm-dist` where the changelog file is the one created as part of step 1. -4. The docker image will be pushed automatically. - -## Manual (all the other binaries) - -1. Manually build and test the new additions -2. Create a new tag based on: - $ tag=v0.2.1 - $ git tag -s "${tag}" -m "${tag}" - $ git push origin "${tag}" - -3. Create the binaries with `make cross`, they are in dist/ -4. Create the GitHub release, copy the release notes from the previous ones, and adjust as necessary. Upload the binaries created and click publish on the release. -5. The last step is creating and uploading the docker images. Use make image to create them and then tag them. Keep in mind that there is only 1 image for cortextool in Dockerhub at the moment. -6. Make sure to update the latest tag to the most recent version. diff --git a/cmd/cortextool/docs/benchtool.md b/cmd/cortextool/docs/benchtool.md deleted file mode 100644 index f71b7906afa..00000000000 --- a/cmd/cortextool/docs/benchtool.md +++ /dev/null @@ -1,170 +0,0 @@ -# Benchtool - -The `benchtool` is a small load testing utility to generate load for Prometheus -remote-write and query API endpoints. It uses a statically configured YAML -workload file to describe the series and queries used for the generate load. - -**warning:** the specifications outlined here are subject to change. It is -likely the specs in this file will require some adjustment to accomodate -expanded functionality and this should not be consided stable. - -## Workload file - -The `benchtool` is designed to generate Prometheus remote-write and PromQL API -query requests to a configured endpoint. The characteristics of the data used -for these requests is driven by a YAML workload configuration file. The workload -file can be configured as a follows: - -```yaml -replicas: "" -queries: - - expr_template: "" - interval: "" - num_queries: "" - series_type: "" - regex: "" -series: - - name: "" - type: "" - static_labels: - "": "" - labels: - - name: "" - unique_values: "" - value_prefix: "" -write_options: - batch_size: "" - interval: "" -``` - -### Series - -The series configuration section of the workload is used to configure the -metrics generated by the workload. It is a list of series objects that allow the -workload author to declare name and characteristics of each series the workload -will generate. - -- **name** is the metric name of the series that will generated. The name will - be used as the reserved `__name__` label for each series generated using this - series config. -- **type** references the type of series that will be generated and the - characteristics of it's underlying data. See the [series type - section](#series-type) for more information. -- **static_labels** is a map of string values to string keys. These will be - added as labels to each series generated from this series description. -- **labels** is field that allows for the input of a list of label descriptions. - The series generated from this series description will be based on the result - of all possible combinations of the provided label descriptions. - - **name** refers to the label name of the generated label. - - **unique_values** referes to the number of values to generate for this - label. - - **value_prefix** refers to the prefix that will used for each generated - label value. The resultant label value will be the prefix appended with - `-`, where the integer is a value between `0` and the configured - `unique_values`. - -#### Series types - -Series types are used in both the series and queries section of the workload. -The denote the character and properties of the data of the generated or queried -series. The following series types are supported. - -- _gauge-zero_: correlates to a gauge series that will contantly be zero. This - is a commonly seen pattern in Prometheus info metrics. -- _gauge-random_: correlates to a gauge series that constant changes to a random - value. The values is chosen using `rand.Float64`. -- _counter-one_ correlates to a counter that increases by 1 at every interval. -- _counter-random_ correlates to a counter that increases by a random amount - every interval. The random amount is not constant and is currently chosen - using `rand.Int()`. - -### Global options - -- **replicas**: Replicas is meant to be a stand in for the host label. For each - value between 0 and the configured replica value, a `bench_replica` label will - be added and appended to each generated series. This label will also be used for - queries configured to use regular expressions. - -### Queries - -The query workload is made up of a list of configured queries. Queries have a -variety of options that can be configured to get the desired behavior. - -- **series_type:** Series type to use for this query. A series name generated - from the `series` section of the Cortex config will be chosen and used for - each generated query. -- **expr_template** is used to configure the query expression that will be run. - It uses a modified [Go text template](https://golang.org/pkg/text/template/) - to allow for the name of a series and a matcher to be injected into the query. - The name will be sourced from the series name and the matcher will be a match - on the `bench_replicas` label. -- **regex** is a boolean value that, if enabled, will cause the injected - `bench_replica` matcher on the query to be a regex match on a single replica - instead of an exact matcher. -- **interval:** Interval at which each instantiation of this query description - will run. A random jitter no greater than half the configured interval is - applied before the first run of each query to ensure that queries are not all - scheduled to run simultaneously. -- **num_queries:** Number of replicas to run of this configured query. Each - instance of the generated query will select a random series with the same - series type. Each query will also apply a unique random jitter on the interval - before it's first run. - -### Write options - -- **batch_size** determines the number of samples send in each remote-write - request. -- **interval** is the duration period between when each batch of remote-write - requests are generated and queued to be sent. - -### Example workload file - -```yaml ---- -queries: - - expr_template: sum(<<.Name>>{<<.Matchers>>}) - interval: 1m - num_queries: 3 - series_type: gauge-random - - expr_template: sum(<<.Name>>{<<.Matchers>>}) - interval: 1m - num_queries: 5 - series_type: gauge-zero - time_range: 2h -replicas: 5 -series: - - labels: - - name: label_01 - unique_values: 5 - value_prefix: label_value_01 - - name: label_02 - unique_values: 20 - value_prefix: label_value_02 - name: metric_gauge_random_01 - static_labels: - static: "true" - type: gauge-random - - labels: - - name: label_01 - unique_values: 5 - value_prefix: label_value_01 - - name: label_02 - unique_values: 20 - value_prefix: label_value_02 - name: metric_gauge_zero_01 - static_labels: - static: "true" - type: gauge-zero -write_options: - batch_size: 1000 - interval: 15s -``` - -## Consistency - -To ensure results are consistent between runs, the seed of the random number -generator used by the workload is determined by the configured `-bench.id` flag -value of the benchtool instance. - -This will ensure two `benchtool` processes run with the same id and workload -config file will result in the same behavior between runs. diff --git a/cmd/cortextool/docs/blockgen.md b/cmd/cortextool/docs/blockgen.md deleted file mode 100644 index f798e98b639..00000000000 --- a/cmd/cortextool/docs/blockgen.md +++ /dev/null @@ -1,72 +0,0 @@ -# Blockgen - -The `blockgen` is a tool which generates Prometheus blocks of mock data. These -blocks can be uploaded to an object store used by Cortex, which may be useful -to profile and benchmark Cortex components when querying or compacting the -generated blocks. - -## Config file - -The blockgen command requires a config file to be specified. -It uses the same syntax to define what metrics should be generated like the -`benchtool` which is documented [here](benchtool.md). - -This is an example config file: - -```yaml -replicas: 3 -block_gen: - interval: 15s - block_size: 2h - block_dir: /tmp/mock_blocks - max_t: 1623422958000 - min_t: 1623336558000 -series: - - labels: - - name: label_01 - unique_values: 100 - value_prefix: label_value_01 - - name: label_02 - unique_values: 10 - value_prefix: label_value_02 - name: metric_gauge_random_01 - static_labels: - static: "true" - type: gauge-random - - labels: - - name: label_01 - unique_values: 100 - value_prefix: label_value_01 - - name: label_02 - unique_values: 10 - value_prefix: label_value_02 - name: metric_gauge_zero_01 - static_labels: - static: "true" - type: gauge-zero -``` - -## Running it - -Assuming the config is in a file named `blockgen.conf` the command could -be run like this: - -``` -$ ./blockgen --config.file=./blockgen.conf -level=info msg="Generating data" minT=1623336558000 maxT=1623422958000 interval=15000 -level=info msg="starting new block" block_id=225463 blocks_left=13 -level=info msg="starting new block" block_id=225464 blocks_left=12 -level=info msg="starting new block" block_id=225465 blocks_left=11 -level=info msg="starting new block" block_id=225466 blocks_left=10 -level=info msg="starting new block" block_id=225467 blocks_left=9 -level=info msg="starting new block" block_id=225468 blocks_left=8 -level=info msg="starting new block" block_id=225469 blocks_left=7 -level=info msg="starting new block" block_id=225470 blocks_left=6 -level=info msg="starting new block" block_id=225471 blocks_left=5 -level=info msg="starting new block" block_id=225472 blocks_left=4 -level=info msg="starting new block" block_id=225473 blocks_left=3 -level=info msg="starting new block" block_id=225474 blocks_left=2 -level=info msg="starting new block" block_id=225475 blocks_left=1 -level=info msg=finished block_dir=/tmp/mock_blocks -$ -``` diff --git a/cmd/cortextool/docs/e2ealerting.md b/cmd/cortextool/docs/e2ealerting.md deleted file mode 100644 index 3ab586b1ef0..00000000000 --- a/cmd/cortextool/docs/e2ealerting.md +++ /dev/null @@ -1,90 +0,0 @@ -# e2ealerting - -## How it works - -`e2ealerting` helps measure the end to end alerting latency between [Prometheus](https://github.com/prometheus/prometheus) scrapes and [Alertmanager](https://github.com/prometheus/alertmanager) notification delivery. We achieve that by creating a metric that exposes the current time as its value, then creating an alert definition that uses that value as an annotation, and finally a built-in [Alertmanager](https://github.com/prometheus/alertmanager) webhook receiver observes the duration between the value of the annotation and webhook reception time as part of a Histogram. - -A client for synchorinizing Prometheus rules definition and Alertmanager configuration allows us to experiment with different values directly within the tool without having to turn knobs configuration in different places. Keep in mind, that these are meant to only support the Cortex configuration API for the [Ruler](https://cortexmetrics.io/docs/api/#set-rule-group) and [Alertmanager](https://cortexmetrics.io/docs/api/#set-alertmanager-configuration). - -Refer to the diagram below for a brief explanation on how this is all connected. - -``` - ┌─────────────────────────────────────┐ - ┌─────────────┐ │ ┌─────────────┐ +-+-+-+-+-+-+│ - │ Prometheus │ │ │ │ |C|o|r|t|e|x|│ - ┌──────│ or │──────Remote Write─────────┼─▶│ Remote Write│ +-+-+-+-+-+-+│ - │ │ Agent │ │ │ Endpoint │ │ - │ └─────────────┘ │ └─────────────┘ │ -Scrape │ │ - │ │ │ - │ ┌──────────Alert Notification Webhook──┼─────────┐ │ - │ │ │ │ │ - │ ▼ │ │ │ - │ ┌─────────────┐ │ ┌─────────────┐ │ - │ │ │ │ │ │ │ - └─▶│ e2ealerting │──────Alertmanager Config──────┼─▶│ Alertmanager│ │ - │ │ │ │ │ │ - └─────────────┘ │ └─────────────┘ │ - │ │ ┌─────────────┐ │ - │ │ │ │ │ - └──────────────Rule Group Config───────┼─▶│ Ruler │ │ - │ │ │ │ - │ └─────────────┘ │ - └─────────────────────────────────────┘ -``` - -## Installation - -### Compiling from source - -You can compile the binary directly by cloning this repo and running `make cmd/e2ealerting/e2ealerting`. The binary will be located in `cmd/e2ealerting/e2ealerting`. - -### Docker Image - -Docker images are part of [grafana/e2ealerting](https://hub.docker.com/repository/docker/grafana/e2ealerting/tags?page=1) in DockerHub. - -## Configuration - -An example `e2ealerting` configuration would look like: - -``` --configs.key= --configs.alertmanager-file=/data/alertmanger_config.yaml --configs.alertmanager-id= --configs.alertmanager-url=https://alertmanager-us-central1.grafana.net --configs.rulegroup-file=/data/ruler_config.yaml --configs.ruler-id= --configs.ruler-url=https://prometheus-us-central1.grafana.net --configs.sync-interval=2h -``` - -## [optional] Alertmanager and Ruler Configuration - -Please note the both the `alertmanager` and `ruler` configuration are optional. If not defined as part of the config, the syncing process is disabled. - -The Alertmanager configuration file `alertmanger_config.yaml` can be defined as: - -```yaml -global: -receivers: - - name: e2e-alerting - webhook_configs: - - url: /api/v1/receiver -route: - group_interval: 1s - group_wait: 1s - receiver: e2e-alerting - repeat_interval: 1s -``` - -Finally, the rule configuration file `ruler_config.yaml`: - -```yaml -name: e2ealerting -rules: - - alert: E2EAlertingAlwaysFiring - annotations: - time: "{{ $value }}" - expr: e2ealerting_now_in_seconds > 0 - for: 10s -```