Back to Pikiwidb

Pika Metric Exporter

tools/pika_exporter/README.md

4.0.230.9 KB
Original Source

Pika Metric Exporter

Prometheus exporter for nosql Qihoo360/pika metrics.

Pika-Exporter is based on Redis-Exporter

Buiding

Build and run locally:

To start using pika_exporter, install Go and run go get

shell
$ go get github.com/OpenAtomFoundation/pika/tools/pika_exporter
$ cd $GOPATH/src/github.com/OpenAtomFoundation/pika/tools/pika_exporter
$ make
$ ./bin/pika_exporter <flags>

For example:

shell
$ nohup ./bin/pika_exporter -pika.addr 127.0.0.1:9221 &

Prometheus Configuration:

Add a block to the scrape_configs of your prometheus.yml config file:

yml
scrape_configs:
  - job_name: pika
    scrape_interval: 15s
    static_configs:
      - targets: ['127.0.0.1:9121']
        labels:
          group: 'test'

Run prometheus:

shell
prometheus --config.file=./grafana/prometheus.yml

Flags

NameEnvironment VariablesDefaultDescriptionExample
pika.host-filePIKA_HOST_FILEPath to file containing one or more pika nodes, separated by newline. NOTE: mutually exclusive with pika.addr.Each line can optionally be comma-separated with the fields <addr>,<password>,<alias>. See here for an example file.--pika.host-file ./pika_hosts_file.txt
pika.addrPIKA_ADDRAddress of one or more pika nodes, separated by comma.--pika.addr 192.168.1.2:9221,192.168.1.3:9221
pika.passwordPIKA_PASSWORDPassword for one or more pika nodes, separated by comma.--pika.password 123.com,123.com
pika.aliasPIKA_ALIASPika instance alias for one or more pika nodes, separated by comma.--pika.alias a,b
namespacePIKA_EXPORTER_NAMESPACEpikaNamespace for metrics--namespace pika
keyspace-stats-clockPIKA_EXPORTER_KEYSPACE_STATS_CLOCK-1Stats the number of keys at keyspace-stats-clock o'clock every day, in the range [0, 23]. If < 0, not open this feature.--keyspace-stats-clock 0
check.key-patternsPIKA_EXPORTER_CHECK_KEY_PARTTERNSComma separated list of key-patterns to export value and length/size, searched for with SCAN.--check.key-patterns db0=test*,db0=abc
check.keysPIKA_EXPORTER_CHECK_KEYSComma separated list of keys to export value and length/size.--check.keys abc,test,wasd
check.scan-countPIKA_EXPORTER_CHECK_SCAN_COUNT100When check keys and executing SCAN command, scan-count assigned to COUNT.--check.scan-count 200
web.listen-addressPIKA_EXPORTER_WEB_LISTEN_ADDRESS:9121Address to listen on for web interface and telemetry.--web.listen-address ":9121"
web.telemetry-pathPIKA_EXPORTER_WEB_TELEMETRY_PATH/metricsPath under which to expose metrics.--web.telemetry-path "/metrics"
log.levelPIKA_EXPORTER_LOG_LEVELinfoLog level, valid options:panic fatal error warn warning info debug.--log.level "debug"
log.formatPIKA_EXPORTER_LOG_FORMATjsonLog format, valid options:txt json.--log.format "json"
versionfalseShow version information and exit.--version

Pika Metrics Definition

Pika Server Info

Metrics NameMetric TypeLabelsMetrics ValueMetric Desc
namespace_build_infoGauge{addr="", alias="", "os"="", "arch_bits"="", "pika_version"="", "pika_git_sha"="","pika_build_compile_date"=""}1pika binary file build info
namespace_server_infoGauge{addr="", alias="", "process_id"="", "tcp_port"="", "config_file"="", "server_id"="", "role"=""}1pika instance's info, the label role is the role in replication info
namespace_uptime_in_secondsGauge{addr="", alias=""}the value of uptime_in_secondspika instance's uptime in seconds
namespace_thread_numGauge{addr="", alias=""}the value of thread_numpika instance's thread num
namespace_sync_thread_numGauge{addr="", alias=""}the value of sync_thread_numpika instance's thread num for syncing

Pika Data Info

