# Использование Prometheus в двухконтейнерной конфигурации

**URL:** https://meta.discourse.org/t/using-prometheous-with-the-two-container-setup/265021
**Category:** Self-hosting
**Tags:** prometheus
**Created:** [02.Март.2021 21:04:51 UTC](https://meta.discourse.org/t/using-prometheous-with-the-two-container-setup/265021 "2021-03-02T21:04:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![dschaper](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dschaper/32/209535_2.png) [@dschaper](https://meta.discourse.org/u/dschaper)
#### Post date: [02.Март.2021 21:04:51 UTC](https://meta.discourse.org/t/using-prometheous-with-the-two-container-setup/265021/1 "2021-03-02T21:04:51Z")

</div>

Нужно ли внести какие-либо изменения в настройку для использования конфигурации с несколькими контейнерами, где Redis и PostgreSQL вынесены в `data`, а остальное — в `web_only`? Я добавил плагин только в конфигурацию контейнера `web_only`.

Официальная панель управления настроена в Grafana, но показатели `Redis RSS` и `Postgres Size` отображаются как `N/A`.

_Показатели `Container CPU usage` и `Container Memory Usage` отсутствуют (`No data`), но это может быть связано с отсутствием `cadvisor` на хосте?_

Мой YAML:

```yaml
  - job_name: 'discourse_prometheus'
    scrape_interval: 1s
    metrics_path: /metrics
    scheme: https
    static_configs:
      - targets: ['<redact>:443']

```

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [02.Март.2021 21:31:59 UTC](https://meta.discourse.org/t/using-prometheous-with-the-two-container-setup/265021/2 "2021-03-02T21:31:59Z")

</div>

Это кажется правильным — в bash символ `$` нужно экранировать.

---

<div class="post-metadata">

### Author: ![dschaper](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dschaper/32/209535_2.png) [@dschaper](https://meta.discourse.org/u/dschaper)
#### Post date: [02.Март.2021 21:49:35 UTC](https://meta.discourse.org/t/using-prometheous-with-the-two-container-setup/265021/3 "2021-03-02T21:49:35Z")

</div>

Не обязательно, но, полагаю, это зависит от того, что вы используете для сравнения с помощью регулярных выражений.

```bash
#!/usr/bin/env bash

TARGET="10.20.20.5"
TARGET2="10.20.20.50"

if [["^10.20.20.5$" =~ $TARGET]]; then
        echo "TARGET Matched Non-escaped"
fi

if [["^10.20.20.5\$" =~ $TARGET]]; then
        echo "TARGET Matched escaped"
fi

if [["^10.20.20.5$" =~ $TARGET2]]; then
        echo "TARGET2 Matched Non-escaped"
fi

if [["^10.20.20.5\$" =~ $TARGET2]]; then
        echo "TARGET2 Matched escaped"
fi

```

```bash
+ TARGET=10.20.20.5
+ TARGET2=10.20.20.50
+ [[^10.20.20.5$ =~ 10.20.20.5]]
+ echo 'TARGET Matched Non-escaped'
TARGET Matched Non-escaped
+ [[^10.20.20.5$ =~ 10.20.20.5]]
+ echo 'TARGET Matched escaped'
TARGET Matched escaped
+ [[^10.20.20.5$ =~ 10.20.20.50]]
+ [[^10.20.20.5$ =~ 10.20.20.50]]

```
