开启JanusGraph中的metrics功能进行监控:
1.在配置文件中指定配置项
# Copyright 2019 JanusGraph Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# JanusGraph configuration sample: HBase and Elasticsearch
#
# This file connects to HBase using a Zookeeper quorum
# (storage.hostname) consisting solely of localhost. It also connects
# to Elasticsearch running on localhost over Elasticsearch's native "Transport"
# protocol. Zookeeper, the HBase services, and Elasticsearch must already
# be running and available before starting JanusGraph with this file.
# The implementation of graph factory that will be used by gremlin server
#
# Default: org.janusgraph.core.JanusGraphFactory
# Data Type: String
# Mutability: LOCAL
gremlin.graph=org.janusgraph.core.JanusGraphFactory
# The primary persistence provider used by JanusGraph. This is required.
# It should be set one of JanusGraph's built-in shorthand names for its
# standard storage backends (shorthands: berkeleyje, cassandrathrift,
# cassandra, astyanax, embeddedcassandra, cql, hbase, inmemory) or to the
# full package and classname of a custom/third-party StoreManager
# implementation.
#
# Default: (no default value)
# Data Type: String
# Mutability: LOCAL
storage.backend=hbase
# The hostname or comma-separated list of hostnames of storage backend
# servers. This is only applicable to some storage backends, such as
# cassandra and hbase.
#
# Default: 127.0.0.1
# Data Type: class java.lang.String[]
# Mutability: LOCAL
storage.hostname=127.0.0.1
# Whether to enable JanusGraph's database-level cache, which is shared
# across all transactions. Enabling this option speeds up traversals by
# holding hot graph elements in memory, but also increases the likelihood
# of reading stale data. Disabling it forces each transaction to
# independently fetch graph elements from storage before reading/writing
# them.
#
# Default: false
# Data Type: Boolean
# Mutability: MASKABLE
cache.db-cache = true
# How long, in milliseconds, database-level cache will keep entries after
# flushing them. This option is only useful on distributed storage
# backends that are capable of acknowledging writes without necessarily
# making them immediately visible.
#
# Default: 50
# Data Type: Integer
# Mutability: GLOBAL_OFFLINE
#
# Settings with mutability GLOBAL_OFFLINE are centrally managed in
# JanusGraph's storage backend. After starting the database for the first
# time, this file's copy of this setting is ignored. Use JanusGraph's
# Management System to read or modify this value after bootstrapping.
cache.db-cache-clean-wait = 20
# Default expiration time, in milliseconds, for entries in the
# database-level cache. Entries are evicted when they reach this age even
# if the cache has room to spare. Set to 0 to disable expiration (cache
# entries live forever or until memory pressure triggers eviction when set
# to 0).
#
# Default: 10000
# Data Type: Long
# Mutability: GLOBAL_OFFLINE
#
# Settings with mutability GLOBAL_OFFLINE are centrally managed in
# JanusGraph's storage backend. After starting the database for the first
# time, this file's copy of this setting is ignored. Use JanusGraph's
# Management System to read or modify this value after bootstrapping.
cache.db-cache-time = 180000
# Size of JanusGraph's database level cache. Values between 0 and 1 are
# interpreted as a percentage of VM heap, while larger values are
# interpreted as an absolute size in bytes.
#
# Default: 0.3
# Data Type: Double
# Mutability: MASKABLE
cache.db-cache-size = 0.5
# The indexing backend used to extend and optimize JanusGraph's query
# functionality. This setting is optional. JanusGraph can use multiple
# heterogeneous index backends. Hence, this option can appear more than
# once, so long as the user-defined name between "index" and "backend" is
# unique among appearances.Similar to the storage backend, this should be
# set to one of JanusGraph's built-in shorthand names for its standard
# index backends (shorthands: lucene, elasticsearch, es, solr) or to the
# full package and classname of a custom/third-party IndexProvider
# implementation.
#
# Default: elasticsearch
# Data Type: String
# Mutability: GLOBAL_OFFLINE
#
# Settings with mutability GLOBAL_OFFLINE are centrally managed in
# JanusGraph's storage backend. After starting the database for the first
# time, this file's copy of this setting is ignored. Use JanusGraph's
# Management System to read or modify this value after bootstrapping.
index.search.backend=elasticsearch
# The hostname or comma-separated list of hostnames of index backend
# servers. This is only applicable to some index backends, such as
# elasticsearch and solr.
#
# Default: 127.0.0.1
# Data Type: class java.lang.String[]
# Mutability: MASKABLE
index.search.hostname=127.0.0.1
#指定使用hbase中的表
storage.hbase.table=threeCountry
# Required to enable Metrics in JanusGraph
metrics.enabled = true
# 自定义默认指标名称
metrics.prefix = janusgraph
# Required; specify logging interval in milliseconds
metrics.console.interval = 60000
然后在gremlin控制台中就会每隔一分钟打印相关信息:
11/3/21 5:33:21 AM =============================================================
-- Counters --------------------------------------------------------------------
global.storeManager.openDatabase.calls
count = 10
global.storeManager.startTransaction.calls
count = 42
org.janusgraph.sys.stores.getSlice.calls
count = 39
org.janusgraph.sys.stores.getSlice.entries-returned
count = 0
org.janusgraph.sys.stores.mutate.calls
count = 1
-- Histograms ------------------------------------------------------------------
org.janusgraph.sys.stores.getSlice.entries-histogram
count = 39
min = 0
max = 0
mean = 0.00
stddev = 0.00
median = 0.00
75% <= 0.00
95% <= 0.00
98% <= 0.00
99% <= 0.00
99.9% <= 0.00
-- Timers ----------------------------------------------------------------------
org.janusgraph.sys.stores.getSlice.time
count = 39
mean rate = 0.21 calls/second
1-minute rate = 0.22 calls/second
5-minute rate = 0.42 calls/second
15-minute rate = 0.53 calls/second
min = 2.84 milliseconds
max = 32.90 milliseconds
mean = 6.94 milliseconds
stddev = 5.44 milliseconds
median = 4.84 milliseconds
75% <= 7.80 milliseconds
95% <= 16.53 milliseconds
98% <= 32.90 milliseconds
99% <= 32.90 milliseconds
99.9% <= 32.90 milliseconds
org.janusgraph.sys.stores.mutate.time
count = 1
mean rate = 0.01 calls/second
1-minute rate = 0.01 calls/second
5-minute rate = 0.11 calls/second
15-minute rate = 0.16 calls/second
min = 95.04 milliseconds
max = 95.04 milliseconds
mean = 95.04 milliseconds
stddev = 0.00 milliseconds
median = 95.04 milliseconds
75% <= 95.04 milliseconds
95% <= 95.04 milliseconds
98% <= 95.04 milliseconds
99% <= 95.04 milliseconds
99.9% <= 95.04 milliseconds