Metrics NameMetric TypeLabelsMetrics ValueMetric Desc
namespace_db_sizeGauge{addr="", alias="", "compression"=""}the value of db_sizetotal db data size (in bytes) of the pika instance, statistics of all files under the configured db-path
namespace_log_sizeGauge{addr="", alias=""}the value of log_sizetotal log data size (in bytes) of the pika instance, statistics of all files under the configured log-path witch contains INFO, WARNING, ERROR logs and binlog (write2fine) files for synchronization
namespace_used_memoryGauge{addr="", alias=""}the value of used_memorytotal used memory size (in bytes) of the pika instance
namespace_db_memtable_usageGauge{addr="", alias=""}the value of db_memtable_usagetotal memtable used memory size (in bytes) of the pika instance
namespace_db_tablereader_usageGauge{addr="", alias=""}the value of db_tablereader_usagetotal tablereader used memory size (in bytes) of the pika instance
(new)namespace_db_fatalGauge{addr="", alias=""}the value of db_fatalthe metrics value: 1 means errors occurred, 0 means no error

Pika Clients Info

Metrics NameMetric TypeLabelsMetrics ValueMetric Desc
namespace_connected_clientsGauge{addr="", alias=""}the value of connected_clientstotal count of connected clients in pika instance

Pika Stats Info

