2016-11-21 6 views
1

У меня есть каддизор с портфолио 4000: 8080, и мне нужно связать его с контейнером с прометеем.Docker - Контейнер Prometheus сразу же умирает

Мой prometheus.yml является:

scrape_configs: 
# Scrape Prometheus itself every 2 seconds. 
- job_name: 'prometheus' 
    scrape_interval: 2s 
    target_groups: 
    - targets: ['localhost:9090', 'cadvisor:8080'] 

Этот файл имеет путь /home/test/prometheus.yml. Чтобы запустить контейнер с Прометеем, я:

docker run -d -p 42047:9090 --name=prometheus -v /home/test/prometheus.yml:/etc/prometheus/prometheus.yml --link cadvisor:cadvisor prom/prometheus -config.file=/etc/prometheus/prometheus.yml -storage.local.path=/prometheus -storage.local.memory-chunks=10000 

Контейнер создается, но он немедленно умирает. Можете ли вы сказать мне, где проблема?

Сообщения образуют docker events&:

2016-11-21T11:43:04.922819454+01:00 container start 69d03c68525c5955cc40757dc973073403b13fdd41c7533f43b7238191088a25 (image=prom/prometheus, name=prometheus) 
2016-11-21T11:43:05.152141981+01:00 container die 69d03c68525c5955cc40757dc973073403b13fdd41c7533f43b7238191088a25 (exitCode=1, image=prom/prometheus, name=prometheus) 

ответ

1

Отступ не является правильным, попробуйте:

scrape_configs: 
    # Scrape Prometheus itself every 2 seconds. 
    - job_name: 'prometheus' 
    scrape_interval: 2s 
    target_groups: 
    - targets: ['localhost:9090', 'cadvisor:8080'] 
+0

все еще не работает. – SegFault

+1

Какая версия Прометея вы используете? 'target_groups' было переименовано в' static_configs' некоторое время назад. Это очень сложно отладить без каких-либо ошибок. –

+0

Я сделал «docker pull prom/prometheus», поэтому я думаю, что он должен быть последним (TAG изображения «последний») – SegFault

3

Я думаю target_groups устарели из scrape_configs в последней версии Прометея. вы можете попробовать static_configs или file_sd_config

scrape_config
static_config
file_sd_config

scrape_configs: 
    - job_name: node_exporter 
    static_configs: 
     - targets: 
     - "stg-elk-app-01:9100" 
     - "stg-app-02:9100" 
3

Формат конфигурации изменяется. цели находятся под static_config в последней версии.

scrape_configs: 
# Scrape Prometheus itself every 2 seconds. 
    - job_name: 'prometheus' 
    scrape_interval: 2s 
    static_configs: 
     - targets: ['localhost:9090', 'cadvisor:8080'] 

Prometheus Documentation for further help

0

Имя контейнера prometheus.

Как правило, когда контейнер существует сразу после его запуска, я бы рекомендовал добавить -log.level=debug сразу после -config.file.

docker run -d -p 42047:9090 --name=prometheus -v /home/test/prometheus.yml:/etc/prometheus/prometheus.yml --link cadvisor:cadvisor prom/prometheus -config.file=/etc/prometheus/prometheus.yml -log.level=debug -storage.local.path=/prometheus -storage.local.memory-chunks=10000

Далее см журналы для контейнера:

docker logs prometheus

Любые проблемы с конфигурацией будет.

0

Как вы сказали в своем ранее комментарий:

from logs: time="2016-11-21T11:21:40Z" level=error msg="Error loading config: couldn't load configuration (-config.file=/etc/prometheus/prometheus.yml): unknown fields in scrape_config: target_groups" source="main.go:149"

Что ясно означает, что поле «target_groups» вызывает проблему. Это связано с тем, что новая версия Prometheus (версия 1.5) отменила использование поля «target_groups» и просто обеспечила цели. Даже я столкнулся с этим вопросом около 6 месяцев назад. Попробуйте его с новой версией. docker pull prom/prometheus может быть вам старым.

Надеюсь, что это поможет ... !!!

2

Да, target_groups переименован в static_configs. Пожалуйста, используйте последнее изображение Прометея со следующим.

static_configs: 
    - targets: ['localhost:9090', 'cadvisor:8080'] 

Выше работал для меня.