Skip to main content

Database Agent Metrics

The CodeXray Database Agent connects to each configured database on a cron cycle, runs engine-native diagnostic queries, and ships the results to the CodeXray backend. Metrics are organised by engine below — some are common, others engine-specific.

All metrics carry a service_name label (configured in the agent's YAML for each database) so you can distinguish multiple instances of the same engine in the UI.


Common to All Engines​

MetricTypeDescription
db_availabilityGauge1 if the database is reachable, 0 otherwise
total_queries_executedCounterTotal queries executed since the last polling cycle
query_execution_timeGaugeMean query execution time across the window
total_connectionsGaugeCurrently open connections
active_connectionsGaugeConnections currently doing work
inactive_connectionsGaugeConnections sitting idle
cpu_usageGaugeDatabase-reported CPU usage percentage
memory_usageGaugeDatabase-reported memory usage
total_memory_gb / available_memory_gbGaugeHost-side memory (total and free) as seen by the engine
db_countGaugeNumber of databases managed by this instance
db_users_countGaugeNumber of users / logins
network_bytes_sent / network_bytes_receivedCounterNetwork I/O at the engine level
read_iops / write_iopsGaugeRead/write operations per second
read_throughput / write_throughputGaugeRead/write throughput
read_latency_ms / write_latency_msGaugePer-operation latency
outstanding_disk_io_requestsGaugeQueued I/O requests at the engine layer
disk_size_usedGaugeUsed disk space

Slow-query stream​

For every poll cycle, the agent emits the top N slow queries (queryLimit in the config, default 10) as individual records with:

  • query_text — the query fingerprint
  • query_exec_time — execution time for this sample
  • query_process_id — engine-assigned process ID
  • query_start_timestamp / query_current_timestamp — session timing

The backend aggregates these into the Top Queries view on each database's Advanced Database Monitoring page.


PostgreSQL (type: PG)​

Native source: pg_stat_* views + optional pg_stat_statements extension.

Activity​

MetricDescription
transactions_totalTotal transactions
transactions_committed / transactions_rolled_backCommit / rollback counts
sessionsSessions opened
sessions_abandoned / sessions_fatal / sessions_killedSession termination reasons
rows_inserted / rows_updated / rows_deleted / rows_fetched / rows_returnedRow activity per poll window
query_calls_totalTotal query calls (from pg_stat_statements if installed)
query_exec_time_ms_totalCumulative exec time (from pg_stat_statements if installed)

Cache & buffer state​

MetricDescription
buffer_hitsShared buffer hits
block_readsBlocks read from disk
shared_buffersCurrent shared_buffers setting
effective_cache_sizeCurrent effective_cache_size setting
shared_memory_sizeAllocated shared memory
segment_sizeWAL segment size
cpu_operator_costPlanner cost constant

Locks, waits, and cancellations​

MetricDescription
queries_canceled_due_to_pinned_buffers
queries_canceled_due_to_deadlocks
queries_canceled_due_to_lock_timeouts
queries_canceled_due_to_old_snapshots
queries_canceled_due_to_dropped_tablespaces
deadlock_detectedPer-query deadlock flag

Storage & replication​

MetricDescription
total_db_sizeTotal DB size
pg_disk_nameDisk name label
pg_disk_size_totalTotal disk size
replication_countNumber of replication slots / standby count

Host​

MetricDescription
os_type / os_name / os_arch / os_versionHost OS info
db_versionserver_version (PG version)

MySQL (type: MY)​

Native source: performance_schema + INFORMATION_SCHEMA + SHOW STATUS counters.

Activity​

MetricDescription
total_queries_executedTotal queries in window
query_exec_timeAvg exec time
queries_per_secondLive QPS
transactions_total / transactions_committed / transactions_rolled_backTransaction counts
rows_inserted / rows_updated / rows_deleted / rows_fetchedRow operations

InnoDB​

MetricDescription
innodb_buffer_pool_sizeBuffer pool size
innodb_buffer_pool_hitsBuffer pool hits
innodb_buffer_pool_readsReads that missed the buffer pool
innodb_row_lock_waitsRow lock waits
innodb_deadlocksDetected deadlocks
innodb_log_sizeRedo log size

Replication​

MetricDescription
slave_running0/1 replication is running
slave_seconds_behind_masterReplication lag
semisync_enabled0/1 semi-sync replication on

Connection​

MetricDescription
max_connectionsConfigured limit
threads_connectedCurrent connection count
threads_runningActive connections
aborted_connectsFailed connection attempts

MSSQL / SQL Server (type: MS)​

Native source: Dynamic Management Views (sys.dm_*).

Activity​

MetricDescription
batch_requests_per_secBatch requests per second
transactions_per_secTransactions per second
active_sessionsCurrently connected sessions
blocked_processesProcesses blocked on locks

Buffer & cache​

MetricDescription
buffer_cache_hit_ratioPercentage of pages served from cache
page_life_expectancySeconds a page stays in buffer pool
memory_grants_pendingQueries waiting for memory
plan_cache_hit_ratioQuery plan cache hit rate

Locks & waits​

MetricDescription
lock_waits_per_secLock wait events per second
lock_requests_per_secLock requests per second
avg_wait_time_msAverage wait time across all wait types
deadlocks_per_secDeadlocks per second

I/O​

MetricDescription
io_read_latency_ms / io_write_latency_msPer-database file I/O latency
io_stalls_totalCumulative I/O stall time
log_flush_waits_per_secLog flush waits

MongoDB​

Native source: db.serverStatus(), db.currentOp().

Operations​

MetricDescription
ops_insert / ops_query / ops_update / ops_delete / ops_getmore / ops_commandPer-operation-type counters
active_connections / available_connectionsConnection pool state
current_clients_total / current_clients_reading / current_clients_writingClients by state

Memory & storage​

MetricDescription
mem_resident_mb / mem_virtual_mbProcess memory
wiredtiger_cache_bytesWiredTiger cache in use
wiredtiger_cache_dirty_bytesDirty pages
collections_count / indexes_countSchema shape

Replication​

MetricDescription
replset_stateReplica set member state
replset_lag_secondsReplication lag
oplog_size_bytesOpLog size

Oracle (type: OR)​

Native source: V$ performance views (AWR-style).

Activity​

MetricDescription
active_sessions / inactive_sessionsSession counts by state
transactions_per_secTransactions per second
executions_per_secSQL executions per second
parses_per_sec / hard_parses_per_secParse activity

Cache & memory​

MetricDescription
buffer_cache_hit_ratioDB cache hit ratio
library_cache_hit_ratioShared pool hit ratio
sga_size_bytes / pga_size_bytesMemory area sizes
redo_size_per_secRedo generation rate

Waits​

MetricDescription
top_wait_event_time_msTime spent in the top wait event
log_file_sync_avg_msLog file sync latency (commit latency)
db_file_read_avg_msPhysical read latency

Cassandra​

Native source: system keyspace + JMX-style runtime metrics.

MetricDescription
read_latency_microseconds / write_latency_microsecondsPer-operation latency
read_rate_per_sec / write_rate_per_secOperation rate
pending_compactionsPending compaction tasks
pending_flushesPending memtable flushes
cache_hit_rate_percentRow cache hit rate
timeouts_per_secOperation timeouts
dropped_mutations_per_secDrops under load
disk_load_bytesData size per node

Couchbase (type: CB)​

Native source: Cluster REST API.

MetricDescription
bucket_ops_per_secOperations per second per bucket
bucket_cache_hit_rate_percentCache hit rate
bucket_memory_used_bytesRAM used per bucket
bucket_item_countItems per bucket
disk_write_queue_lengthPending writes to disk
replica_queue_lengthPending replica replication
xdcr_replications_activeActive cross-datacenter replication streams

Metric Naming Note​

Metric names in CodeXray's UI may differ slightly from the native engine view names — the agent normalises into a consistent schema before emission. Use the Advanced Database Monitoring views in the UI as the source of truth for what's available per engine in your deployment.


Next Steps​