🩺InfluxDB

InfluxDB is an open-source time series database used by Datasentinel to store collected metrics and manage data retention.

Data is organized into time series, each of which contains a set of data points that are timestamped.

Usually, no management tasks are necessary with the InfluxDB backend database. However, if you require information about InfluxDB, here are some useful tips:

Datasentinel store metrics in the database ds-data with a default retention policy of 14 days (named ds-data)

Data is stored in daily shards, located in the directory /datasentinel/data/influxdb/data.

Additionally, the database employs series files found in the directory /datasentinel/data/influxdb/data/ds-data/_series, which facilitate the mapping of time series data to corresponding shards.

A complete installation embeds an InfluxDB database (Version 1.7.6) but you can use your own Influxdb database on a separate server.

Please contact support@datasentinel.io if you plan to use your own database.

Database Size

Here are some OS commands to check the size of an InfluxDB database.

InfluxDB is configured to manage its data storage and retention by dividing metrics into daily shards. A new directory is created each day.

The database ds-data stores its metrics in the directory /datasentinel/data/influxdb/data/ds-data/.

To see the size used by the retention policies, use the following command:

du -sh /datasentinel/data/influxdb/data/ds-data/*

The subdirectory ds-data corresponds to the default retention policy and holds the stored metrics.

Display the size of each daily shard:

du -sh /datasentinel/data/influxdb/data/ds-data/ds-data/*

Series File

du -sh /datasentinel/data/influxdb/data/ds-data/_series

Show Logs

The default log level for InfluxDB is set to error.

To view every action taken by InfluxDB, you can change the log level to info in the [logging] section of the configuration file located at

/datasentinel/soft/influxdb-1.7.6-1/etc/influxdb/influxdb.conf.

This can be helpful in troubleshooting issues but needs restart.

To access the logs, use the following command:

journalctl -xefu datasentinel_influxdb

Useful Commands

InfluxDB is configured to listen on port 8216.

An alias is present on the platform owner account, allowing you to simply type influx to connect.

Some useful commands when analyzing the InfluxDB database.

  • Cardinality

use ds-data
show series cardinality
  • Daily created series by shard

use _internal
select seriesCreate from "shard" where "database"='ds-data' and retentionPolicy='ds-data' group by path order by time desc limit 1
  • Number of points per second being written to the instance.

use ds-data
select derivative(pointReq, 1s) from "write" where time > now() - 10m
  • Modify the Retention Policy (Typically done through the User Interface)

use ds-data
alter retention policy "ds-data" on "ds-data" duration 31d replication 1 shard duration 1d default;
show retention policies

Recreating Indexes

Official documentation: https://docs.influxdata.com/influxdb/v1.7/administration/rebuild-tsi-index/#

sudo systemctl stop datasentinel_influxdb

cd /datasentinel/data/influxdb/
find . -name _series -exec ls -l {} \; -exec rm -fr {} \;
find . -name _series

find . -name index -exec ls -l {} \; -exec rm -fr {} \;
find . -name index

influx_inspect buildtsi -datadir /datasentinel/data/influxdb/data -waldir /datasentinel/data/influxdb/wal

sudo systemctl start datasentinel_influxdb

Recreating the Database

This action completely resets the database used to store metrics

The directory /datasentinel/data/influxdb/data/ds-data is deleted and the storage space freed up.

Connect to influxDB as datasentinel user.

  • Type influx

$ influx
  Connected to http://localhost:8216 version 1.7.6
  InfluxDB shell version: 1.7.6
  Enter an InfluxQL query
  >
  • Drop the database

drop database "ds-data"
show databases
  • Create the database

create database "ds-data"
show databases
  • Create retention policies

create retention policy "ds-data" on "ds-data" duration 14d replication 1 shard duration 1d default;
create retention policy "ar-data" on "ds-data" duration 90d replication 1 shard duration 1d;
use "ds-data"
show retention policies

Metrics

Show internals metrics

curl http://localhost:8216/metrics
# HELP go_gc_duration_seconds A summary of the GC invocation durations.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 6.0455e-05
go_gc_duration_seconds{quantile="0.25"} 0.000173879
go_gc_duration_seconds{quantile="0.5"} 0.000244642
go_gc_duration_seconds{quantile="0.75"} 0.000370561
go_gc_duration_seconds{quantile="1"} 0.003673301
go_gc_duration_seconds_sum 0.066770784
go_gc_duration_seconds_count 170
# HELP go_goroutines Number of goroutines that currently exist.
# TYPE go_goroutines gauge
go_goroutines 32
# HELP go_info Information about the Go environment.
# TYPE go_info gauge
go_info{version="go1.11"} 1
# HELP go_memstats_alloc_bytes Number of bytes allocated and still in use.
# TYPE go_memstats_alloc_bytes gauge
go_memstats_alloc_bytes 2.102922224e+09
# HELP go_memstats_alloc_bytes_total Total number of bytes allocated, even if freed.
# TYPE go_memstats_alloc_bytes_total counter
go_memstats_alloc_bytes_total 1.1651334704e+10
# HELP go_memstats_buck_hash_sys_bytes Number of bytes used by the profiling bucket hash table.
# TYPE go_memstats_buck_hash_sys_bytes gauge
go_memstats_buck_hash_sys_bytes 1.667387e+06
# HELP go_memstats_frees_total Total number of frees.
# TYPE go_memstats_frees_total counter
go_memstats_frees_total 7.9725592e+07
# HELP go_memstats_gc_cpu_fraction The fraction of this program's available CPU time used by the GC since the program started.
# TYPE go_memstats_gc_cpu_fraction gauge
go_memstats_gc_cpu_fraction 0.1066384218405857
# HELP go_memstats_gc_sys_bytes Number of bytes used for garbage collection system metadata.
# TYPE go_memstats_gc_sys_bytes gauge
go_memstats_gc_sys_bytes 9.3151232e+07
# HELP go_memstats_heap_alloc_bytes Number of heap bytes allocated and still in use.
# TYPE go_memstats_heap_alloc_bytes gauge
go_memstats_heap_alloc_bytes 2.102922224e+09
# HELP go_memstats_heap_idle_bytes Number of heap bytes waiting to be used.
# TYPE go_memstats_heap_idle_bytes gauge
go_memstats_heap_idle_bytes 1.05316352e+08
# HELP go_memstats_heap_inuse_bytes Number of heap bytes that are in use.
# TYPE go_memstats_heap_inuse_bytes gauge
go_memstats_heap_inuse_bytes 2.309423104e+09
# HELP go_memstats_heap_objects Number of allocated objects.
# TYPE go_memstats_heap_objects gauge
go_memstats_heap_objects 9.898008e+06
# HELP go_memstats_heap_released_bytes Number of heap bytes released to OS.
# TYPE go_memstats_heap_released_bytes gauge
go_memstats_heap_released_bytes 0
# HELP go_memstats_heap_sys_bytes Number of heap bytes obtained from system.
# TYPE go_memstats_heap_sys_bytes gauge
go_memstats_heap_sys_bytes 2.414739456e+09
# HELP go_memstats_last_gc_time_seconds Number of seconds since 1970 of last garbage collection.
# TYPE go_memstats_last_gc_time_seconds gauge
go_memstats_last_gc_time_seconds 1.67353162333638e+09
# HELP go_memstats_lookups_total Total number of pointer lookups.
# TYPE go_memstats_lookups_total counter
go_memstats_lookups_total 0
# HELP go_memstats_mallocs_total Total number of mallocs.
# TYPE go_memstats_mallocs_total counter
go_memstats_mallocs_total 8.96236e+07
# HELP go_memstats_mcache_inuse_bytes Number of bytes in use by mcache structures.
# TYPE go_memstats_mcache_inuse_bytes gauge
go_memstats_mcache_inuse_bytes 6912
# HELP go_memstats_mcache_sys_bytes Number of bytes used for mcache structures obtained from system.
# TYPE go_memstats_mcache_sys_bytes gauge
go_memstats_mcache_sys_bytes 16384
# HELP go_memstats_mspan_inuse_bytes Number of bytes in use by mspan structures.
# TYPE go_memstats_mspan_inuse_bytes gauge
go_memstats_mspan_inuse_bytes 2.9181872e+07
# HELP go_memstats_mspan_sys_bytes Number of bytes used for mspan structures obtained from system.
# TYPE go_memstats_mspan_sys_bytes gauge
go_memstats_mspan_sys_bytes 3.4471936e+07
# HELP go_memstats_next_gc_bytes Number of heap bytes when next garbage collection will take place.
# TYPE go_memstats_next_gc_bytes gauge
go_memstats_next_gc_bytes 2.527974448e+09
# HELP go_memstats_other_sys_bytes Number of bytes used for other system allocations.
# TYPE go_memstats_other_sys_bytes gauge
go_memstats_other_sys_bytes 4.479293e+06
# HELP go_memstats_stack_inuse_bytes Number of bytes in use by the stack allocator.
# TYPE go_memstats_stack_inuse_bytes gauge
go_memstats_stack_inuse_bytes 1.179648e+06
# HELP go_memstats_stack_sys_bytes Number of bytes obtained from system for stack allocator.
# TYPE go_memstats_stack_sys_bytes gauge
go_memstats_stack_sys_bytes 1.179648e+06
# HELP go_memstats_sys_bytes Number of bytes obtained from system.
# TYPE go_memstats_sys_bytes gauge
go_memstats_sys_bytes 2.549705336e+09
# HELP go_threads Number of OS threads created.
# TYPE go_threads gauge
go_threads 15
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 67.81
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 65536
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 3505
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 3.342630912e+09
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1.6735316038e+09
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 9.414549504e+09

Last updated