Skip to content

Commit

Permalink
1.4.1 version
Browse files Browse the repository at this point in the history
  • Loading branch information
kiamran authored Jan 2, 2020
1 parent 032c288 commit f39cfa1
Show file tree
Hide file tree
Showing 54 changed files with 3,582 additions and 182 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM alpine:3.7

ENV ANODOT_TAGS="source=prometheus-remote-write"
ADD anodot-prometheus-remote-write /go/bin/anodot-prometheus-remote-write
# ln -s required for backward compatibility with older docker images.
RUN apk add --no-cache ca-certificates && ln -s /go/bin/anodot-prometheus-remote-write /go/bin/server
Expand Down
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
GO := go
HELM:=helm
GOFLAGS=-mod=vendor

GOARCH := amd64
Expand Down Expand Up @@ -49,19 +50,19 @@ build-container: build
@echo ">> created docker image $(DOCKER_IMAGE_NAME):$(VERSION)"

build-charts:
helm init --client-only
helm version --client
@helm plugin install https://github.com/instrumenta/helm-kubeval || echo "Skipping error..."
$(HELM) init --client-only
$(HELM) version --client
@$(HELM) plugin install https://github.com/instrumenta/helm-kubeval || echo "Skipping error..."
./utils/kubeval.sh
helm lint deployment/helm/*
helm package deployment/helm/*
$(HELM) lint deployment/helm/*
$(HELM) package deployment/helm/*

test:
GOFLAGS=$(GOFLAGS) $(GO) test -v -race -coverprofile=coverage.txt -covermode=atomic -timeout 10s ./pkg/...

test-container: build-container
@docker rm -f $(APPLICATION_NAME) || true
@docker run -d -P --name=$(APPLICATION_NAME) $(DOCKER_IMAGE_NAME):$(VERSION) --token abc --url http://localhost:9090
@docker run -d -P --name=$(APPLICATION_NAME) $(DOCKER_IMAGE_NAME):$(VERSION) --token abc --url http://localhost
docker ps
set -x curl --connect-timeout 5 --max-time 10 --retry 5 --retry-delay 0 --retry-max-time 40 -I http://localhost:$$(docker port $(APPLICATION_NAME) | grep -o '[0-9]*$$' )/health

Expand Down
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,17 @@ make test

# Deploying application application

Optional Configuration options. Should be specified under `configuration.env` section in values.yaml

| Env variable | Description | Default |
| ----------------------------|-------------------------------------------------------------------------------| --------------|
| ANODOT_LOG_LEVEL | Application log level. Supported options are: `panic, fatal, error, warning, info, debug, trace`| info |
| ANODOT_TAGS | Format `TAG1=VALUE1;TAG2=VALUE2` Static tags that will be added to Anodot |["source":"prometheus-remote-write"]|
| ANODOT_HTTP_DEBUG_ENABLED | Should be used to enable HTTP requests/response dumps to stdout |false|

## Prerequisites
- Docker 1.18ce.
- Prometheus Server on K8s cluster.
- Prometheus Server

### Using helm

Expand Down Expand Up @@ -88,8 +96,14 @@ metadata:
app: prometheus-operator-prometheus
name: prometheus
spec:
remoteWrite:
- url: "http://anodot-prometheus-remote-write:1234/receive"
remoteWrite:
- url: http://anodot-prometheus-remote-write:1234/receive
# writeRelabelConfigs:
# - action: drop
# regex: '(apiserver_request_count|prometheus_remote_storage_sent_batch_duration_seconds_bucket)'
# sourceLabels: [__name__]
queueConfig:
maxSamplesPerSend: 1000
version: v2.10.0
```
Expand Down
2 changes: 1 addition & 1 deletion deployment/docker-compose/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '2'

services:
remote-write:
image: anodot/prometheus-remote-write:1.4.0
image: anodot/prometheus-remote-write:1.5.0
container_name: anodot-prometheus-remote-write
restart: unless-stopped
ports:
Expand Down
4 changes: 2 additions & 2 deletions deployment/helm/anodot-prometheus-remote-write/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v1
name: anodot-prometheus-remote-write
version: "1.0.0"
version: "1.1.0"
description: Anodot Prometheus remote write. Used to push Prometheus to Anodot system.
appVersion: "1.4.0"
appVersion: "1.5.0"
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,18 @@ spec:
labels:
app: {{ template "template_name" . }}
release: {{ .Release.Name }}
annotations:
prometheus.io/scrape: 'true'
prometheus.io/port: '1234'
spec:
containers:
- name: {{ template "template_name" . }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
env:
{{- range $name, $value := .Values.configuration.env }}
- name: "{{ $name }}"
value: "{{ $value }}"
{{- end }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
{{ range .Values.configuration.args }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: {{ template "template_name" . }}
name: {{ template "template_name" . }}
annotations:
prometheus.io/scrape: 'true'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{ if .Values.prometheus.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
app: {{ template "template_name" . }}
requiredBy: "anodot"
{{- if .Values.prometheus.serviceMonitor.labels}}
{{ toYaml .Values.prometheus.serviceMonitor.labels | indent 4 }}
{{- end }}
name: {{ template "template_name" . }}
spec:
jobLabel: {{ .Values.prometheus.serviceMonitor.jobLabel }}
namespaceSelector:
any: true
selector:
matchLabels:
app: {{ template "template_name" . }}
release: {{ .Release.Name }}
endpoints:
- port: http
{{- if .Values.prometheus.serviceMonitor.interval }}
interval: {{ .Values.prometheus.serviceMonitor.interval }}
{{- end }}
{{- if .Values.prometheus.serviceMonitor.metricRelabelings }}
metricRelabelings:
{{ tpl (toYaml .Values.prometheus.serviceMonitor.metricRelabelings | indent 8) . }}
{{- end }}
{{- if .Values.prometheus.serviceMonitor.relabelings }}
relabelings:
{{ toYaml .Values.prometheus.serviceMonitor.relabelings | indent 8 }}
{{- end }}
{{- end }}
38 changes: 33 additions & 5 deletions deployment/helm/anodot-prometheus-remote-write/values.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
image:
repository: anodot/prometheus-remote-write
tag: "1.4.0"
tag: "1.5.0"
pullPolicy: IfNotPresent

configuration:
replicas: 1
env:
ANODOT_LOG_LEVEL: "error"
ANODOT_TAGS: "source:prometheus-remote-write"
ANODOT_HTTP_DEBUG_ENABLED: "false"
args:
- "--url=http://anodotd:8080/api/v1/"
- "--token=XXXXXXXXX"

resources:
requests:
memory: '4Gi'
cpu: '150m'
limits:
memory: '5Gi'
memory: '200M'
cpu: '300m'
limits:
memory: '1Gi'
cpu: '500m'

livenessProbe:
initialDelaySeconds: 30
Expand All @@ -28,3 +32,27 @@ readinessProbe:

service:
type: ClusterIP

prometheus:
serviceMonitor:
enabled: false
jobLabel: "anodot-prometheus-remote-write"
labels:
key: "value"

interval: 30s
scrapeTimeout: 5s

metricRelabelings: []
# - sourceLabels: [__name__]
# separator: ;
# regex: ^node_mountstats_nfs_(event|operations|transport)_.+
# replacement: $1
# action: drop
relabelings: []
# - sourceLabels: [__meta_kubernetes_pod_node_name]
# separator: ;
# regex: ^(.*)$
# target_label: nodename
# replacement: $1
# action: replace
7 changes: 4 additions & 3 deletions e2e/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
ANODOT_API_TOKEN: "123456"

prometheus:
image: prom/prometheus:v2.13.1
image: prom/prometheus:latest
depends_on:
- remote-write
ports:
Expand All @@ -22,7 +22,7 @@ services:
- ./sample-docker-prometheus.yml:/etc/prometheus/prometheus.yml:ro

remote-write:
image: anodot/prometheus-remote-write:1.4.0
image: anodot/prometheus-remote-write:1.5.0
container_name: anodot-prometheus-remote-write
depends_on:
- anodot-metrics-stub
Expand All @@ -31,4 +31,5 @@ services:
- "1234:1234"
command: ["-url=http://anodot-metrics-stub","--port=8080","-token=123456","-workers=20"]
environment:
ANODOT_METRICS_BUFFER_SIZE: 4
ANODOT_METRICS_PER_REQUEST_SIZE: 4
ANODOT_LOG_LEVEL: "trace"
21 changes: 19 additions & 2 deletions e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ type Metrics struct {
Properties map[string]string `json:"properties"`
Timestamp float64 `json:"timestamp"`
Value float64 `json:"value"`
Tags struct {
} `json:"tags"`
Tags map[string]string `json:"tags"`
}

func TestMain(m *testing.M) {
Expand Down Expand Up @@ -54,6 +53,11 @@ INFINITE_LOOP:
for {
samples, err := metrics("http://localhost:1234/metrics", 3, 1*time.Second)
if err != nil {
out, err = shellCommand("docker-compose", "logs")
log.Println(string(out))
if err != nil {
log.Fatal("Failed to execute docker-compose command", err)
}
log.Fatal("Failed to get metrics:", err)
}

Expand Down Expand Up @@ -198,6 +202,10 @@ func TestMetricsData(t *testing.T) {
t.Fatal("Number of metrics does not match")
}

expectedTags := map[string]string{
"source": "prometheus-remote-write",
}

for _, m := range metrics {
what := m.Properties["what"]
switch what {
Expand All @@ -220,6 +228,11 @@ func TestMetricsData(t *testing.T) {
if !reflect.DeepEqual(m.Properties, expectedProperties) {
t.Fatal(fmt.Sprintf("Not equal properties.\n Got %v\n, want %v", m.Properties, expectedProperties))
}

if !reflect.DeepEqual(m.Tags, expectedTags) {
t.Fatal(fmt.Sprintf("Not equal tags.\n Got %v\n, want %v", m.Tags, expectedTags))
}

case "exported_version":
expectedProperties := map[string]string{
"instance": "anodot-metrics-stub:8080",
Expand All @@ -238,6 +251,10 @@ func TestMetricsData(t *testing.T) {
t.Fatal(fmt.Sprintf("Not equal properties.\n Got %v\n want %v", m.Properties, expectedProperties))
}

if !reflect.DeepEqual(m.Tags, expectedTags) {
t.Fatal(fmt.Sprintf("Not equal tags.\n Got %v\n, want %v", m.Tags, expectedTags))
}

default:
t.Fatal(fmt.Sprintf("Unsupported what value=%q", what))
}
Expand Down
14 changes: 11 additions & 3 deletions e2e/sample-docker-prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ global:
remote_write:
- url: "http://remote-write:1234/receive"
write_relabel_configs:
- source_labels: [ __name__ ]
regex: 'exported_http_requests_total|exported_version'
- source_labels: [anodot_include]
regex: 'true'
action: keep
- regex: 'anodot_include'
action: labeldrop
queue_config:
batch_send_deadline: 1s

Expand All @@ -16,4 +18,10 @@ scrape_configs:
metrics_path: '/stub/metrics'

static_configs:
- targets: ['anodot-metrics-stub:8080']
- targets: ['anodot-metrics-stub:8080']

metric_relabel_configs:
- source_labels: [__name__]
regex: '(exported_http_requests_total|exported_version)'
replacement: 'true'
target_label: 'anodot_include'
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ module github.com/anodot/anodot-remote-write
go 1.12

require (
github.com/anodot/anodot-common v0.0.0-20191203135633-34129dedd424
github.com/anodot/anodot-common v0.0.1
github.com/gogo/protobuf v1.2.1 // indirect
github.com/golang/protobuf v1.3.2
github.com/golang/snappy v0.0.1
github.com/grpc-ecosystem/grpc-gateway v1.9.6 // indirect
github.com/prometheus/client_golang v1.2.1
github.com/prometheus/common v0.7.0
github.com/prometheus/prometheus v2.5.0+incompatible
github.com/sirupsen/logrus v1.4.2
google.golang.org/genproto v0.0.0-20190817000702-55e96fffbd48 // indirect
google.golang.org/grpc v1.23.0 // indirect
)
9 changes: 7 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuy
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/anodot/anodot-common v0.0.0-20191203135633-34129dedd424 h1:ZpAYPvpiiqVTGSEkykCKCUjTcu00eAO+BTDtZl5hEZU=
github.com/anodot/anodot-common v0.0.0-20191203135633-34129dedd424/go.mod h1:T6BrWGlhuYjMG3w+y0+Tu2Qcju/vWpZsI6Iqaw/qadA=
github.com/anodot/anodot-common v0.0.1 h1:7HzGMchhYCU9oPOGOsVr0/Y/0l3A9XOxzeMDA+abGbw=
github.com/anodot/anodot-common v0.0.1/go.mod h1:T6BrWGlhuYjMG3w+y0+Tu2Qcju/vWpZsI6Iqaw/qadA=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
Expand All @@ -17,6 +17,7 @@ github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
Expand Down Expand Up @@ -49,6 +50,7 @@ github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
Expand All @@ -63,6 +65,7 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0 h1:vrDKnkGzuGvhNAL56c7DBz29ZL+KxnoR0x7enabFceM=
Expand Down Expand Up @@ -90,10 +93,12 @@ github.com/prometheus/prometheus v2.5.0+incompatible h1:7QPitgO2kOFG8ecuRn9O/4L9
github.com/prometheus/prometheus v2.5.0+incompatible/go.mod h1:oAIUtOny2rjMX0OWN5vPR5/q/twIROJvdqnQKDdil/s=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand Down
Loading

0 comments on commit f39cfa1

Please sign in to comment.