From 572989798ee2be7b90e0477a348b34c7fe324df6 Mon Sep 17 00:00:00 2001 From: Viktor Date: Mon, 5 Jun 2017 00:36:55 +0200 Subject: [PATCH] Fixed arguments trimming --- config/alertmanager/Dockerfile | 3 --- config/alertmanager/Dockerfile.slack | 3 +++ .../{config.yml => config-slack.yml} | 0 prometheus/run_test.go | 6 +++-- prometheus/util.go | 2 +- scripts/dm-swarm-07.sh | 26 +++++++++++++++++++ stack.yml | 1 + ...nager-demo.yml => alert-manager-slack.yml} | 2 +- ...full.yml => docker-flow-monitor-slack.yml} | 12 ++++++++- 9 files changed, 47 insertions(+), 8 deletions(-) delete mode 100644 config/alertmanager/Dockerfile create mode 100644 config/alertmanager/Dockerfile.slack rename config/alertmanager/{config.yml => config-slack.yml} (100%) create mode 100755 scripts/dm-swarm-07.sh rename stacks/{alert-manager-demo.yml => alert-manager-slack.yml} (78%) rename stacks/{docker-flow-monitor-full.yml => docker-flow-monitor-slack.yml} (82%) diff --git a/config/alertmanager/Dockerfile b/config/alertmanager/Dockerfile deleted file mode 100644 index 026a3c1..0000000 --- a/config/alertmanager/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM prom/alertmanager - -COPY config.yml /etc/alertmanager/config.yml \ No newline at end of file diff --git a/config/alertmanager/Dockerfile.slack b/config/alertmanager/Dockerfile.slack new file mode 100644 index 0000000..f7946ba --- /dev/null +++ b/config/alertmanager/Dockerfile.slack @@ -0,0 +1,3 @@ +FROM prom/alertmanager + +COPY config-slack.yml /etc/alertmanager/config.yml \ No newline at end of file diff --git a/config/alertmanager/config.yml b/config/alertmanager/config-slack.yml similarity index 100% rename from config/alertmanager/config.yml rename to config/alertmanager/config-slack.yml diff --git a/prometheus/run_test.go b/prometheus/run_test.go index a9afe46..2ae007a 100644 --- a/prometheus/run_test.go +++ b/prometheus/run_test.go @@ -43,13 +43,15 @@ func (s *RunTestSuite) Test_Run_ExecutesPrometheus() { s.Equal([]string{"/bin/sh", "-c", "prometheus -config.file=/etc/prometheus/prometheus.yml -storage.local.path=/prometheus -web.console.libraries=/usr/share/prometheus/console_libraries -web.console.templates=/usr/share/prometheus/consoles"}, actualArgs) } -func (s *RunTestSuite) Test_Run_AddsRoutePrefix() { +func (s *RunTestSuite) Test_Run_AddsArguments() { cmdRunOrig := cmdRun defer func() { cmdRun = cmdRunOrig os.Unsetenv("ARG_WEB_ROUTE-PREFIX") + os.Unsetenv("ARG_ALERTMANAGER_URL") }() os.Setenv("ARG_WEB_ROUTE-PREFIX", "/something") + os.Setenv("ARG_ALERTMANAGER_URL", "alertmanager") actualArgs := []string{} cmdRun = func(cmd *exec.Cmd) error { actualArgs = cmd.Args @@ -58,7 +60,7 @@ func (s *RunTestSuite) Test_Run_AddsRoutePrefix() { Run() - s.Equal([]string{"/bin/sh", "-c", "prometheus -config.file=/etc/prometheus/prometheus.yml -storage.local.path=/prometheus -web.console.libraries=/usr/share/prometheus/console_libraries -web.console.templates=/usr/share/prometheus/consoles -web.route-prefix=/something"}, actualArgs) + s.Equal([]string{"/bin/sh", "-c", "prometheus -config.file=/etc/prometheus/prometheus.yml -storage.local.path=/prometheus -web.console.libraries=/usr/share/prometheus/console_libraries -web.console.templates=/usr/share/prometheus/consoles -web.route-prefix=/something -alertmanager.url=alertmanager"}, actualArgs) } func (s *RunTestSuite) Test_Run_AddsExternalUrl() { diff --git a/prometheus/util.go b/prometheus/util.go index 1d06fcc..d9b602c 100644 --- a/prometheus/util.go +++ b/prometheus/util.go @@ -14,7 +14,7 @@ func getArgFromEnv(env, prefix string) (key, value string) { if strings.HasPrefix(env, prefix + "_") { values := strings.Split(env, "=") key = values[0] - key = strings.TrimLeft(key, prefix + "_") + key = strings.Replace(key, prefix + "_", "", 1) key = strings.ToLower(key) value = values[1] } diff --git a/scripts/dm-swarm-07.sh b/scripts/dm-swarm-07.sh new file mode 100755 index 0000000..2855dc7 --- /dev/null +++ b/scripts/dm-swarm-07.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +./scripts/dm-swarm.sh + +eval $(docker-machine env swarm-1) + +docker network create -d overlay proxy + +docker stack deploy \ + -c stacks/docker-flow-proxy-mem.yml \ + proxy + +docker network create -d overlay monitor + +DOMAIN=$(docker-machine ip swarm-1) \ + docker stack deploy \ + -c stacks/docker-flow-monitor-am.yml \ + monitor + +docker stack deploy \ + -c stacks/exporters-alert.yml \ + exporter + +docker stack deploy \ + -c stacks/go-demo-alert.yml \ + go-demo diff --git a/stack.yml b/stack.yml index d9cd338..72056c7 100644 --- a/stack.yml +++ b/stack.yml @@ -36,6 +36,7 @@ services: - /var/run/docker.sock:/var/run/docker.sock environment: - DF_NOTIFY_CREATE_SERVICE_URL=http://monitor:8080/v1/docker-flow-monitor/reconfigure + - DF_NOTIFY_REMOVE_SERVICE_URL=http://monitor:8080/v1/docker-flow-monitor/remove deploy: labels: - com.df.alertName=memlimit diff --git a/stacks/alert-manager-demo.yml b/stacks/alert-manager-slack.yml similarity index 78% rename from stacks/alert-manager-demo.yml rename to stacks/alert-manager-slack.yml index 8c61f24..bea20de 100644 --- a/stacks/alert-manager-demo.yml +++ b/stacks/alert-manager-slack.yml @@ -3,7 +3,7 @@ version: "3" services: alert-manager: - image: vfarcic/alert-manager:demo + image: vfarcic/alert-manager:slack ports: - 9093:9093 networks: diff --git a/stacks/docker-flow-monitor-full.yml b/stacks/docker-flow-monitor-slack.yml similarity index 82% rename from stacks/docker-flow-monitor-full.yml rename to stacks/docker-flow-monitor-slack.yml index e5e197d..30842b7 100644 --- a/stacks/docker-flow-monitor-full.yml +++ b/stacks/docker-flow-monitor-slack.yml @@ -20,9 +20,14 @@ services: - com.df.servicePath=/monitor - com.df.serviceDomain=${DOMAIN:-localhost} - com.df.port=9090 + resources: + reservations: + memory: 500M + limits: + memory: 800M alert-manager: - image: vfarcic/alert-manager:demo + image: vfarcic/alert-manager:slack networks: - monitor @@ -38,6 +43,11 @@ services: deploy: placement: constraints: [node.role == manager] + resources: + reservations: + memory: 5M + limits: + memory: 10M networks: monitor: