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.
Prerequisites
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'
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
Status
datasentinelstatusagent
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
Start
datasentinelstartagent
Response
Copyright 2023 (c) datasentinel- All rights reserved www.datasentinel.io
================================================================================
Starting the agent...
To show the status : datasentinel status agent
Stop
datasentinelstopagent
Response
Copyright 2023 (c) datasentinel- All rights reserved www.datasentinel.io
================================================================================
The agent is stopped!
Change Port Number
By default, the agent is configured to listen on port 8282, enabling API or CLI calls to be made.
datasentinelsetport9121
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
Change Table Monitoring Limit
datasentinelsettables-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
Change Query monitoring Limit
Since agent version 3.2
datasentinelsetquery-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
Upload Server
The Upload Server refers to the server name of the platform where metrics are transmitted.
Set
Change the server where metrics are sent
datasentinelsetserverapp.datasentinel.io443
Response
Copyright 2023 (c) datasentinel- All rights reserved www.datasentinel.io
================================================================================
Server successfully set!
Server
host : app.datasentinel.io
port : 443
Show
Show the platform server where metrics are sent
datasentinelshowserver
Response
Copyright 2023 (c) datasentinel- All rights reserved www.datasentinel.io
================================================================================
Server
host : app.datasentinel.io
port : 443
Test
datasentineltestserver
Response
Copyright 2023 (c) datasentinel- All rights reserved www.datasentinel.io
================================================================================
TEST: The upload server is reachable and up!
Server
host : app.datasentinel.io
port : 443
Token
Set
Configure the authentication token used to access the platform.
This should only be done during initialization. The agent subsequently retrieves updated tokens from the platform.
datasentinelsettoken<tokenvalue>
Response
Copyright 2023 (c) Datasentinel- All rights reserved www.datasentinel.io
================================================================================
Token successfully set!
Server
host : app.datasentinel.io
port : 443
Show
After testing the token on the platform's upload server, the validity date of the token is provided.
datasentinelshowtoken
Response
Copyright 2023 (c) Datasentinel- All rights reserved www.datasentinel.io
================================================================================
Token : <token value>
Organization : ds-data
Expiration Date : 2023-07-22 18:09:29
Proxy
Under certain circumstances, an intermediary proxy server is required to establish a connection between the agent and the platform server.
Set
create a json file with proxy settings and update the agent
Copyright 2023 (c) datasentinel- All rights reserved www.datasentinel.io
================================================================================
Proxy successfully set!
Proxy
host : myProxyHostName
port : 4587
user :
password :
Show
datasentinelshowproxy
Response
Copyright 2023 (c) datasentinel- All rights reserved www.datasentinel.io
================================================================================
Proxy
host : hostname
port : 4587
user :
password :
Delete
datasentineldeleteproxy
Response
Copyright 2023 (c) datasentinel- All rights reserved www.datasentinel.io
================================================================================
Proxy successfully deleted!
Proxy
host :
port : 0
user :
password :
Connections
Show
datasentinelshowconnections
Response
Copyright 2023 (c) datasentinel- All rights reserved www.datasentinel.io
================================================================================
name status state host port user
--------------------------------------------------------------------------------
:9342 enabled running pg-sales-1734 9342 datasentinel
tags : application=sales,environment=production,provider=amazon,datacenter=lyon
Enable All
datasentinelenableall
Response
Copyright 2023 (c) datasentinel- All rights reserved www.datasentinel.io
================================================================================
Connections enabled!
name status state host port user
--------------------------------------------------------------------------------
:9342 enabled running pg-sales-1734 9342 datasentinel
tags : application=sales,environment=production,provider=amazon,datacenter=lyon
Disable All
datasentineldisableall
Response
Copyright 2023 (c) datasentinel- All rights reserved www.datasentinel.io
================================================================================
Connections disabled!
name status state host port user
--------------------------------------------------------------------------------
:9342 disabled not running pg-sales-1734 9342 datasentinel
tags : application=sales,environment=production,provider=amazon,datacenter=lyon
Copyright 2023 (c) datasentinel- All rights reserved www.datasentinel.io
================================================================================
Connection added!
Name : myNewConnection
Status : enabled
State : connected
Host : pg-sales-1734
Port : 9342
user : datasentinel
password : sentinel
Lock monitoring : on
Lock monitoring delay : 30s
Table monitoring : on
Query samples : off
Query monitoring : on
Optimize : on
Min calls : 2
Min time : 1s
tags : application=sales,environment=production,provider=amazon,datacenter=lyon
Show
datasentinelshowconnectionmyNewConnection
Parameter
The connection name
Response
Copyright 2023 (c) datasentinel- All rights reserved www.datasentinel.io
================================================================================
Name : myNewConnection
Status : enabled
State : connected
Host : pg-sales-1734
Port : 9342
user : datasentinel
password : sentinel
Lock monitoring : on
Lock monitoring delay : 30s
Table monitoring : on
Query samples : off
Query monitoring : on
Optimize : on
Min calls : 2
Min time : 1s
tags : application=sales,environment=production,provider=amazon,datacenter=lyon
Copyright 2023 (c) datasentinel- All rights reserved www.datasentinel.io
================================================================================
Connection successfully deleted!
Enable
Activate the connection and initiate connection attempts in order to start monitoring
datasentinelenableconnectionmyNewConnection
Parameter
The connection name
Response
Copyright 2023 (c) datasentinel- All rights reserved www.datasentinel.io
================================================================================
Connection enabled!
Name : myNewConnection
Status : enabled
State : connected
Host : pg-sales-1734
Port : 9342
user : datasentinel
password : sentinel
Lock monitoring : on
Lock monitoring delay : 30s
Table monitoring : on
Query samples : off
Query monitoring : on
Optimize : on
Min calls : 2
Min time : 1s
tags : application=sales,environment=production,provider=amazon,datacenter=lyon
Disable
datasentinel disable connection myNewConnection
Parameter
The connection name
Response
Copyright 2023 (c) datasentinel- All rights reserved www.datasentinel.io
================================================================================
Connection disabled!
Name : myNewConnection
Status : enabled
State : connected
Host : pg-sales-1734
Port : 9342
user : datasentinel
password : sentinel
Lock monitoring : on
Lock monitoring delay : 30s
Table monitoring : on
Query samples : off
Query monitoring : on
Optimize : on
Min calls : 2
Min time : 1s
tags : application=sales,environment=production,provider=amazon,datacenter=lyon
Copyright 2023 (c) datasentinel- All rights reserved www.datasentinel.io
================================================================================
Connection updated!
Name : myNewConnection
Status : enabled
State : connected
Host : pg-sales-1734
Port : 9342
user : datasentinel
password : sentinel
Lock monitoring : on
Lock monitoring delay : 30s
Table monitoring : on
Query samples : off
Query monitoring : on
Optimize : on
Min calls : 2
Min time : 1s
tags : application=sales,environment=production,provider=amazon,datacenter=lyon
Collection Level
The Agent Version 3.2 introduces the Collection Level feature, which was released in February 2023 and allows you to choose the metrics to monitor.
The Query Optimize feature fetches queries from pg_stat_statements, filtered by minimum calls or minimum total execution time, groups similar queries, and shows the optimization gain at each level.