-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,521 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
# .goreleaser.yml | ||
builds: | ||
- binary: grafana-annotation | ||
goos: | ||
- linux | ||
- darwin | ||
goarch: | ||
- amd64 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# git options | ||
GIT_COMMIT ?= $(shell git rev-parse HEAD) | ||
GIT_TAG ?= $(shell git tag --points-at HEAD) | ||
DIST_TYPE ?= snapshot | ||
BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD) | ||
|
||
PROJECT_NAME := grafana-annotation | ||
PKG_ORG := Contentsquare | ||
PKG := grafana-annotation | ||
PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/) | ||
GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/ | grep -v _test.go) | ||
BINARY_NAME := grafana-annotation | ||
|
||
M = $(shell printf "\033[34;1m▶\033[0m") | ||
|
||
GO := go | ||
GOFMT := gofmt | ||
OS := $(shell uname -s) | ||
GOOS ?= $(shell echo $(OS) | tr '[:upper:]' '[:lower:]') | ||
GOARCH ?= amd64 | ||
|
||
BUILD_CONSTS = -X main.buildRevision=$(GIT_COMMIT) -X main.buildTag=$(GIT_TAG) | ||
BUILD_OPTS = -ldflags="$(BUILD_CONSTS)" -gcflags="-trimpath=$(GOPATH)/src" | ||
|
||
tidy: | ||
$(info ===== $@ =====) | ||
GO111MODULE=on go mod tidy | ||
|
||
deps: | ||
$(info ===== $@ =====) | ||
GO111MODULE=on go mod vendor | ||
|
||
format: | ||
$(info ===== $@ =====) | ||
$(GOFMT) -w -s $(GO_FILES) | ||
|
||
build: | ||
$(info ===== $@ =====) | ||
GO111MODULE=on GOOS=$(GOOS) $(GO) build -tags static -o $(BINARY_NAME) $(BUILD_OPTS) | ||
|
||
test: | ||
$(info ===== $@ =====) | ||
$(GO) test -v -race -cover -coverprofile=coverage.out ./... | ||
|
||
fmt: | ||
$(info ===== gofmt =====) | ||
$(GOFMT) -d -e -s $(GO_FILES) | ||
|
||
#lint: | ||
# $(info ===== $@ =====) | ||
# $(GO) vet $(PKG_LIST) | ||
# $(GO) list ./... | grep -Ev /vendor/ | sed -e 's/${PROJECT_NAME}/./' | xargs -L1 golint -set_exit_status | ||
# | ||
|
||
lint: | ||
$(info ===== $@ =====) | ||
golangci-lint run . -v | ||
|
||
tarball: version | ||
$(info ===== $@ =====) | ||
ifneq ($(GIT_TAG),) | ||
tar czf $(BINARY_NAME)-$(GOOS)-$(GOARCH)-$(GIT_TAG).tar.gz $(BINARY_NAME) | ||
else | ||
tar czf $(BINARY_NAME)-$(GOOS)-$(GOARCH)-$(VERSION_FILE).tar.gz $(BINARY_NAME) | ||
endif | ||
|
||
version: | ||
$(info ===== $@ =====) | ||
ifneq ($(GIT_TAG),) | ||
$(eval VERSION := $(GIT_TAG)) | ||
$(eval VERSION_FILE := $(GIT_TAG)) | ||
else | ||
$(eval VERSION := $(subst /,-,$(BRANCH))) | ||
$(eval VERSION_FILE := $(GIT_COMMIT)-SNAPSHOT) | ||
endif | ||
@test -n "$(VERSION)" | ||
$(info Building $(VERSION)/$(VERSION_FILE) on sha1 $(GIT_COMMIT)) | ||
|
||
get_version: version | ||
$(info $(VERSION_FILE)) | ||
|
||
.PHONY: tidy \ | ||
deps \ | ||
format \ | ||
build \ | ||
test \ | ||
fmt \ | ||
lint \ | ||
tarball |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,40 @@ | ||
grafana-annotation: Post graphite annotation to grafana 5+. | ||
grafana-annotation: Post annotation to Elastic Search | ||
|
||
# Install | ||
|
||
go get -d "github.com/contentsquare/grafana-annotation" | ||
|
||
# Build | ||
|
||
```shell | ||
make build | ||
``` | ||
|
||
# Configure | ||
|
||
Will work with a configuration file (default to `~/.grafana-anotation-poster.yml`) | ||
|
||
## Configuration file | ||
|
||
```yaml | ||
grafanaUri: https://some-grafana-host.tld | ||
bearerToken: BearerTokenFromGrafana | ||
region: eu-west-1 | ||
env: dev | ||
provider: aws | ||
role: testproject | ||
elasticsearch: | ||
bootstrap_servers: | ||
- http://localhost:9200 | ||
index_name: "test_index.2006.02" | ||
``` | ||
## Create a Bearer Token | ||
[Read the Docs](http://docs.grafana.org/http_api/auth/) | ||
# Build | ||
``` | ||
go build | ||
``` | ||
# Call | ||
## Example usage | ||
## Options | ||
``` | ||
Usage of grafana-annotation: | ||
-config-file string | ||
Configuration File (default "~/.grafana-anotation-poster.yml") | ||
-data string | ||
Additional data. | ||
-tag value | ||
Tags. may be repeated multiple times | ||
-verbose | ||
Be Verbose. | ||
-what string | ||
The What item to post. (default "$(hostname)") | ||
```shell script | ||
~# grafana-annotation --config-file resources/config-test.yml post --tags systemd --tags stop --tags kafka service kafka is stopped | ||
Using config file: resources/config-test.yml | ||
[2020-12-10 13:27:29] INFO Annotation successfully posted to elasticsearch. tags=[systemd stop kafka eu-west-1 testproject dev aws Vianneys-MacBook-Pro.local] | ||
~# | ||
``` | ||
|
||
## Example call | ||
|
||
``` | ||
~$ grafana-annotation -data "Details on this event" -tag foo \ | ||
-tag bar -what "Something happened on system foo with bar event" | ||
``` | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.