Bug 54679 - Prometheus не отображает метрки от prometheus-json_exporter
Summary: Prometheus не отображает метрки от prometheus-json_exporter
Status: REOPENED
Alias: None
Product: Sisyphus
Classification: Development
Component: prometheus-json_exporter (show other bugs)
Version: unstable
Hardware: x86_64 Linux
: P5 normal
Assignee: Andrey Cherepanov
QA Contact: qa-sisyphus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-06-05 11:48 MSK by Olga
Modified: 2025-09-12 18:13 MSK (History)
2 users (show)

See Also:


Attachments
Метрики в prometheus/graph (47.98 KB, image/png)
2025-06-09 12:07 MSK, Olga
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Olga 2025-06-05 11:48:28 MSK
Версия программы:
=================
prometheus-json_exporter-0.7.0-alt2

Стенды с ошибкой, обновлен. до Sisyphus:
========================================
Alt Workstation 11

Шаги, приводящие к ошибке:
==========================
1. Установить пакеты prometheus-json_exporter, prometheus:
#  apt-get install prometheus-json_exporter prometheus
2. Добавить json_exporter в prometheus:
#  echo "
  - job_name: 'json_exporter'
    static_configs:
      - targets: ['localhost:7979']  # URL экспортера
     " >> /etc/prometheus/prometheus.yml
3. Запустить сервис prometheus и проверить статус:
# systemctl enable --now prometheus && sleep 5 && systemctl status prometheus
4. Создать конфиг для json_exporter
# vim /etc/prometheus/json_exporter.yml: 
modules:
  default:
    metrics:
      - name: "service_status"
        path: "{.status}"
        help: "Service health status (1=healthy, 0=unhealthy)"
        value_type: gauge
      - name: users_online
        path: "{.users_online}"
        help: "Number of active users"
        value_type: counter
5. Добавить конфиг в сервис prometheus-json_exporter и запустить его:
# vim /lib/systemd/system/prometheus-json_exporter.service: 
ExecStart=/usr/bin/json_exporter --web.systemd-socket $OPTIONS 
-> ExecStart=/usr/bin/json_exporter --config.file /etc/prometheus/json_exporter.yml
# systemctl enable --now prometheus-json_exporter && sleep 5 && systemctl status prometheus-json_exporter
json_exporter можно запустить еще так:
# json_exporter --config.file /etc/prometheus/json_exporter.yml
6. Запустить тестовый HTTP-сервер:
# python3 -m http.server 8002 & echo '{"status": 1, "users_online": 42}' > test.json
7. Выполнить запрос 
# curl "http://localhost:7979/probe?target=http://localhost:8002/test.json"
8. Проверить метрики :
# curl http://localhost:7979/metrics | grep -E "service_status|users_online"

Ожидаемый результат:
====================
Вывод метрик из prometheus

Фактический результат:
======================
Метрики не отображаются в prometheus:
# curl http://localhost:7979/metrics | grep -E "service_status|users_online"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  9880    0  9880    0     0  2846k      0 --:--:-- --:--:-- --:--:-- 3216k
При выполнении запроса # curl "http://localhost:7979/probe?target=http://localhost:8002/test.json", следующий вывод:
# HELP service_status Service health status (1=healthy, 0=unhealthy)
# TYPE service_status untyped
service_status 1
# HELP users_online Number of active users
# TYPE users_online untyped
users_online 42
Comment 1 Olga 2025-06-09 12:07:07 MSK
Created attachment 18807 [details]
Метрики в prometheus/graph

После того, как поменяла конфиг prometheus для добавления json_exporter на:
 - job_name: 'json_exporter'
   metrics_path: /probe
   static_configs:
     - targets: #['localhost:8000']  # URL экспортера
       - http://localhost:8000/test.json
   relabel_configs:
     - source_labels: [__address__]
       target_label: __param_target
     - source_labels: [__param_target]
       target_label: instance
     - target_label: __address__
       replacement: localhost:7979
Стали отображаться метрики в http://localhost:9090/graph (См. Вложение)
Но на http://localhost:7979/metrics по прежнему не отображаются
Comment 2 Repository Robot 2025-08-24 12:14:49 MSK
prometheus-json_exporter-0.7.0-alt3 -> sisyphus:

Sun Aug 24 2025 Andrey Cherepanov <cas@altlinux> 0.7.0-alt3
- Removed socket file, fixed service file (ALT #54679).
- Set program version.
Comment 3 Куницкий Дмитрий 2025-09-12 18:13:30 MSK
Версия пакета: prometheus-json_exporter-0.7.0-alt3.x86_64

Ошибка актуальна