From 391abe42adf3bf065d9543ada068b696b00efdcd Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Fri, 24 Feb 2023 00:49:12 -0800 Subject: deploy: add krakend monitoring using influxdb and grafana --- contrib/docker-compose.yaml | 27 ++++++++++++++++++++++++++- contrib/influx/initdb.sh | 16 ++++++++++++++++ contrib/krakend.json | 20 +++++++------------- 3 files changed, 49 insertions(+), 14 deletions(-) create mode 100755 contrib/influx/initdb.sh (limited to 'contrib') diff --git a/contrib/docker-compose.yaml b/contrib/docker-compose.yaml index 3ca7981..8aeaff8 100644 --- a/contrib/docker-compose.yaml +++ b/contrib/docker-compose.yaml @@ -10,7 +10,7 @@ services: - "8080:8080" krakend: - image: "devopsfaith/krakend:latest" + image: "devopsfaith/krakend:2.2" restart: always ports: - "8081:8080" @@ -18,5 +18,30 @@ services: volumes: - "./krakend.json:/etc/krakend/krakend.json" + influx: + image: influxdb:2.6.1 + environment: + - "DOCKER_INFLUXDB_INIT_MODE=setup" + - "DOCKER_INFLUXDB_INIT_USERNAME=krakend" + - "DOCKER_INFLUXDB_INIT_PASSWORD=password" + - "DOCKER_INFLUXDB_INIT_ORG=my-org" + - "DOCKER_INFLUXDB_INIT_BUCKET=krakend" + - "DOCKER_INFLUXDB_INIT_RETENTION=1w" + - "DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=my-super-secret-auth-token" + ports: + - "8086:8086" + volumes: + - "./influx/initdb.sh:/docker-entrypoint-initdb.d/initdb.sh" + + grafana: + image: "grafana/grafana:9.3.6" + restart: always + ports: + - "3000:3000" + volumes: + - grafana:/var/lib/grafana + volumes: sqlite3: + grafana: + influxdb: diff --git a/contrib/influx/initdb.sh b/contrib/influx/initdb.sh new file mode 100755 index 0000000..b1d07af --- /dev/null +++ b/contrib/influx/initdb.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# The following script creates the authentication for Grafana +# and is meant to be added to InfluxDB docker-compose.yml file. +# image: influxdb +# volumes: +# - "./config/influx:/docker-entrypoint-initdb.d" +set -e + +# Retrieve the ID from the bucket created during setup +BUCKET_ID=$(influx bucket list | grep "$DOCKER_INFLUXDB_INIT_BUCKET" | awk '{print $1}') + +influx v1 auth create \ + --username ${DOCKER_INFLUXDB_INIT_USERNAME} \ + --password ${DOCKER_INFLUXDB_INIT_PASSWORD} \ + --write-bucket ${BUCKET_ID} \ + --org ${DOCKER_INFLUXDB_INIT_ORG} diff --git a/contrib/krakend.json b/contrib/krakend.json index 1f89340..2ed23d8 100644 --- a/contrib/krakend.json +++ b/contrib/krakend.json @@ -3,19 +3,13 @@ "version": 3, "name": "Checkin.bot API", "extra_config": { - "telemetry/opencensus": { - "sample_rate": 100, - "reporting_period": 0, - "exporters": { - "prometheus": { - "port": 9091, - "namespace": "krakend", - "tag_host": false, - "tag_path": true, - "tag_method": true, - "tag_statuscode": false - } - } + "telemetry/influx": { + "address": "http://influx:8086", + "ttl": "25s", + "buffer_size": 100, + "db": "krakend", + "username": "krakend", + "password": "password" }, "telemetry/metrics": { "collection_time": "60s", -- cgit v1.2.3