Metrics

From Svacer Wiki
Revision as of 17:49, 28 November 2025 by Akuzmin (talk | contribs) (add new metrics)

(diff) ← Older revision | Approved revision (diff) | Latest revision (diff) | Newer revision → (diff)

Включение метрик

Для включения метрик запустите сервер Svacer с переменной окружения SVACER_TRACE_OPTIONS=prom_metrics_on

SVACER_TRACE_OPTIONS=prom_metrics_on svacer-server run

После этого метрики будут доступны по URL вашего сервера на /api/metrics

http://localhost:8080/api/metrics

Список метрик

Название Описание
svacer_active_imports Number of active imports of svace/sarif results
svacer_active_pdf_exports Number of active pdf export tasks
svacer_active_snapshot_exports Number of active snapshot exports
svacer_active_snapshot_imports Number of active snapshot imports
svacer_comment_changes_since_start The total number of comment additions/deletions/modifications since start
svacer_import_results_since_start The total number of imported results since last server start
svacer_import_snapshots_since_start The total number of imported snapshots since last server start
svacer_object_store_read_ampl The current read amplification of the database. It's computed as the number of sublevels in L0 + the number of non-empty levels below L0
svacer_object_store_size Approximate size of the object store
svacer_object_store_vsize VirtualSize is the sum of the sizes of the virtual sstables in the latest version. BackingTableSize - VirtualSize gives an estimate for the space amplification caused by not compacting virtual sstables
svacer_pgxpool_acquire_count Cumulative count of successful acquires from the pool
svacer_pgxpool_acquire_duration_ns Total duration of all successful acquires from the pool in nanoseconds
svacer_pgxpool_acquired_conns Number of currently acquired connections in the pool
svacer_pgxpool_canceled_acquire_count Cumulative count of acquires from the pool that were canceled by a context
svacer_pgxpool_constructing_conns Number of conns with construction in progress in the pool
svacer_pgxpool_empty_acquire Cumulative count of successful acquires from the pool that waited for a resource to be released or constructed because the pool was empty
svacer_pgxpool_idle_conns Number of currently idle conns in the pool
svacer_pgxpool_max_conns Maximum size of the pool
svacer_pgxpool_max_idle_destroy_count Cumulative count of connections destroyed because they exceeded MaxConnIdleTime
svacer_pgxpool_max_lifetime_destroy_count Cumulative count of connections destroyed because they exceeded MaxConnLifetime
svacer_pgxpool_new_conns_count Cumulative count of new connections opened
svacer_pgxpool_total_conns Total number of resources currently in the pool. The value is the sum of ConstructingConns, AcquiredConns, and IdleConns
svacer_rest_import_sarif The total number of import sarif requests via REST endpoint
svacer_rest_import_sarif_failed The total number of failed import sarif requests via REST endpoint
svacer_rest_import_sarif_success The total number of success import sarif requests via REST endpoint
svacer_rest_import_svace_dirs The total number of import svace dir requests via REST endpoint
svacer_rest_import_svace_dirs_failed The total number of failed import svace dir requests via REST endpoint
svacer_rest_import_svace_dirs_success The total number of success import svace dir requests via REST endpoint
svacer_rest_num_tokens_issued The total number of login tokens issued
svacer_rest_num_tokens_removed The total number of login tokens removed
svacer_review_changes_since_start The total number of review modifications since start
svacer_total_branches_count Total number of branches on server
svacer_total_ldap_users_count Total number of LDAP users on server
svacer_total_projects_count Total number of projects on server
svacer_total_snapshots_count Total number of projects on server
svacer_total_users_count Total number of non-LDAP users on server
svacer_wsocket_sessions_counter The total number of active web socket connections

Добавление в Prometheus

Для сбора метрик Прометеусом добавьте в его конфиг-файл /etc/prometheus/prometheus.yml подобную запись, поменяв название, хост и порт на те что у вас

- job_name: svacer-metrics-example
  metrics_path: /api/metrics
  static_configs:
    - targets: ['svacer.ispras.ru:8080']

Grafana dashboard

Для визуализации метрик в Grafana импортируете dashboard из файла grafana-dashboard-svacer.json. В диалоге импорта выберите собирающий метрики Prometheus в качестве data source.