Skip to main content
Version: Next

Metrics

Dgraph database provides metrics on Dgraph instance activity, disk activity, server node health, memory, and Raft leadership. It also provides built-in metrics provided by Go. Dgraph metrics follow the metric and label conventions for the Prometheus monitoring and alerting toolkit.

Activity Metrics

Activity metrics let you track the mutations, queries, and proposals of a Dgraph instance.

MetricDescription
go_goroutinesTotal number of Goroutines currently running in Dgraph.
dgraph_active_mutations_totalTotal number of mutations currently running.
dgraph_pending_proposals_totalTotal pending Raft proposals.
dgraph_pending_queries_totalTotal number of queries in progress.
dgraph_num_queries_total{method="Server.Mutate"}Total number of mutations run in Dgraph.
dgraph_num_queries_total{method="Server.Query"}Total number of queries run in Dgraph.

Disk metrics

Disk metrics let you track the disk activity of the Dgraph process. Dgraph does not interact directly with the filesystem. Instead it relies on Badger to read from and write to disk.

MetricDescription
badger_read_num_vlogTotal count of reads by badger in vlog,
badger_write_num_vlogTotal count of writes by Badger in vlog,
badger_read_bytes_vlogTotal bytes read by Badger,
badger_write_bytes_vlogTotal bytes written by Badger,
badger_read_bytes_lsmTotal bytes read by Badger,
badger_write_bytes_l0Total bytes written by Badger,
badger_write_bytes_compactionTotal bytes written by Badger,
badger_get_num_lsmTotal count of LSM gets,
badger_get_num_memtableTotal count of LSM gets from memtable,
badger_hit_num_lsm_bloom_filterTotal count of LSM bloom hits,
badger_get_num_userTotal count of calls to Badger's get,
badger_put_num_userTotal count of calls to Badger's put,
badger_write_bytes_userTotal bytes written by user,
badger_get_with_result_num_userTotal count of calls to Badger's get that returned value,
badger_iterator_num_userTotal count of iterators made in badger,
badger_size_bytes_lsmSize of the LSM in bytes,
badger_size_bytes_vlogSize of the value log in bytes,
badger_write_pending_num_memtableTotal count of pending writes,
badger_compaction_current_num_lsmNumber of tables being actively compacted,

Old Metrics (Pre 23.1.0)

badger_disk_reads_total | Total count of disk reads in Badger. badger_disk_writes_total | Total count of disk writes in Badger. badger_gets_total | Total count of calls to Badger's get. badger_memtable_gets_total | Total count of memtable accesses to Badger's get. badger_puts_total | Total count of calls to Badger's put. badger_read_bytes | Total bytes read from Badger. badger_lsm_bloom_hits_total | Total number of LSM tree bloom hits. badger_written_bytes | Total bytes written to Badger. badger_lsm_size_bytes | Total size in bytes of the LSM tree. badger_vlog_size_bytes | Total size in bytes of the value log.

Go Metrics

Go's built-in metrics may also be useful to measure memory usage and garbage collection time.

MetricDescription
go_memstats_gc_cpu_fractionThe fraction of this program's available CPU time used by the GC since the program started.
go_memstats_heap_idle_bytesNumber of heap bytes waiting to be used.
go_memstats_heap_inuse_bytesNumber of heap bytes that are in use.

Health Metrics

Health metrics let you check the health of a server node.

note

Health metrics are only available for Dgraph Alpha server nodes.

MetricDescription
dgraph_alpha_health_statusValue is 1 when the Alpha node is ready to accept requests; otherwise 0.
dgraph_max_assigned_tsThis shows the latest max assigned timestamp. All Alpha nodes within the same Alpha group should show the same timestamp if they are in sync.
dgraph_txn_aborts_totalShows the total number of server-initiated transaction aborts that have occurred on the Alpha node.
dgraph_txn_commits_totalShows the total number of successful commits that have occurred on the Alpha node.
dgraph_txn_discards_totalShows the total number of client-initiated transaction discards that have occurred on the Alpha node. This is incremented when the client calls for a transaction discard, such as using the Dgraph Go client's txn.Discard function.

Memory metrics

Memory metrics let you track the memory usage of the Dgraph process. The idle and inuse metrics give you a better sense of the active memory usage of the Dgraph process. The process memory metric shows the memory usage as measured by the operating system.

By looking at all three metrics you can see how much memory a Dgraph process is holding from the operating system and how much is actively in use.

MetricDescription
dgraph_memory_idle_bytesEstimated amount of memory that is being held idle that could be reclaimed by the OS.
dgraph_memory_inuse_bytesTotal memory usage in bytes (sum of heap usage and stack usage).
dgraph_memory_proc_bytesTotal memory usage in bytes of the Dgraph process. This metric is equivalent to resident set size on Linux.

Raft leadership metrics

Raft leadership metrics let you track changes in Raft leadership for Dgraph Alpha and Dgraph Zero nodes in your Cluster. These metrics include a group label along with the node name, so that you can determine which metrics apply to which Raft groups.

MetricDescription
dgraph_raft_has_leaderValue is 1 when the node has a leader; otherwise 0.
dgraph_raft_is_leaderValue is 1 when the node is the leader of its group; otherwise 0.
dgraph_raft_leader_changes_totalThe total number of leader changes seen by this node.