Shardman is a critical point in your infrastructure, as it stores all of your data. This makes logging mandatory. So you should understand how logging works in Shardman. Due to the complexity of Shardman, it supports several logging directions. First, logs from the shardmand daemon that manages the cluster configuration. Second, logs from PostgreSQL database instances.
Shardman uses standard PostgreSQL
logging settings described here.
Logging settings should be placed to
sdmspec.json in the
pgParameters section as shown in the example below:
{
"ShardSpec": {
"pgParameters": {
"log_line_prefix": "%m [%r][%p]",
"log_min_messages": "INFO",
"log_statement": "none",
"log_destination": "stderr",
"log_filename": "pg.log",
"logging_collector": "on",
"log_checkpoints": "false",
...
},
...
},
...
}
By default, logics are placed in the directory like this
/var/lib/pgpro/sdm-14/data/keeper-cluster0-clover-1-shrn1-0/postgres/log.
In this example, cluster0 is the current cluster,
clover-1-shrn1 is the name of the current shard,
0 is the identifier of the integrated keeper process.
To change the log directory, set the log_directory parameter.
shardmand
is a systemd unit,
its logs are written to journald. You can use
journalctl to examine it.
For example, you can use the following command:
$ journalctl -u shardmand@cluster0.service
You can filter by arbitrary time limits using the --since and
--until options, which restrict the entries displayed to those
after or before the given time, respectively. The time values can come in a variety
of formats. For absolute time values, you should use YYYY-MM-DD HH:MM:SS.
For instance, we can see all of the entries since January 10th, 2023 at 5:15 PM by typing:
$ journalctl -u shardmand@cluster0.service --since "2023-01-10 17:15:00"
If components of the above format are left off, some defaults will be applied. For instance, if the date is omitted, the current date will be assumed. If the time component is missing, “00:00:00” (midnight) will be substituted. The seconds field can be left off as well to default to “00”:
$ journalctl -u shardmand@cluster0.service --since "2023-01-10" --until "2023-01-11 03:00"
To control the log verbosity for all Shardman services, set
SDM_LOG_LEVEL in the shardmand configuration file.