Comment on page
⌨
CLI
The agent offers a CLI for conveniently modifying attributes and connections.
The agent stores its configuration in the hidden .datasentinel directory within the user's home directory, using two files: agent.yml and connections.yml.
These files can be manually managed if necessary.
Enable the execution of the CLI
- Using an alias
alias datasentinel='DATASENTINEL_PATH=<<INSTALL_DIRECTORY>>/datasentinel;LD_LIBRARY_PATH=$DATASENTINEL_PATH/lib/ $DATASENTINEL_PATH/datasentinel'
- Using environment variables
export DATASENTINEL_PATH="<<INSTALL_DIRECTORY>>/datasentinel"
export LD_LIBRARY_PATH=$DATASENTINEL_PATH/lib:$LD_LIBRARY_PATH
export PATH=$DATASENTINEL_PATH:$PATH
- Simply enter the datasentinel command.
datasentinel
Response
Copyright 2023 (c) Datasentinel- All rights reserved www.datasentinel.io
================================================================================
Agent:
- start agent
- stop agent
- status agent
- show metrics
Show internal agent metrics and cache activity
- set port <port number>
- set collection-rate <low|high>
low: The sessions collection is done every 10 seconds
high: The sessions collection is done every second (Default value)
If the datasentinel extension is not installed, the collection-rate is automatically adjusted to low value
- set tables-monitoring-limit (default 1000)
The agent monitors the activity of tables and indexes if the number of tables in the connection is less than the defined limit
- set query-monitoring-limit (default 10000)
The agent tracks query activity, storing unique IDs in a daily cache. Exceeding limit triggers automatic deactivation of query monitoring.
Connections: when the connections are disabled, the agent is disconnected.
- enable all
- disable all
Connection:
- add connection <name> -f <json file>
- update connection <name> -f <json file>
json example: {
"host": "hostname",
"port": 4587,
"user": "username",
"password": "value",
"tags": "key=value,key=value,..."
}
- update connection <name> samples <on|off> (default off)
Collect and send sample queries, with literal values if present
- update connection <name> lock-monitoring <on|off> (default on)
Scan blocking sessions (longer than lock-monitoring-delay) and send blocking reports
- update connection <name> lock-monitoring-delay <seconds> (default 30)
Minimum number of seconds before triggering a blocking scenario
- update connection <name> table-monitoring <on|off> (default on)
Monitor the activity of tables and indexes (The number of tables must be lower than the maximum limit set at the agent level (default 1000)
- update connection <name> query-monitoring <on|off> (default on)
Monitor pg_stat_statements query activity
- update connection <name> query-monitoring-optimize <on|off> (default on)
Group similar pg_stat_statements queries
- update connection <name> query-monitoring-min-calls <calls> (default 2)
- update connection <name> query-monitoring-min-time <seconds> (default 1)
Retrieve pg_stat_statements queries executed n times (calls) or with total execution time exceeding specified seconds
- update connection <name> test-query-monitoring-optimize
Test and optimize pg_stat_statements query contents with previous parameters, display results
- delete connection <name>
- enable connection <name>
- disable connection <name>
- show connections
- show connection <name>
Dump connection in JSON format:
- dump connection <name>
Upload server:
- set server <host> <port>
- show server
- test server
Token:
- set token <value>
- show token
Proxy:
- set proxy -f <json file>
json example: {
"host": "hostname",
"port": 4587,
"user": "username (optional)",
"password": "value (optional)"
}
- delete proxy
- show proxy
datasentinel status agent
Response
Copyright 2023 (c) Datasentinel- All rights reserved www.datasentinel.io
================================================================================
Agent
Version : 3.2.0
Server : pgsentinel.localdomain
Port : 8282
Start time : 2023-01-31 13:08:27
Collection rate : high
Table monitoring limit : 2500
Query monitoring limit : 35000
Sql max size : 7512453
Proxy
host :
port : 0
user :
password :
Upload
host : 163.172.135.154
port : 443
Connections
declared : 2
running : 1
not running : 1
datasentinel start agent
Response
Copyright 2023 (c) datasentinel- All rights reserved www.datasentinel.io
================================================================================
Starting the agent...
To show the status : datasentinel status agent
datasentinel stop agent
Response
Copyright 2023 (c) datasentinel- All rights reserved www.datasentinel.io
================================================================================
The agent is stopped!
By default, the agent is configured to listen on port 8282, enabling API or CLI calls to be made.
datasentinel set port 9121
Response
Copyright 2023 (c) datasentinel- All rights reserved www.datasentinel.io
================================================================================
Agent port successfully set! The agent has been stopped, you need to restart it
datasentinel set tables-monitoring-limit <limit>
- Parameter:The limit number. The agent tracks the activity of tables and indexes if the connection’s table count is below the set limit (default 1000).
Response
Copyright 2023 (c) datasentinel- All rights reserved www.datasentinel.io
================================================================================
Tables monitoring limit successfully set to 3000!
Agent
Version : 3.2.0
Server : pgsentinel.localdomain
Port : 8282
Start time : 2023-01-31 13:08:27
Collection rate : low
Table monitoring limit : 2500
Query monitoring limit : 35000
Sql max size : 7512453
Proxy
host :
port : 0
user :
password :
Upload
host : 163.172.135.154
port : 443
Connections
declared : 2
running : 1
not running : 1
Since agent version 3.2
datasentinel set query-monitoring-limit <limit>
- Parameter:The limit number. The agent tracks query activity, storing unique IDs in a daily cache. Exceeding limit triggers automatic deactivation of query monitoring. (default 30000)
Response
Copyright 2023 (c) datasentinel- All rights reserved www.datasentinel.io
================================================================================
Tables monitoring limit successfully set to 3000!
Agent
Version : 3.2.0
Server : pgsentinel.localdomain
Port : 8282
Start time : 2023-01-31 13:08:27
Collection rate : low
Table monitoring limit : 2500
Query monitoring limit : 35000
Sql max size : 7512453
Proxy
host :
port : 0
user :
password :
Upload
host : 163.172.135.154
port : 443
Connections
declared : 2
running : 1
not running : 1
The Upload Server refers to the server name of the platform where metrics are transmitted.
- Change the server where metrics are sent
datasentinel set server app.datasentinel.io 443
Response
Copyright 2023 (c) datasentinel- All rights reserved www.datasentinel.io
================================================================================
Server successfully set!