🧩API

The agent's setup is adjustable using direct API invocations, facilitating interactive information retrieval and interaction.

Agent API can be reached at https://<<host_name>>:<<port_number>> host_name: Refers to the host where the agent is installed (or localhost if used locally). port_number: By default, the agent listens on port 8282, which can be updated as needed

Examples are demonstrated using localhost as the host name and the default port number 8282.

Certain operations necessitate a header token for transmission to the agent. This token aligns with the agent's license key and the platform it operates on.

// example
export TOKEN=<<datasentinel_token>> 
curl -k --header "api-token: $TOKEN" --request PUT   https://localhost:8282/api/agent/stop'

Management

Status

GET https://localhost:8282/api/agent/status

Show agent's status, version, and properties.

Output example
{
    "version": "3.4.1",
    "server": "pg-sales-3127",
    "port": 8282,
    "last_upload": "",
    "collection-rate": "low",
    "remove_proxy_os_env": false,
    "tables-monitoring-limit": 1000,
    "query-monitoring-limit": 30000,
    "sql-max-size": 256000,
    "start_time": "2023-08-22 14:52:12",
    "proxy": {
        "host": "",
        "port": 0,
        "user": "",
        "password": ""
    },
    "upload_server": {
        "host": "51.15.237.231",
        "port": 443
    },
    "connections": {
        "connections": 1,
        "running": 1,
        "not running": 0
    }
}

Stop

PUT https://localhost:8282/api/agent/stop

Stop the agent.

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

{
"status": "Agent stopped"
}

Port Number

PATCH https://localhost:8282/api/agent/port/{port}

Modify the port number that the agent listens on. The agent is stopped after the modification. Start it again to apply the new port configuration.

Path Parameters

NameTypeDescription

port*

Number

New port

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

{
"status": "Port changed successfully! The agent has been stopped. You need to restart it."
}

Table Monitoring Limit

PATCH https://localhost:8282/api/agent/tables-monitoring-limit/{limit}

The agent monitors table and index activities when the connection's table count remains below the specified limit (default: 1000).

Refer to the Collection Level section for more details.

Path Parameters

NameTypeDescription

limit*

Number

Limit number

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

{
    "status": "Tables monitoring limit successfully changed."
}

Query Monitoring Limit

PATCH https://localhost:8282/api/agent/query-monitoring-limit/{limit}

The agent monitors query activity by storing unique IDs in a daily cache. If the limit is exceeded, this automatically deactivates query monitoring (default: 30000).

Refer to the Collection Level section for more details.

Path Parameters

NameTypeDescription

limit*

Number

Limit number

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

{
    "status": "Query monitoring limit successfully changed."
}

Upload Server

The Upload Server refers to the server name of the platform where metrics are transmitted.

Set attributes

PUT https://localhost:8282/api/server

This is the server where metrics are sent

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

Request Body

NameTypeDescription

host*

String

Server Name of the hosting platform

port*

Number

Platform Listening Port. By default, the platform operates on port 443.

{
    "status": "OK"
}
// Example
cat > body.json << EOF
{
  "host": "demo.datasentinel.io",
  "port": 443
}
EOF

export TOKEN=<<datasentinel_token>>
curl -k --header "api-token: $TOKEN" --header 'Content-Type: application/json' -X PUT https://localhost:8282/api/server -d @body.json

Show attributes

GET https://localhost:8282/api/server

Show server name and port details for the platform where metrics are sent.

Output example
{
    "host": "demo.datasentinel.io",
    "port": 443
}

Test Upload

POST https://localhost:8282/api/server/test-upload

The agent conducts a test to confirm whether the upload server, configured with the specified port, is accessible.

Proxy

Under certain circumstances, an intermediary proxy server is required to establish a connection between the agent and the platform server.

Set attributes

POST https://localhost:8282/api/proxy

The following details pertain to the proxy server. Username and password are optional and can be excluded if not required.

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

Request Body

NameTypeDescription

host*

String

Server Name of the hosting platform

port*

Number

Platform Listening Port. By default, the platform operates on port 443.

user

String

User name

password

String

Password

// Example
cat > body.json << EOF
{
  "host": "proxy-server",
  "port": 12443,
  "user": "",
  "password": ""
}
EOF

export TOKEN=<<datasentinel_token>>
curl -k --header "api-token: $TOKEN" --header 'Content-Type: application/json' -X POST https://localhost:8282/api/proxy -d @body.json

Show attributes

GET https://localhost:8282/api/proxy

Proxy attributes

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

Output example
{
    "host": "proxy-server",
    "port": 45215,
    "user": "",
    "password": ""
}

DELETE https://localhost:8282/api/proxy