Metrics NameMetric TypeLabelsMetrics ValueMetric Desc
namespace_total_connections_receivedCounter{addr="", alias=""}the value of total_connections_receivedtotal count of received connections from clients in pika instance
namespace_instantaneous_ops_per_secGauge{addr="", alias=""}the value of instantaneous_ops_per_secthe count of prcessed operations in per seconds by pika instance
namespace_total_commands_processedCounter{addr="", alias=""}the value of total_commands_processedtotal count of processed commands in pika instance
namespace_is_bgsavingGauge{addr="", alias=""}0 or 1the metrics value: 1 means bgsave is in progress, 0 means bgsave is not in progress
namespace_is_scaning_keyspaceGauge{addr="", alias=""}0 or 1the metrics value: 1 means the keyspace is scanning, 0 means not scanning
namespace_compactGauge{addr="", alias="", compact_cron"="", "compact_interval":""}0 or 1the metrics value: 1 means compact is in progress, 0 means compact is not in progress

Pika Command Exec Count Info

Metrics NameMetric TypeLabelsMetrics ValueMetric Desc
namespace_command_exec_countCounter{addr="", alias="", "command"=""}the value of the command executed countthe count of each command executed in pika instance

Pika CPU Info

Metrics NameMetric TypeLabelsMetrics ValueMetric Desc
namespace_used_cpu_user_childrenCounter{addr="", alias=""}the value of used_cpu_user_childrentotal user CPU usage time (in seconds) of pika children instance
namespace_used_cpu_userCounter{addr="", alias=""}the value of used_cpu_usertotal user CPU usage time (in seconds) of pika instance
namespace_used_cpu_sys_childrenCounter{addr="", alias=""}the value of used_cpu_sys_childrentotal system CPU usage time (in seconds) of pika children instance
namespace_used_cpu_sysCounter{addr="", alias=""}the value of used_cpu_systotal system CPU usage time (in seconds) of pika instance

Pika Replication Info

Metrics NameMetric TypeLabelsMetrics ValueMetric Desc
namespace_connected_slavesGauge{addr="", alias=""}the value of connected_slavesthe count of connected slaves, when pika instance's role is master
(no exists)namespace_partition_slave_lagGauge{addr="", alias="", "slave_conn_fd"="", slave_ip"="", "slave_port"="", "partition"=""}parse master slave info's lagthe binlog lag of all slaves of the pika instance
namespace_master_link_statusGauge{addr="", alias="", "master_host"="", "master_port"=""}0 or 1connection state between slave and master(1 means all partitions sync ok), when pika instance's role is slave
namespace_slave_read_onlyGauge{addr="", alias="", "master_host"="", "master_port"=""}0 or 1is slave read only, when pika instance's role is slave
namespace_slave_priorityGauge{addr="", alias="", "master_host"="", "master_port"=""}the value of slave_priorityslave priority, when pika instance's role is slave
(no exists)namespace_partition_repl_stateGauge{addr="", alias="", "master_host"="", "master_port"="", "partition"="", "repl_state"=""}0sync connection state between slave and master for each partition, when pika instance's role is slave
(no exists)namespace_db_binlog_offset_filenumGauge{addr="", alias="", "db"=""}the value of binlog_offset filenum each dbbinlog file num for each db
(no exists)namespace_db_binlog_offsetGauge{addr="", alias="", "db"="", "safety_purge"=""}the value of binlog_offset offset each dbbinlog offset for each db
(new)namespace_db_consensus_last_logGauge{addr="", alias="", "db"="", "last_log"=""}the value of consensus last_log each dbconsensus last_log for each db when consensus-level is enabled

Pika Keyspace Info

Metrics NameMetric TypeLabelsMetrics ValueMetric Desc
(new)namespace_keyspace_last_start_timeGauge{addr="", alias=""}the value of Keyspace Time convert to unix secondsthe start time(unix seconds) of the last statistical keyspace
namespace_keysGauge{addr="", alias="", "db"="", "type"=""}the value of keystotal count of the key-type keys for each db
namespace_expire_keysGauge{addr="", alias="", "db"="", "type"=""}the value of expire_keystotal count of the key-type expire keys for each db
namespace_invalid_keysGauge{addr="", alias="", "db"="", "type"=""}the value of invalid_keystotal count of the key-type invalid keys for each db

Pika Command Execution Time

Rocksdb Metrics

Serial NumberMetricMeaning
55rocksdb.cfstatsThe all metrics of compaction_L<N>: compaction.L<N>.AvgSec Average time spent per Compact. compaction.L<N>.CompCount The number of times Compact has been accumulated. compaction.L<N>.CompMergeCPU CPU time used in compression, in seconds. compaction.L<N>.CompSec Compact cumulative time, in seconds. compaction.L<N>.CompactedFiles Number of files that have completed compact. compaction.L<N>.KeyDrop Number of keys deleted in compact. compaction.L<N>.KeyIn Number of records compared during the compaction process. compaction.L<N>.MovedGB During the compaction process, the number of bytes moved to level n+1. compaction.L<N>.NumFiles Total number of sst files. compaction.L<N>.RblobGB The size of data read from the blob file by the compaction, in GB. compaction.L<N>.ReadGB Read size in GB. compaction.L<N>.ReadMBps Read rate in MBps. compaction.L<N>.RnGB When performing compact, read the size of the current layer file in GB. compaction.L<N>.Rnp1GB When performing compact, read the size of the next level file in GB. compaction.L<N>.Score Score, the higher the score, the higher the priority. compaction.L<N>.SizeBytes Total size of SST in bytes. compaction.L<N>.WblobGB The size of the blob file written during compaction, in GB. compaction.L<N>.WnewGB WNP1- Rnp1. compaction.L<N>.WriteAmp Total bytes written to level<N+1>/(total bytes read from level<N>). compaction.L<N>.WriteGB The size of the table file written during the compaction period, in GB. compaction.L<N>.WriteMBps Data write rate in compaction.
11rocksdb.num-immutable-mem-tableNumber of immutable memtables not yet flushed.
12rocksdb.num-immutable-mem-table-flushedNumber of immutable memtables that have been flushed.
13rocksdb.mem-table-flush-pendingReturns 1 if there is a pending memtable flush; otherwise returns 0.
14rocksdb.num-running-flushesNumber of currently running flush operations.
15rocksdb.compaction-pendingReturns 1 if at least one compaction operation is pending; otherwise returns 0.
16rocksdb.num-running-compactionsNumber of running compactions.
17rocksdb.background-errorsTotal number of background errors.
18rocksdb.cur-size-active-mem-tableApproximate size, in bytes, of the active memtable.
19rocksdb.cur-size-all-mem-tablesTotal size in bytes of memtables not yet flushed, including the current active memtable and the unflushed immutable memtables.
20rocksdb.size-all-mem-tablesTotal size in bytes of all memtables, including the active memtable, unflushed immutable memtables, and pinned immutable memtables.
25rocksdb.estimate-num-keysEstimated number of keys in active memtable, unflushed immutable memtables, and flushed SST files.
26rocksdb.estimate-table-readers-memEstimated memory size used for reading SST files, excluding block cache (such as filter and index blocks).
28rocksdb.num-snapshotsNumber of unreleased snapshots in the database.
31rocksdb.num-live-versionsNumber of current versions. More current versions usually indicate more SST files being used by iterators or incomplete compactions.
32rocksdb.current-super-version-numberCurrent number of the LSM version. It is a uint64_t integer that increments after any changes in the LSM tree. This number is not preserved after restarting the database and starts from 0 after a database restart.
33rocksdb.estimate-live-data-sizeEstimated size of the activity data in bytes.For BlobDB, it also includes the actual live bytes in the version's blob file.
36rocksdb.total-sst-files-sizeTotal size (in bytes) of all SST files.Note: If there are too many files, it may slow down the online query.
37rocksdb.live-sst-files-sizeTotal size in bytes of all SST files belonging to the latest LSM tree.
47rocksdb.block-cache-capacityThe capacity of the block cache.
48rocksdb.block-cache-usageMemory size occupied by entries in the block cache.
49rocksdb.block-cache-pinned-usageMemory size occupied by pinned entries in the block cache.
51rocksdb.num-blob-filesThe number of blob files in the current version.
52rocksdb.blob-statsThe total and size of all blob files, and the total amount of garbage (in bytes) in blob files in the current version.
53rocksdb.total-blob-file-sizeThe total size of all blob files across all versions.
54rocksdb.live-blob-file-sizeThe total size of all blob files in the current version.

Grafana Dashboard

See here

Screenshots: