Monitoring
Monitoring applications and databases is essential to track the load and resources used by the system.
Memgraph currently supports:
- Real-time logs tracking via WebSocket server: Log tracking is helpful for debugging purposes and monitoring the database operations.
- Metrics tracking via HTTP server (Enterprise Edition): In the Enterprise edition, besides log tracking, Memgraph allows tracking information about transactions, query latencies, types of queries executed, snapshot recovery latencies, triggers, TTL data, Bolt messages, indexes, streams, memory, operators and sessions. There are also many metrics which are trying to describe the state of high availability. These include metrics which describe latencies of RPC messages, time needed to perform a failover and counters for events occurring throughout the lifetime of HA Memgraph.
- Session trace: Profile the execution of all queries within a session to identify performance bottlenecks.
For deeper troubleshooting — including profiling with perf, capturing core
dumps, and GDB workflows — see the Debugging
guide. If you run HA on Kubernetes, the K8s setup
guide covers init-container
diagnostics and uploading core dumps to S3.
Real-time logs tracking via WebSocket server
Connect to Memgraph’s logging server via WebSocket to forward logs to all the connected clients.
Log messages
Each log that is written to the log file is forwarded to the connected clients in the following format:
{
event: "log",
level: "trace"|"debug"|"info"|"warning"|"error"|"critical",
message: "<log-message>"
}Connection
To connect to Memgraph’s WebSocket server, use the following URL:
ws://host:portThe default host is 0.0.0.0, but it can be changed using the
--monitoring-address= configuration flag.
The default port is 7444, but it can be changed using the --monitoring-port
configuration flag.
To connect to Memgraph’s WebSocket server using the default configuration and Python client, you can use the following code snippet:
import asyncio
import websockets
HOST = 'localhost'
PORT = '7444'
# The WebSocket URL
ws_url = f'ws://{HOST}:{PORT}'
async def read_logs():
async with websockets.connect(ws_url) as websocket:
print(f"Connected to Memgraph at {ws_url}")
try:
# Keep reading messages (logs) from the server
while True:
log_message = await websocket.recv()
print(log_message)
except websockets.exceptions.ConnectionClosed:
print("Connection to Memgraph closed.")
asyncio.run(read_logs())The code structure is similar in other languages, depending on the WebSocket library used.
If you want to connect with a WebSocket Secure (WSS) connection, set the
--bolt-cert-file and --bolt-key-file configuration flags to enable an SSL
connection. Refer to the configuration page to learn how to update the
configuration and to
see the list of all available configuration
flags.
Authentication
When authentication is not used due to no users present in Memgraph, no authentication message is expected, and no response will be returned.
When the authentication is used, Memgraph won’t send a message to a certain connection until it’s authenticated.
To authenticate, create a JSON with the credentials in the following format:
{
"username": "<username>",
"password": "<password>"
}If the credentials are valid, the connection will be made, and the client will receive the messages. As a response, the client should receive the following message:
{
"success": true,
"message": "User has been successfully authenticated!"
}If they are invalid or the first message is in an invalid format, the connection is dropped. As a response, the following message is sent:
{
"success": false,
"message": "<error-message>"
}To use WebSocket to authenticate, send the JSON message to the WebSocket server:
import asyncio
import json
import websockets
HOST = "localhost"
PORT = "7444"
USERNAME = "memgraph"
PASSWORD = "memgraph"
ws_url = f"ws://{HOST}:{PORT}"
async def authenticate_and_read_logs(websocket):
# Send authentication credentials
credentials = json.dumps({"username": USERNAME, "password": PASSWORD})
await websocket.send(credentials)
# Wait for authentication response
response = await websocket.recv()
response_data = json.loads(response)
if response_data.get("success"):
print("Authentication successful!")
else:
print(f"Authentication failed: {response_data.get('message')}")
return # Stop if authentication fails
# After successful authentication, start reading logs
try:
while True:
log_message = await websocket.recv()
print(log_message)
except websockets.exceptions.ConnectionClosed:
print("Connection to Memgraph closed.")
async def connect_and_authenticate():
async with websockets.connect(ws_url) as websocket:
print(f"Connected to Memgraph at {ws_url}")
await authenticate_and_read_logs(websocket)
asyncio.run(connect_and_authenticate())Authorization (Enterprise)
Permission for connecting through WebSocket is controlled by the WEBSOCKET
privilege.
Metrics tracking via HTTP server (Enterprise Edition)
In the Enterprise Edition, Memgraph allows tracking information about high availability, transactions, query latencies, snapshot recovery latencies, triggers, Bolt messages, indexes, constraints, streams, memory, operators and sessions, all by using an HTTP server.
To retrieve data from the HTTP server, enter a valid Memgraph Enterprise license key.
The default address and port for the metrics server is 0.0.0.0:9091, and can
be configured using the --metrics-address and --metrics-port configuration
flags.
Metrics format
The --metrics-format configuration
flag controls
the response format of the HTTP endpoint. The allowed values are:
OpenMetrics: Prometheus-compatible OpenMetrics text format (application/openmetrics-text). Metrics are labeled per-database. Any OpenMetrics compatible clients can connect directly to Memgraph to scrape metrics.JSON(default): A flat JSON object. TheJSONformat is deprecated. Using JSON with any OpenMetrics compatible client requires the Prometheus exporter middleware.
New deployments should use OpenMetrics, which enables direct Prometheus
scraping and provides per-database metric labels.
Per-database metrics
Most metrics are tracked per-database. In a multi-tenant setup, each database maintains its own counters, gauges, and histograms. How per-database metrics are exposed depends on the format — see the OpenMetrics and JSON sections below.
Session-related metrics (active sessions, Bolt messages) and high-availability metrics remain global — they are not scoped to any single database.
System metrics
All system metrics measuring different parts of the system can be divided into three different types:
- Gauge — a single value of some variable in the system (e.g. memory usage, active transaction count)
- Counter — a monotonically increasing value (e.g. total number of committed transactions)
- Histogram — distribution of measured values (e.g. query latency percentiles)
The metric names in the tables below use the OpenMetrics format. The deprecated
JSON endpoint and SHOW METRICS INFO use different names — see
JSON monitoring for details.
General metrics
| Name | Type | Description |
|---|---|---|
| memgraph_vertex_count | Gauge | Number of nodes stored in the database. |
| memgraph_edge_count | Gauge | Number of relationships stored in the database. |
| memgraph_disk_usage_bytes | Gauge | Disk space used by the database’s data directory (in bytes). |
| memgraph_memory_res_bytes | Gauge | RAM used by the Memgraph process as reported by the OS (in bytes). Reflects the resident set size, not the value used for license enforcement. |
| memgraph_peak_memory_res_bytes | Gauge | Peak RAM used by the Memgraph process (in bytes). |
Index metrics
| Name | Type | Description |
|---|---|---|
| memgraph_active_label_indices | Gauge | Number of active label indexes. |
| memgraph_active_label_property_indices | Gauge | Number of active label-property indexes. |
| memgraph_active_edge_type_indices | Gauge | Number of active edge-type indexes. |
| memgraph_active_edge_type_property_indices | Gauge | Number of active edge-type-property indexes. |
| memgraph_active_edge_property_indices | Gauge | Number of active edge-property indexes. |
| memgraph_active_point_indices | Gauge | Number of active point indexes. |
| memgraph_active_text_indices | Gauge | Number of active text indexes on vertices. |
| memgraph_active_text_edge_indices | Gauge | Number of active text indexes on edges. |
| memgraph_active_vector_indices | Gauge | Number of active vector indexes on vertices. |
| memgraph_active_vector_edge_indices | Gauge | Number of active vector indexes on edges. |
Constraint metrics
| Name | Type | Description |
|---|---|---|
| memgraph_active_existence_constraints | Gauge | Number of active existence constraints. |
| memgraph_active_unique_constraints | Gauge | Number of active unique constraints. |
| memgraph_active_type_constraints | Gauge | Number of active type constraints. |
Memory metrics
| Name | Type | Description |
|---|---|---|
| memgraph_db_memory_tracked_bytes | Gauge | Total tracked memory for the database (in bytes). |
| memgraph_db_peak_memory_tracked_bytes | Gauge | Peak tracked memory for the database (in bytes). |
| memgraph_db_storage_memory_tracked_bytes | Gauge | Memory used by graph structures (vertices, edges, properties). |
| memgraph_db_embedding_memory_tracked_bytes | Gauge | Memory used by vector index embeddings. |
| memgraph_db_query_memory_tracked_bytes | Gauge | Memory used by query execution. |
| memgraph_unreleased_delta_objects | Gauge | Number of unreleased delta objects. |
| memgraph_gc_latency_seconds | Histogram | GC total cleanup time. |
| memgraph_gc_skiplist_cleanup_latency_seconds | Histogram | GC time spent cleaning skiplists in indexes. |
Operator metrics
Before a Cypher query is executed, it is converted into an internal form suitable for execution, known as a query plan. A query plan is a tree-like data structure describing a pipeline of operations that will be performed on the database in order to yield the results for a given query. Every node within a plan is known as a logical operator and describes a particular operation.
All operator metrics are counters tracking how many times each operator was used.
| Name | Type |
|---|---|
| memgraph_once_operator_total | Counter |
| memgraph_create_node_operator_total | Counter |
| memgraph_create_expand_operator_total | Counter |
| memgraph_scan_all_operator_total | Counter |
| memgraph_scan_all_by_label_operator_total | Counter |
| memgraph_scan_all_by_label_properties_operator_total | Counter |
| memgraph_scan_all_by_id_operator_total | Counter |
| memgraph_scan_all_by_edge_operator_total | Counter |
| memgraph_scan_all_by_edge_type_operator_total | Counter |
| memgraph_scan_all_by_edge_type_property_operator_total | Counter |
| memgraph_scan_all_by_edge_type_property_value_operator_total | Counter |
| memgraph_scan_all_by_edge_type_property_range_operator_total | Counter |
| memgraph_scan_all_by_edge_property_operator_total | Counter |
| memgraph_scan_all_by_edge_property_value_operator_total | Counter |
| memgraph_scan_all_by_edge_property_range_operator_total | Counter |
| memgraph_scan_all_by_edge_id_operator_total | Counter |
| memgraph_scan_all_by_point_distance_operator_total | Counter |
| memgraph_scan_all_by_point_withinbbox_operator_total | Counter |
| memgraph_expand_operator_total | Counter |
| memgraph_expand_variable_operator_total | Counter |
| memgraph_construct_named_path_operator_total | Counter |
| memgraph_filter_operator_total | Counter |
| memgraph_produce_operator_total | Counter |
| memgraph_delete_operator_total | Counter |
| memgraph_set_property_operator_total | Counter |
| memgraph_set_properties_operator_total | Counter |
| memgraph_set_labels_operator_total | Counter |
| memgraph_set_nested_property_operator_total | Counter |
| memgraph_remove_property_operator_total | Counter |
| memgraph_remove_labels_operator_total | Counter |
| memgraph_remove_nested_property_operator_total | Counter |
| memgraph_edge_uniqueness_filter_operator_total | Counter |
| memgraph_empty_result_operator_total | Counter |
| memgraph_accumulate_operator_total | Counter |
| memgraph_aggregate_operator_total | Counter |
| memgraph_skip_operator_total | Counter |
| memgraph_limit_operator_total | Counter |
| memgraph_order_by_operator_total | Counter |
| memgraph_merge_operator_total | Counter |
| memgraph_optional_operator_total | Counter |
| memgraph_unwind_operator_total | Counter |
| memgraph_distinct_operator_total | Counter |
| memgraph_union_operator_total | Counter |
| memgraph_cartesian_operator_total | Counter |
| memgraph_call_procedure_operator_total | Counter |
| memgraph_foreach_operator_total | Counter |
| memgraph_evaluate_pattern_filter_operator_total | Counter |
| memgraph_apply_operator_total | Counter |
| memgraph_indexed_join_operator_total | Counter |
| memgraph_hash_join_operator_total | Counter |
| memgraph_roll_up_apply_operator_total | Counter |
| memgraph_periodic_commit_operator_total | Counter |
| memgraph_periodic_subquery_operator_total | Counter |
Query metrics
| Name | Type | Description |
|---|---|---|
| memgraph_query_execution_latency_seconds | Histogram | Query execution latency. |
| memgraph_read_queries_total | Counter | Number of read-only queries executed. |
| memgraph_write_queries_total | Counter | Number of write-only queries executed. |
| memgraph_read_write_queries_total | Counter | Number of read-write queries executed. |
Schema and storage info metrics
| Name | Type | Description |
|---|---|---|
| memgraph_show_schema_total | Counter | Number of times SHOW SCHEMA INFO was executed. |
| memgraph_show_storage_info_total | Counter | Number of times SHOW STORAGE INFO or SHOW STORAGE INFO ON DATABASE was executed. |
Session metrics
Session metrics are global; they are not scoped to any individual database.
| Name | Type | Description |
|---|---|---|
| memgraph_active_sessions | Gauge | Number of active connections. |
| memgraph_active_bolt_sessions | Gauge | Number of active Bolt connections. |
| memgraph_active_tcp_sessions | Gauge | Number of active TCP connections. |
| memgraph_active_ssl_sessions | Gauge | Number of active SSL connections. |
| memgraph_active_websocket_sessions | Gauge | Number of active WebSocket connections. |
| memgraph_bolt_messages_total | Counter | Number of Bolt messages sent. |
Snapshot metrics
| Name | Type | Description |
|---|---|---|
| memgraph_snapshot_creation_latency_seconds | Histogram | Snapshot creation latency. |
| memgraph_snapshot_recovery_latency_seconds | Histogram | Snapshot recovery latency. |
Stream metrics
| Name | Type | Description |
|---|---|---|
| memgraph_streams_created_total | Counter | Number of streams created. |
| memgraph_messages_consumed_total | Counter | Number of consumed streamed messages. |
Transaction metrics
| Name | Type | Description |
|---|---|---|
| memgraph_active_transactions | Gauge | Number of active transactions. |
| memgraph_committed_transactions_total | Counter | Number of committed transactions. |
| memgraph_rolled_back_transactions_total | Counter | Number of rolled-back transactions. |
| memgraph_failed_queries_total | Counter | Number of times executing a query failed (during parse time or runtime). |
| memgraph_failed_prepares_total | Counter | Number of times preparing a query failed. |
| memgraph_failed_pulls_total | Counter | Number of times pulling a query failed. |
| memgraph_successful_queries_total | Counter | Number of successful queries. |
| memgraph_transient_errors_total | Counter | Number of transient errors (errors which can be retried). |
| memgraph_write_write_conflicts_total | Counter | Number of write-write conflicts (two transactions modifying the same node simultaneously). |
Trigger metrics
| Name | Type | Description |
|---|---|---|
| memgraph_triggers_created_total | Counter | Number of triggers created. |
| memgraph_triggers_executed_total | Counter | Number of triggers executed. |
TTL metrics
| Name | Type | Description |
|---|---|---|
| memgraph_deleted_nodes_total | Counter | Number of nodes deleted via TTL. |
| memgraph_deleted_edges_total | Counter | Number of edges deleted via TTL. |
HA metrics
HA metrics are global; they are not scoped to any individual database.
Latency histograms
| Name | Type | Description |
|---|---|---|
| memgraph_socket_connect_seconds | Histogram | Socket connect latency. |
| memgraph_prepare_commit_rpc_seconds | Histogram | PrepareCommitRpc latency. |
| memgraph_current_wal_rpc_seconds | Histogram | CurrentWalRpc latency. |
| memgraph_wal_files_rpc_seconds | Histogram | WalFilesRpc latency. |
| memgraph_replica_stream_seconds | Histogram | Time to construct PrepareCommitRpc stream. |
| memgraph_snapshot_rpc_seconds | Histogram | SnapshotRpc latency. |
| memgraph_frequent_heartbeat_rpc_seconds | Histogram | FrequentHeartbeatRpc latency. |
| memgraph_heartbeat_rpc_seconds | Histogram | HeartbeatRpc latency. |
| memgraph_system_recovery_rpc_seconds | Histogram | SystemRecoveryRpc latency. |
| memgraph_choose_most_up_to_date_instance_seconds | Histogram | Latency of choosing the next main instance. |
| memgraph_get_histories_seconds | Histogram | Latency of retrieving instance histories. |
| memgraph_instance_fail_callback_seconds | Histogram | Instance failure callback latency. |
| memgraph_instance_succ_callback_seconds | Histogram | Instance success callback latency. |
| memgraph_data_failover_seconds | Histogram | Failover procedure latency. |
| memgraph_start_txn_replication_seconds | Histogram | Latency of starting transaction replication. |
| memgraph_finalize_txn_replication_seconds | Histogram | Latency of finishing transaction replication. |
| memgraph_demote_main_to_replica_rpc_seconds | Histogram | DemoteMainToReplicaRpc latency. |
| memgraph_enable_writing_on_main_rpc_seconds | Histogram | EnableWritingOnMainRpc latency. |
| memgraph_get_database_histories_rpc_seconds | Histogram | GetDatabaseHistoriesRpc latency. |
| memgraph_promote_to_main_rpc_seconds | Histogram | PromoteToMainRpc latency. |
| memgraph_register_replica_on_main_rpc_seconds | Histogram | RegisterReplicaOnMainRpc latency. |
| memgraph_state_check_rpc_seconds | Histogram | StateCheckRpc latency. |
| memgraph_unregister_replica_rpc_seconds | Histogram | UnregisterReplicaRpc latency. |
| memgraph_update_data_instance_config_rpc_seconds | Histogram | UpdateDataInstanceConfigRpc latency. |
Throughput histograms
Throughput metrics are labeled per replica with an mg_instance label.
| Name | Type | Description |
|---|---|---|
| memgraph_snapshot_throughput_bytes_per_second | Histogram | Snapshot replication throughput to a replica (bytes/second). |
| memgraph_wal_throughput_bytes_per_second | Histogram | WAL replication throughput to a replica (bytes/second). |
Counters
| Name | Type | Description |
|---|---|---|
| memgraph_successful_failovers_total | Counter | Successful failovers. |
| memgraph_raft_failed_failovers_total | Counter | Failovers that failed because writing to Raft failed. |
| memgraph_no_alive_instance_failed_failovers_total | Counter | Failovers that failed because no instance was alive. |
| memgraph_become_leader_success_total | Counter | Times a coordinator successfully became leader. |
| memgraph_failed_to_become_leader_total | Counter | Times a coordinator failed to become leader. |
| memgraph_show_instance_total | Counter | Times SHOW INSTANCE was called. |
| memgraph_show_instances_total | Counter | Times SHOW INSTANCES was called. |
| memgraph_demote_instance_total | Counter | Times the user manually demoted an instance. |
| memgraph_unregister_repl_instance_total | Counter | Times the user tried to unregister a replication instance. |
| memgraph_remove_coord_instance_total | Counter | Times the user tried to remove a coordinator instance. |
| memgraph_state_check_rpc_success_total | Counter | Successful StateCheckRpc responses. |
| memgraph_state_check_rpc_fail_total | Counter | Failed or missing StateCheckRpc responses. |
| memgraph_unregister_replica_rpc_success_total | Counter | Successful UnregisterReplicaRpc responses. |
| memgraph_unregister_replica_rpc_fail_total | Counter | Failed or missing UnregisterReplicaRpc responses. |
| memgraph_enable_writing_on_main_rpc_success_total | Counter | Successful EnableWritingOnMainRpc responses. |
| memgraph_enable_writing_on_main_rpc_fail_total | Counter | Failed or missing EnableWritingOnMainRpc responses. |
| memgraph_promote_to_main_rpc_success_total | Counter | Successful PromoteToMainRpc responses. |
| memgraph_promote_to_main_rpc_fail_total | Counter | Failed or missing PromoteToMainRpc responses. |
| memgraph_demote_main_to_replica_rpc_success_total | Counter | Successful DemoteMainToReplicaRpc responses. |
| memgraph_demote_main_to_replica_rpc_fail_total | Counter | Failed or missing DemoteMainToReplicaRpc responses. |
| memgraph_register_replica_on_main_rpc_success_total | Counter | Successful RegisterReplicaOnMainRpc responses. |
| memgraph_register_replica_on_main_rpc_fail_total | Counter | Failed or missing RegisterReplicaOnMainRpc responses. |
| memgraph_swap_main_uuid_rpc_success_total | Counter | Successful SwapMainUUIDRpc responses. |
| memgraph_swap_main_uuid_rpc_fail_total | Counter | Failed or missing SwapMainUUIDRpc responses. |
| memgraph_get_database_histories_rpc_success_total | Counter | Successful GetDatabaseHistoriesRpc responses. |
| memgraph_get_database_histories_rpc_fail_total | Counter | Failed or missing GetDatabaseHistoriesRpc responses. |
| memgraph_update_data_instance_config_rpc_success_total | Counter | Successful UpdateDataInstanceConfigRpc responses. |
| memgraph_update_data_instance_config_rpc_fail_total | Counter | Failed or missing UpdateDataInstanceConfigRpc responses. |
| memgraph_replica_recovery_success_total | Counter | Successful replica recovery processes. |
| memgraph_replica_recovery_fail_total | Counter | Failed replica recovery processes. |
| memgraph_replica_recovery_skip_total | Counter | Skipped replica recovery tasks. |
OpenMetrics monitoring
Set --metrics-format=OpenMetrics
to enable the OpenMetrics endpoint. The response uses
OpenMetrics text format
(application/openmetrics-text), which any Prometheus-compatible client can
scrape directly.
The metrics are served at http://host:port/metrics (or http://host:port/).
See Prometheus scrape configuration for how
to set up scraping.
Per-database labels
Per-database metrics carry database and uuid labels identifying which
database they belong to. Global metrics (such as sessions, HA) have no database
label.
# TYPE memgraph_vertex_count gauge
memgraph_vertex_count{database="memgraph",uuid="abc-123"} 42254
memgraph_vertex_count{database="analytics",uuid="def-456"} 1000
# TYPE memgraph_active_sessions gauge
memgraph_active_sessions 3Instance status gauges
The following per-instance gauges are exposed for each registered HA instance.
Each metric carries an mg_instance label identifying the instance by name.
All instances expose instance_up and instance_last_response_seconds.
Coordinator instances additionally expose instance_is_leader, while data
instances expose instance_is_main.
| Name | Type | Applies to | Description |
|---|---|---|---|
| memgraph_instance_up | Gauge | All | 1 if the instance is up, 0 if down. |
| memgraph_instance_last_response_seconds | Gauge | All | Seconds since the last successful response from the instance. |
| memgraph_instance_is_leader | Gauge | Coordinators | 1 if the coordinator is the leader, 0 if follower. |
| memgraph_instance_is_main | Gauge | Data instances | 1 if the data instance is the main, 0 if replica. |
Prometheus scrape configuration
Add Memgraph as a scrape target in your prometheus.yml:
scrape_configs:
- job_name: "memgraph"
metrics_path: "/metrics"
static_configs:
- targets: ["memgraph-host:9091"]JSON monitoring (deprecated)
Set --metrics-format=JSON (the current default) to enable the JSON endpoint.
This format is deprecated and will be removed in a future release.
To retrieve the metrics, send a GET request to http://host:port/metrics
or http://host:port/:
import json
import requests
def fetch_memgraph_metrics():
metrics_url = "http://0.0.0.0:9091/metrics"
try:
response = requests.get(metrics_url, timeout=5)
if response.status_code == 200:
metrics_data = json.loads(response.text)
print("Memgraph Metrics:\n", json.dumps(metrics_data, indent=4))
else:
print(f"Failed to fetch metrics. Status code: {response.status_code}")
except requests.exceptions.RequestException as e:
print(f"An error occurred: {e}")
fetch_memgraph_metrics()Response format
The endpoint returns a JSON object grouped by metric category. Each category contains key-value pairs of metric names and their values:
{
"General": {
"vertex_count": 42254,
"edge_count": 871978,
"average_degree": 41.2732,
"disk_usage": 81508835,
"memory_usage": 339640320,
"peak_memory_usage": 339775488,
"unreleased_delta_objects": 0,
"SocketConnect_us_50p": 0,
"SocketConnect_us_90p": 0,
"SocketConnect_us_99p": 0
},
"Index": {
"ActiveLabelIndices": 6,
"ActiveLabelPropertyIndices": 18
},
"Transaction": {
"ActiveTransactions": 1,
"CommitedTransactions": 0,
"RollbackedTransactions": 0
}
}Metric naming
The JSON endpoint uses different metric names from the OpenMetrics tables
above, and groups metrics into categories. Histogram values are reported in
microseconds with _us_50p, _us_90p, _us_99p suffixes rather than as
native Prometheus histograms in seconds.
Some notable name differences:
| OpenMetrics name | JSON name | JSON category |
|---|---|---|
| memgraph_vertex_count | vertex_count | General |
| memgraph_edge_count | edge_count | General |
| memgraph_memory_res_bytes | memory_usage | General |
| memgraph_peak_memory_res_bytes | peak_memory_usage | General |
| memgraph_disk_usage_bytes | disk_usage | General |
| memgraph_rolled_back_transactions_total | RollbackedTransactions | Transaction |
| memgraph_query_execution_latency_seconds | QueryExecutionLatency_us_50p/90p/99p | Query |
| memgraph_active_label_indices | ActiveLabelIndices | Index |
The full set of JSON names can be seen in the SHOW METRICS INFO output
documented on the server stats page.
Aggregated metrics
The JSON format aggregates per-database metrics into global totals; it
does not expose per-database breakdowns. For per-database visibility, use
--metrics-format=OpenMetrics or the SHOW METRICS INFO Cypher query.
HA counter reset behaviour
All HA metrics with type Counter are aggregated for all coordinators. That makes it easier for users to track what is going on since they don’t need to aggregate
by their own metrics specific to each coordinators. Also, after every pull, HA metrics with type Counter are in Memgraph reset to 0. This makes it possible to use Gauge on
the client side without worrying that on restart we will lose all data.
The ReplicaRecoverySuccess, ReplicaRecoveryFail, and ReplicaRecoverySkip
counters are excluded from this behaviour and report cumulative totals.
mg-exporter
OpenMetrics compatible clients cannot scrape the JSON endpoint directly. Use the separate Prometheus exporter middleware, which reads the JSON endpoint and re-exposes metrics in a Prometheus-compatible format.
Migrating from JSON to OpenMetrics
If you are currently using the deprecated JSON metrics endpoint, follow these steps to switch to OpenMetrics.
Configuration change
Set --metrics-format=OpenMetrics
instead of JSON. The endpoint address and port remain the same.
If you were using mg-exporter
to bridge the JSON endpoint to Prometheus, you can remove it: Prometheus can
now scrape the OpenMetrics endpoint directly.
Metric name changes
OpenMetrics uses memgraph_ prefixed, snake_case names (e.g.
memgraph_vertex_count) instead of the JSON CamelCase names (e.g.
vertex_count). See the metric naming table in the JSON
section for a summary of notable differences. You will need to update any
dashboard queries or alerting rules that reference the old names.
Histogram format change
The OpenMetrics endpoint uses different histogram bucket boundaries from the JSON endpoint. As a result, computed percentiles (p50, p90, p99) may differ slightly from values previously reported by the JSON format for the same workload.
JSON reported histograms as three fixed percentile values in microseconds
with _us_50p, _us_90p, _us_99p suffixes. OpenMetrics exposes native
Prometheus histograms in seconds with configurable bucket boundaries. Update
any dashboard panels that reference histogram metrics to use Prometheus
histogram_quantile() functions and adjust for the unit change.
Per-database labels
The JSON endpoint aggregated all database metrics into global totals. The
OpenMetrics endpoint exposes metrics per database, using database and
uuid labels. Existing dashboard queries that expect flat, unlabelled metrics
will need to be updated — either by filtering on a specific database label or by
aggregating with sum().
HA counter semantics
In the JSON endpoint, most HA counter metrics use delta semantics: they reset
to zero after each scrape. In OpenMetrics, all counters are cumulative (as
per the Prometheus data model). If your alerting rules relied on the delta
behaviour, switch to using rate() or increase() functions in your queries.
New metrics
The OpenMetrics endpoint exposes instance status gauges
for each registered HA instance (e.g. memgraph_instance_is_alive,
memgraph_instance_is_main). These are not available in the JSON format.
Session trace
A session refers to a temporary, interactive connection from a client (either a user or an application) to the database server, used to execute a series of transactions and queries. Session trace is a feature in Memgraph that allows you to profile the execution of all queries within a session, providing detailed information on query parsing, planning and execution. This can be invaluable for understanding performance bottlenecks and optimizing database interactions.
Session trace events are emitted into the main Memgraph log at the INFO level, tagged with
the session that produced them. There is no separate per-session log file — every traced session interleaves into the
same log stream and is told apart by its [session=<uuid>] tag.
Session trace events are written at the INFO level, so they are only visible when
--log-level is set to INFO, DEBUG or TRACE. If you enable session
trace while the log level filters INFO out, Memgraph logs a warning and no trace events appear. Lower the level at
startup, or during runtime with SET DATABASE SETTING "log.level" TO "INFO";.
Enabling session trace
Enable session trace for your current session using the following command:
SET SESSION TRACE ON;The command returns the unique UUID of the session being traced:
| session uuid |
|---|
| ”de9c907b-6675-40bd-bf09-d4ce7b24f22d” |
Use this UUID to find the session’s events in the log. From this point on, every query executed in the session emits tagged trace events until tracing is turned off.
Reading the trace
Each trace event is a line in the main log prefixed with the session tag, the user (when authenticated) and the current transaction id:
[session=<uuid>] [user=<user>] [tx=<id>] <event>To isolate a single session’s trace, filter the main log by its UUID:
grep -F '[session=de9c907b-6675-40bd-bf09-d4ce7b24f22d]' /var/log/memgraph/<memgraph_date>.logThe trace captures detailed information for every query executed during the session, including:
- Session UUID, user and transaction ID: carried on every tagged line.
- Accepted query: the query text as received.
- Parsing, planning and execution timings: start and end markers and durations for each phase.
- Explain and profile plans: the query’s plan and, after execution, its profiling statistics and execution counters.
- Commit timings: start and end markers for the commit phase.
- Failed queries: the error message when a query throws.
This detailed logging helps in profiling the entire session workload, increasing visibility into potential performance bottlenecks without enabling trace-level logging globally.
Trace coverage is bounded to the connection’s own thread. Work that Memgraph hands off to background threads (for example parallel index creation, replication, garbage collection or Raft) is not attributed to the session and does not appear in its trace.
Disabling session trace
To stop emitting trace events for the current session, use the following command:
SET SESSION TRACE OFF;After executing this command, no further trace events are written for the active session.