Delete proxy

Headers

NameTypeDescription

api-token*

String

Datasentinel License Key

Connections

Show Connections

GET https://localhost:8282/api/connections

Display declared connections and their attributes

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

Output example
[
    {
        "name": ":9342",
        "host": "pg-sales-3127",
        "port": 9342,
        "user": "datasentinel",
        "password": "sentinel",
        "tags": "application=sales,environment=production,provider=amazon,datacenter=paris",
        "enabled": true,
        "connected": true,
        "collection-rate": "low",
        "samples": false,
        "lock-monitoring": true,
        "lock-monitoring-delay": 30,
        "table-monitoring": true,
        "query-monitoring": true,
        "query-monitoring-optimize": false,
        "query-monitoring-min-calls": 2,
        "query-monitoring-min-time": 1
    }
]

Enable All

PATCH https://localhost:8282/api/connections/enable

Enable all connections and initiate connection attempts for each of them only if they are not already established.

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

Output example
{
    "status": "OK"
}

Disable All

PATCH https://localhost:8282/api/connections/disable

Deactivate all connections and disconnect them.

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

Output example
{
    "status": "OK"
}

Connection

Add Connection

POST https://localhost:8282/api/connections/{connection_name}

Create a new connection, establishing it, and Initiate monitoring

Path Parameters

NameTypeDescription

connection_name*

String

Connection Identifier

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

Request Body

NameTypeDescription

host*

String

Hostname for connection

port*

Number

Indicate the port used for communication with the PostgreSQL cluster.

user*

String

PostgreSQL user used by Datasentinel for monitoring

password

String

User password

tags*

String

Tags linked with the instance. Tags should follow the format [key=value],.... Can be empty

// Example
cat > body.json << EOF
{
    "host": "pg-sales-3127",
    "port": 9342,
    "user": "datasentinel",
    "password": "sentinel",
    "tags": "application=sales,environment=production,provider=amazon,datacenter=paris"
}
EOF

export TOKEN=<<datasentinel_token>>
curl -k --header "api-token: $TOKEN" --header 'Content-Type: application/json' --request POST 'https://localhost:8282/api/connections/sales_prod' -d @body.json

Show Connection

GET https://localhost:8282/api/connections/{connection_name}

Display Connection Attributes

Path Parameters

NameTypeDescription

connection_name*

String

Connection name

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

Output example
{
    "name": "sales-prod",
    "host": "pg-sales-3127",
    "port": 9342,
    "user": "datasentinel",
    "password": "sentinel",
    "tags": "application=sales,environment=production,provider=amazon,datacenter=paris",
    "enabled": true,
    "connected": true,
    "collection-rate": "low",
    "samples": false,
    "lock-monitoring": true,
    "lock-monitoring-delay": 30,
    "table-monitoring": true,
    "query-monitoring": true,
    "query-monitoring-optimize": false,
    "query-monitoring-min-calls": 2,
    "query-monitoring-min-time": 1
}

Update Connection

PUT https://localhost:8282/api/connections/{connection_name}

Update connection attributes

Path Parameters

NameTypeDescription

connection_name*

String

Connection Identifier

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

Request Body

NameTypeDescription

host

String

Hostname for connection

port

Number

Indicate the port used for communication with the PostgreSQL cluster.

user

String

PostgreSQL user used by Datasentinel for monitoring

password

String

User password

tags

String

Tags linked with the instance. Tags should follow the format [key=value],.... Can be empty

DELETE https://localhost:8282/api/connections/{connection_name}

Delete Connection

Path Parameters

NameTypeDescription

connection_name*

String

Connection name

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

{
  "status": "Connection deleted!"
}

Enable

PATCH https://localhost:8282/api/connections/{connection_name}/enable

Activate the connection and initiate connection attempts in order to start monitoring

Path Parameters

NameTypeDescription

connection_name*

String

Connection name

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

{
    "status": "Connection enabled!"
}

Disable

PATCH https://localhost:8282/api/connections/{connection_name}/disable

Disable the connection and perform a disconnection

Path Parameters

NameTypeDescription

connection_name*

String

Connection name

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

{
    "status": "Connection disabled!"
}

Collection Level

The Agent version 3.2, which was released in February 2023, introduces the Collection Level feature allowing you to choose the metrics to monitor.

🗃️Collection Level

Collection Level settings are displayed within the connection properties.

Query samples

Enable

PATCH https://localhost:8282/api/connections/{connection_name}/enable-samples

Activate query sample collection. Refer to the Collection Level section specifically dedicated to query samples for detailed instructions.

Path Parameters

NameTypeDescription

connection_name*

String

Connection name

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

