From 4e391a5e396a1780e2056d8c62653f9e3b12b822 Mon Sep 17 00:00:00 2001 From: Artem Navoiev Date: Sat, 7 Nov 2020 17:00:23 +0200 Subject: [PATCH] [deployment] add vmalert + alertmanager to docker compose (#885) --- deployment/docker/alerts.yml | 23 +++++++++++++++++++++ deployment/docker/docker-compose.yml | 30 ++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 deployment/docker/alerts.yml diff --git a/deployment/docker/alerts.yml b/deployment/docker/alerts.yml new file mode 100644 index 000000000..1d2e3398e --- /dev/null +++ b/deployment/docker/alerts.yml @@ -0,0 +1,23 @@ +groups: + - name: groupGorSingleAlert + rules: + - alert: VMRows + for: 10s + expr: vm_rows > 0 + labels: + label: bar + host: "{{ $labels.instance }}" + annotations: + summary: "{{ $value|humanize }}" + description: "{{$labels}}" + - name: TestGroup + rules: + - alert: Conns + expr: sum(vm_tcplistener_conns) by(instance) > 1 + for: 5s + annotations: + summary: "Too high connection number for {{$labels.instance}}" + description: "It is {{ $value }} connections for {{$labels.instance}}" + - alert: ExampleAlertAlwaysFiring + expr: sum by(job) + (up == 1) diff --git a/deployment/docker/docker-compose.yml b/deployment/docker/docker-compose.yml index 8ccab8569..fc1e4f115 100644 --- a/deployment/docker/docker-compose.yml +++ b/deployment/docker/docker-compose.yml @@ -52,6 +52,36 @@ services: networks: - vm_net restart: always + vmalert: + container_name: vmalert + image: victoriametrics/vmalert + depends_on: + - "victoriametrics" + - "alertmanager" + ports: + - 8880:8880 + volumes: + - ./alerts.yml:/etc/alerts/alerts.yml + command: + - '--datasource.url=http://victoriametrics:8428/' + - '--remoteRead.url=http://victoriametrics:8428/' + - '--remoteWrite.url=http://victoriametrics:8428/' + - '--notifier.url=http://alertmanager:9093/' + - '--rule=/etc/alerts/*.yml' + # display source of alerts in grafana + - '-external.url=http://127.0.0.1:3000' #grafana outside container + - '--external.alert.source=explore?orgId=1&left=["now-1h","now","VictoriaMetrics",{"expr":"{{$$expr|quotesEscape|pathEscape}}"},{"mode":"Metrics"},{"ui":[true,true,true,"none"]}]' ## when copypaste the line be aware of '$$' for escaping in '$expr' + networks: + - vm_net + restart: always + alertmanager: + container_name: alertmanager + image: prom/alertmanager + ports: + - 9093:9093 + networks: + - vm_net + restart: always volumes: vmagentdata: {} vmdata: {}