From 7b761bc2c9b87b019998c87239e2e0b9a4211b2c Mon Sep 17 00:00:00 2001 From: Martin Migasiewicz <616250+martinm82@users.noreply.github.com> Date: Wed, 22 Jun 2022 20:34:18 +0200 Subject: [PATCH] feat: add example how to use nginx to avoid overloading Artifactory by scraping data by Prometheus. (#79) --- README.md | 13 ++++++++++++- docker-compose.yml | 30 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 docker-compose.yml diff --git a/README.md b/README.md index 5ada3fd..ed5a8be 100755 --- a/README.md +++ b/README.md @@ -35,12 +35,23 @@ $ ./artifactory_exporter ### Docker Set the credentials in `env_file_name` and you can deploy this exporter using the [peimanja/artifactory_exporter](https://registry.hub.docker.com/r/peimanja/artifactory_exporter/) Docker image: -: ```bash $ docker run --env-file=env_file_name -p 9531:9531 peimanja/artifactory_exporter:latest ``` +### Docker Compose + +Running the exporter against an Artifactory instance with millions of artifacts will cause performance issues in case Prometheus will scrape too often. + +To avoid such situations you can run nginx in front of the exporter and use it as a cache. The Artifactory responses will be cached in nginx and kept valid for `PROXY_CACHE_VALID` seconds. After that time any new request from Prometheus will re-request metrics from Artifactory and store again in the nginx cache. + +Set the credentials in an environment file as described in the *Docker* section and store the file as `.env` next to `docker-compose.yml` and run the following command: + +```bash +docker-compose up -d +``` + ## Install with Helm [Helm](https://helm.sh) must be installed to use the charts. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3673bab --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,30 @@ +version: "3.8" + +services: + autoheal: + image: willfarrell/autoheal:latest + restart: always + volumes: + - '/var/run/docker.sock:/var/run/docker.sock' + + proxy: + depends_on: + - exporter + image: decentralize/caching-proxy + restart: always + environment: + UPSTREAM: "http://exporter:9531" + MAX_SIZE: "100m" + PROXY_READ_TIMEOUT: "2400s" + PROXY_CACHE_VALID: "60s" + ports: + - 8088:80/tcp + + exporter: + image: peimanja/artifactory_exporter + restart: always + ports: + - 9531:9531 + command: --log.level=debug + env_file: + - .env