{
  "status": "Query samples enabled!"
}

Disable

PATCH https://localhost:8282/api/connections/{connection_name}/disable-samples

Deactivate query sample collection. Refer to the Collection Level section specifically dedicated to query samples for detailed instructions.

Path Parameters

NameTypeDescription

connection_name*

String

Connection name

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

{
  "status": "Query samples disabled!"
}

Lock Monitoring

Enable

PATCH https://localhost:8282/api/connections/{connection_name}/enable-lock-monitoring

Enable Lock Monitoring. Refer to the Collection Level section specifically dedicated to lock monitoring for detailed instructions.

Path Parameters

NameTypeDescription

connection_name*

String

Connection name

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

{
  "status": "Lock monitoring enabled!"
}

Disable

PATCH https://localhost:8282/api/connections/{connection_name}/disable-lock-monitoring

Disable Lock Monitoring Refer to the Collection Level section specifically dedicated to lock monitoring for detailed instructions.

Path Parameters

NameTypeDescription

connection_name*

String

Connection name

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

{
  "status": "Lock monitoring disabled!"
}

Delay

PATCH https://localhost:8282/api/connections/{connection_name}/lock-monitoring-delay/{seconds}

Change Lock Monitoring Delay. Refer to the Collection Level section specifically dedicated to lock monitoring for detailed instructions.

Path Parameters

NameTypeDescription

connection_name*

String

Connection name

seconds*

Number

Number of seconds

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

Output example
{
  "status": "Lock monitoring delay updated to value 90s"
}

Table Monitoring

Enable

PATCH https://localhost:8282/api/connections/{connection_name}/enable-table-monitoring

Activate Table Monitoring. Refer to the Collection Level section specifically dedicated to table monitoring for detailed instructions.

Path Parameters

NameTypeDescription

connection_name*

String

Connection name

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

{
    "status": "Table monitoring enabled!"
}

Disable

PATCH https://localhost:8282/api/connections/{connection_name}/disable-table-monitoring

Deactivate Table Monitoring. Refer to the Collection Level section specifically dedicated to table monitoring for detailed instructions.

Path Parameters

NameTypeDescription

connection_name*

String

Connection name

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

{
    "status": "Table monitoring disabled!"
}

Query Monitoring

Enable

PATCH https://localhost:8282/api/connections/{connection_name}/enable-query-monitoring

Activate Query Monitoring. Refer to the Collection Level section specifically dedicated to query monitoring for detailed instructions.

Path Parameters

NameTypeDescription

connection_name*

String

Connection name

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

{
    "status": "Query monitoring enabled!"
}

Disable

PATCH https://localhost:8282/api/connections/{connection_name}/disable-query-monitoring

Deactivate Query Monitoring. Refer to the Collection Level section specifically dedicated to query monitoring for detailed instructions.

Path Parameters

NameTypeDescription

connection_name*

String

Connection name

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

{
    "status": "Query monitoring disabled!"
}

Query Filters

Min Calls

PATCH https://localhost:8282/api/connections/{connection_name}/query-monitoring-min-calls/{min-calls}

Change the value of Min Calls Refer to the Collection Level section specifically dedicated to query monitoring filters for detailed instructions.

Path Parameters

NameTypeDescription

connection_name*

String

Connection name

min-calls

Number

Min calls

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

Example output
{
  "status": "Query monitoring min calls updated to value 50"
}

Min Time

PATCH https://localhost:8282/api/connections/{connection_name}/query-monitoring-min-time/{seconds}

Change the value of Min Time. Refer to the Collection Level section specifically dedicated to query monitoring filters for detailed instructions.

Path Parameters

NameTypeDescription

connection_name*

String

Connection name

seconds

Number

Min time

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

Example output
{
  "status": "Query monitoring min time updated to value 10s"
}

Query Optimize

Enable

PATCH https://localhost:8282/api/connections/{connection_name}/enable-query-monitoring-optimize

Activate Query Monitoring Optimization. Refer to the Collection Level section specifically dedicated to query monitoring optimization for detailed instructions.

Path Parameters

NameTypeDescription

connection_name*

String

Connection name

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

{
    "status": "Query monitoring optimize enabled!"
}

Disable

PATCH https://localhost:8282/api/connections/{connection_name}/disable-query-monitoring-optimize

Deactivate Query Monitoring Optimization. Refer to the Collection Level section specifically dedicated to query monitoring optimization for detailed instructions.

Path Parameters

NameTypeDescription

connection_name*

String

Connection name

Headers

NameTypeDescription

api-token*

String

Datasentinel license key

{
    "status": "Query monitoring optimize disabled!"
}

Last updated