Skip to content

Commit

Permalink
include Cortex version in cortex_build_info (#2468)
Browse files Browse the repository at this point in the history
* include build info in cortex_build_info metric

Signed-off-by: Thor <thansen@digitalocean.com>

* Added CHANGELOG entry

Signed-off-by: Marco Pracucci <marco@pracucci.com>

Co-authored-by: Thor <thansen@digitalocean.com>
Co-authored-by: Marco Pracucci <marco@pracucci.com>
  • Loading branch information
3 people committed Apr 17, 2020
1 parent 74ea373 commit 996cb83
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -30,6 +30,7 @@
* [BUGFIX] Experimental TSDB: fixed response status code from `422` to `500` when an error occurs while iterating chunks with the experimental blocks storage. #2402
* [BUGFIX] Ring: Fixed a situation where upgrading from pre-1.0 cortex with a rolling strategy caused new 1.0 ingesters to lose their zone value in the ring until manually forced to re-register. #2404
* [BUGFIX] Distributor: `/all_user_stats` now show API and Rule Ingest Rate correctly. #2457
* [BUGFIX] Fixed `version`, `revision` and `branch` labels exported by the `cortex_build_info` metric. #2468

## 1.0.0 / 2020-04-02

Expand Down
8 changes: 6 additions & 2 deletions Makefile
@@ -1,12 +1,16 @@
.PHONY: all test clean images protos exes dist
.DEFAULT_GOAL := all

# Version number
VERSION=$(shell cat "./VERSION" 2> /dev/null)

# Boiler plate for building Docker containers.
# All this must go at top of file I'm afraid.
IMAGE_PREFIX ?= quay.io/cortexproject/
# Use CIRCLE_TAG if present for releases.
IMAGE_TAG ?= $(if $(CIRCLE_TAG),$(CIRCLE_TAG),$(shell ./tools/image-tag))
GIT_REVISION := $(shell git rev-parse HEAD)
GIT_REVISION := $(shell git rev-parse --short HEAD)
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
UPTODATE := .uptodate

# Support gsed on OSX (installed via brew), falling back to sed. On Linux
Expand Down Expand Up @@ -82,7 +86,7 @@ RM := --rm
# as it currently disallows TTY devices. This value needs to be overridden
# in any custom cloudbuild.yaml files
TTY := --tty
GO_FLAGS := -ldflags "-extldflags \"-static\" -s -w" -tags netgo
GO_FLAGS := -ldflags "-X main.Branch=$(GIT_BRANCH) -X main.Revision=$(GIT_REVISION) -X main.Version=$(VERSION) -extldflags \"-static\" -s -w" -tags netgo

ifeq ($(BUILD_IN_CONTAINER),true)

Expand Down
10 changes: 10 additions & 0 deletions cmd/cortex/main.go
Expand Up @@ -22,7 +22,17 @@ import (
"github.com/cortexproject/cortex/pkg/util/flagext"
)

// Version is set via build flag -ldflags -X main.Version
var (
Version string
Branch string
Revision string
)

func init() {
version.Version = Version
version.Branch = Branch
version.Revision = Revision
prometheus.MustRegister(version.NewCollector("cortex"))
}

Expand Down

0 comments on commit 996cb83

Please sign in to comment.