# API Reference

{% hint style="info" %}
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
{% endhint %}

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

{% hint style="info" %}
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.
{% endhint %}

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

## Management

## Status

<mark style="color:blue;">`GET`</mark> `https://localhost:8282/api/agent/status`

Show agent's status, version, and properties.

{% tabs %}
{% tab title="200: OK Status and attributes" %}
{% code title="Output example" %}

```json
{
    "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
    }
}
```

{% endcode %}
{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}
{% endtabs %}

## Stop

<mark style="color:orange;">`PUT`</mark> `https://localhost:8282/api/agent/stop`

Stop the agent.

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

{% tabs %}
{% tab title="200: OK Status and attributes" %}

```json
{
"status": "Agent stopped"
}
```

{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}
{% endtabs %}

## Port Number

<mark style="color:purple;">`PATCH`</mark> `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

| Name                                   | Type   | Description |
| -------------------------------------- | ------ | ----------- |
| port<mark style="color:red;">\*</mark> | Number | New port    |

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

{% tabs %}
{% tab title="200: OK OK" %}

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

{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}
{% endtabs %}

## Table Monitoring Limit

<mark style="color:purple;">`PATCH`</mark> `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 ](https://docs.datasentinel.io/manual/implementation/agent-usage/collection-level)section for more details.

#### Path Parameters

| Name                                    | Type   | Description  |
| --------------------------------------- | ------ | ------------ |
| limit<mark style="color:red;">\*</mark> | Number | Limit number |

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

{% tabs %}
{% tab title="200: OK OK" %}

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

{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}
{% endtabs %}

## Query Monitoring Limit

<mark style="color:purple;">`PATCH`</mark> `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 ](https://docs.datasentinel.io/manual/implementation/agent-usage/collection-level)section for more details.

#### Path Parameters

| Name                                    | Type   | Description  |
| --------------------------------------- | ------ | ------------ |
| limit<mark style="color:red;">\*</mark> | Number | Limit number |

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

{% tabs %}
{% tab title="200: OK OK" %}

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

{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}
{% endtabs %}

## Upload Server

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

## Set attributes

<mark style="color:orange;">`PUT`</mark> `https://localhost:8282/api/server`

This is the server where metrics are sent

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

#### Request Body

| Name                                   | Type   | Description                                                                       |
| -------------------------------------- | ------ | --------------------------------------------------------------------------------- |
| host<mark style="color:red;">\*</mark> | String | Server Name of the hosting platform                                               |
| port<mark style="color:red;">\*</mark> | Number | <p>Platform Listening Port.<br>By default, the platform operates on port 443.</p> |

{% tabs %}
{% tab title="200: OK OK" %}

```json
{
    "status": "OK"
}
```

{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}
{% endtabs %}

```bash
// 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

<mark style="color:blue;">`GET`</mark> `https://localhost:8282/api/server`

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

{% tabs %}
{% tab title="200: OK Status and attributes" %}
{% code title="Output example" %}

```json
{
    "host": "demo.datasentinel.io",
    "port": 443
}
```

{% endcode %}
{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}
{% endtabs %}

## Test Upload&#x20;

<mark style="color:green;">`POST`</mark> `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.

{% tabs %}
{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="201: Created In case of an error, the corresponding message will be shown in the response." %}

```json
{
    "status": "OK"
}
```

{% endtab %}
{% endtabs %}

## Proxy

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

## Set attributes

<mark style="color:green;">`POST`</mark> `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

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

#### Request Body

| Name                                   | Type   | Description                                                                       |
| -------------------------------------- | ------ | --------------------------------------------------------------------------------- |
| host<mark style="color:red;">\*</mark> | String | Server Name of the hosting platform                                               |
| port<mark style="color:red;">\*</mark> | Number | <p>Platform Listening Port.<br>By default, the platform operates on port 443.</p> |
| user                                   | String | User name                                                                         |
| password                               | String | Password                                                                          |

{% tabs %}
{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="201: Created " %}

```json
{
"status": "Proxy set"
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}
{% endtabs %}

```bash
// 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

<mark style="color:blue;">`GET`</mark> `https://localhost:8282/api/proxy`

Proxy attributes

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

{% tabs %}
{% tab title="200: OK Status and attributes" %}
{% code title="Output example" %}

```json
{
    "host": "proxy-server",
    "port": 45215,
    "user": "",
    "password": ""
}
```

{% endcode %}
{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}
{% endtabs %}

<mark style="color:red;">`DELETE`</mark> `https://localhost:8282/api/proxy`

Delete proxy

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel License Key |

{% tabs %}
{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="200: OK " %}

```json
{
    "status": "OK"
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}
{% endtabs %}

## Connections

## Show Connections

<mark style="color:blue;">`GET`</mark> `https://localhost:8282/api/connections`

Display declared connections and their attributes

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

{% tabs %}
{% tab title="200: OK Status and attributes" %}
{% code title="Output example" %}

```json
[
    {
        "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
    }
]
```

{% endcode %}
{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}
{% endtabs %}

## Enable All

<mark style="color:purple;">`PATCH`</mark> `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

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

{% tabs %}
{% tab title="200: OK Status and attributes" %}
{% code title="Output example" %}

```json
{
    "status": "OK"
}
```

{% endcode %}
{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}
{% endtabs %}

## Disable All

<mark style="color:purple;">`PATCH`</mark> `https://localhost:8282/api/connections/disable`

Deactivate all connections and disconnect them.

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

{% tabs %}
{% tab title="200: OK Status and attributes" %}
{% code title="Output example" %}

```json
{
    "status": "OK"
}
```

{% endcode %}
{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}
{% endtabs %}

## Connection

## Add Connection

<mark style="color:green;">`POST`</mark> `https://localhost:8282/api/connections/{connection_name}`

Create a new connection, establishing it, and Initiate monitoring

#### Path Parameters

| Name                                               | Type   | Description           |
| -------------------------------------------------- | ------ | --------------------- |
| connection\_name<mark style="color:red;">\*</mark> | String | Connection Identifier |

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

#### Request Body

| Name                                   | Type   | Description                                                                                               |
| -------------------------------------- | ------ | --------------------------------------------------------------------------------------------------------- |
| host<mark style="color:red;">\*</mark> | String | Hostname for connection                                                                                   |
| port<mark style="color:red;">\*</mark> | Number | Indicate the port used for communication with the PostgreSQL cluster.                                     |
| user<mark style="color:red;">\*</mark> | String | PostgreSQL user used by Datasentinel for monitoring                                                       |
| password                               | String | User password                                                                                             |
| tags<mark style="color:red;">\*</mark> | String | <p>Tags linked with the instance. Tags should follow the format \[key=value],....<br><br>Can be empty</p> |

{% tabs %}
{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="201: Created " %}

```json
{
  "status": "Connection created and connected!"
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}
{% endtabs %}

```bash
// 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

<mark style="color:blue;">`GET`</mark> `https://localhost:8282/api/connections/{connection_name}`

Display Connection Attributes

#### Path Parameters

| Name                                               | Type   | Description     |
| -------------------------------------------------- | ------ | --------------- |
| connection\_name<mark style="color:red;">\*</mark> | String | Connection name |

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

{% tabs %}
{% tab title="200: OK Status and attributes" %}
{% code title="Output example" %}

```json
{
    "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
}
```

{% endcode %}
{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="404: Not Found Connection name not found" %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}
{% endtabs %}

## Update Connection

<mark style="color:orange;">`PUT`</mark> `https://localhost:8282/api/connections/{connection_name}`

Update connection attributes

#### Path Parameters

| Name                                               | Type   | Description           |
| -------------------------------------------------- | ------ | --------------------- |
| connection\_name<mark style="color:red;">\*</mark> | String | Connection Identifier |

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

#### Request Body

| Name     | Type   | Description                                                                                               |
| -------- | ------ | --------------------------------------------------------------------------------------------------------- |
| 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 | <p>Tags linked with the instance. Tags should follow the format \[key=value],....<br><br>Can be empty</p> |

{% tabs %}
{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}

{% tab title="200: OK " %}

```json
{
  "status": "Connection updated!"
}
```

{% endtab %}
{% endtabs %}

<mark style="color:red;">`DELETE`</mark> `https://localhost:8282/api/connections/{connection_name}`

Delete Connection

#### Path Parameters

| Name                                               | Type   | Description     |
| -------------------------------------------------- | ------ | --------------- |
| connection\_name<mark style="color:red;">\*</mark> | String | Connection name |

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

{% tabs %}
{% tab title="200: OK " %}

```json
{
  "status": "Connection deleted!"
}
```

{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="404: Not Found Connection name not found" %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}
{% endtabs %}

## Enable

<mark style="color:purple;">`PATCH`</mark> `https://localhost:8282/api/connections/{connection_name}/enable`

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

#### Path Parameters

| Name                                               | Type   | Description     |
| -------------------------------------------------- | ------ | --------------- |
| connection\_name<mark style="color:red;">\*</mark> | String | Connection name |

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

{% tabs %}
{% tab title="200: OK Status and attributes" %}

```json
{
    "status": "Connection enabled!"
}
```

{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="404: Not Found Connection name not found" %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}
{% endtabs %}

## Disable

<mark style="color:purple;">`PATCH`</mark> `https://localhost:8282/api/connections/{connection_name}/disable`

Disable the connection and perform a disconnection

#### Path Parameters

| Name                                               | Type   | Description     |
| -------------------------------------------------- | ------ | --------------- |
| connection\_name<mark style="color:red;">\*</mark> | String | Connection name |

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

{% tabs %}
{% tab title="200: OK Status and attributes" %}

```json
{
    "status": "Connection disabled!"
}
```

{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="404: Not Found Connection name not found" %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}
{% endtabs %}

##

## 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.<br>

{% content-ref url="collection-level" %}
[collection-level](https://docs.datasentinel.io/manual/implementation/agent-usage/collection-level)
{% endcontent-ref %}

{% hint style="info" %}
Collection Level settings are displayed within the connection properties.
{% endhint %}

### Query samples

## Enable

<mark style="color:purple;">`PATCH`</mark> `https://localhost:8282/api/connections/{connection_name}/enable-samples`

Activate query sample collection. \
Refer to the [Collection Level](https://docs.datasentinel.io/manual/implementation/collection-level#query-samples) section specifically dedicated to query samples for detailed instructions.

#### Path Parameters

| Name                                               | Type   | Description     |
| -------------------------------------------------- | ------ | --------------- |
| connection\_name<mark style="color:red;">\*</mark> | String | Connection name |

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

{% tabs %}
{% tab title="200: OK Status and attributes" %}

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

{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="404: Not Found Connection name not found" %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}
{% endtabs %}

## Disable

<mark style="color:purple;">`PATCH`</mark> `https://localhost:8282/api/connections/{connection_name}/disable-samples`

Deactivate query sample collection. \
Refer to the [Collection Level](https://docs.datasentinel.io/manual/implementation/collection-level#query-samples) section specifically dedicated to query samples for detailed instructions.

#### Path Parameters

| Name                                               | Type   | Description     |
| -------------------------------------------------- | ------ | --------------- |
| connection\_name<mark style="color:red;">\*</mark> | String | Connection name |

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

{% tabs %}
{% tab title="200: OK Status and attributes" %}

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

{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="404: Not Found Connection name not found" %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}
{% endtabs %}

### Lock Monitoring

## Enable

<mark style="color:purple;">`PATCH`</mark> `https://localhost:8282/api/connections/{connection_name}/enable-lock-monitoring`

Enable Lock Monitoring. \
Refer to the [Collection Level](https://docs.datasentinel.io/manual/implementation/collection-level#lock-monitoring) section specifically dedicated to lock monitoring for detailed instructions.

#### Path Parameters

| Name                                               | Type   | Description     |
| -------------------------------------------------- | ------ | --------------- |
| connection\_name<mark style="color:red;">\*</mark> | String | Connection name |

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

{% tabs %}
{% tab title="200: OK Status and attributes" %}

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

{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="404: Not Found Connection name not found" %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}
{% endtabs %}

## Disable

<mark style="color:purple;">`PATCH`</mark> `https://localhost:8282/api/connections/{connection_name}/disable-lock-monitoring`

Disable Lock Monitoring \
Refer to the [Collection Level](https://docs.datasentinel.io/manual/implementation/collection-level#lock-monitoring) section specifically dedicated to lock monitoring for detailed instructions.

#### Path Parameters

| Name                                               | Type   | Description     |
| -------------------------------------------------- | ------ | --------------- |
| connection\_name<mark style="color:red;">\*</mark> | String | Connection name |

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

{% tabs %}
{% tab title="200: OK Status and attributes" %}

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

{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="404: Not Found Connection name not found" %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}
{% endtabs %}

## Delay

<mark style="color:purple;">`PATCH`</mark> `https://localhost:8282/api/connections/{connection_name}/lock-monitoring-delay/{seconds}`

Change Lock Monitoring Delay.\
Refer to the [Collection Level](https://docs.datasentinel.io/manual/implementation/collection-level#lock-monitoring) section specifically dedicated to lock monitoring for detailed instructions.

#### Path Parameters

| Name                                               | Type   | Description       |
| -------------------------------------------------- | ------ | ----------------- |
| connection\_name<mark style="color:red;">\*</mark> | String | Connection name   |
| seconds<mark style="color:red;">\*</mark>          | Number | Number of seconds |

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

{% tabs %}
{% tab title="200: OK Status and attributes" %}
{% code title="Output example" %}

```json
{
  "status": "Lock monitoring delay updated to value 90s"
}

```

{% endcode %}
{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="404: Not Found Connection name not found" %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}
{% endtabs %}

### Table Monitoring

## Enable

<mark style="color:purple;">`PATCH`</mark> `https://localhost:8282/api/connections/{connection_name}/enable-table-monitoring`

Activate Table Monitoring. \
Refer to the [Collection Level](https://docs.datasentinel.io/manual/implementation/collection-level#table-monitoring) section specifically dedicated to table monitoring for detailed instructions.

#### Path Parameters

| Name                                               | Type   | Description     |
| -------------------------------------------------- | ------ | --------------- |
| connection\_name<mark style="color:red;">\*</mark> | String | Connection name |

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

{% tabs %}
{% tab title="200: OK Status and attributes" %}

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

{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="404: Not Found Connection name not found" %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}
{% endtabs %}

## Disable

<mark style="color:purple;">`PATCH`</mark> `https://localhost:8282/api/connections/{connection_name}/disable-table-monitoring`

Deactivate Table Monitoring. \
Refer to the [Collection Level](https://docs.datasentinel.io/manual/implementation/collection-level#table-monitoring) section specifically dedicated to table monitoring for detailed instructions.

#### Path Parameters

| Name                                               | Type   | Description     |
| -------------------------------------------------- | ------ | --------------- |
| connection\_name<mark style="color:red;">\*</mark> | String | Connection name |

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

{% tabs %}
{% tab title="200: OK Status and attributes" %}

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

{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="404: Not Found Connection name not found" %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}
{% endtabs %}

### Query Monitoring

## Enable

<mark style="color:purple;">`PATCH`</mark> `https://localhost:8282/api/connections/{connection_name}/enable-query-monitoring`

Activate Query Monitoring. \
Refer to the [Collection Level](https://docs.datasentinel.io/manual/implementation/collection-level#query-monitoring) section specifically dedicated to query monitoring for detailed instructions.

#### Path Parameters

| Name                                               | Type   | Description     |
| -------------------------------------------------- | ------ | --------------- |
| connection\_name<mark style="color:red;">\*</mark> | String | Connection name |

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

{% tabs %}
{% tab title="200: OK Status and attributes" %}

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

{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="404: Not Found Connection name not found" %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}
{% endtabs %}

## Disable

<mark style="color:purple;">`PATCH`</mark> `https://localhost:8282/api/connections/{connection_name}/disable-query-monitoring`

Deactivate Query Monitoring. \
Refer to the [Collection Level](https://docs.datasentinel.io/manual/implementation/collection-level#query-monitoring) section specifically dedicated to query monitoring for detailed instructions.

#### Path Parameters

| Name                                               | Type   | Description     |
| -------------------------------------------------- | ------ | --------------- |
| connection\_name<mark style="color:red;">\*</mark> | String | Connection name |

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

{% tabs %}
{% tab title="200: OK Status and attributes" %}

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

{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="404: Not Found Connection name not found" %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}
{% endtabs %}

### Query Filters

## Min Calls

<mark style="color:purple;">`PATCH`</mark> `https://localhost:8282/api/connections/{connection_name}/query-monitoring-min-calls/{min-calls}`

Change the value of Min Calls\
Refer to the [Collection Level](https://docs.datasentinel.io/manual/implementation/collection-level#query-monitoring-filters) section specifically dedicated to query monitoring filters for detailed instructions.

#### Path Parameters

| Name                                               | Type   | Description     |
| -------------------------------------------------- | ------ | --------------- |
| connection\_name<mark style="color:red;">\*</mark> | String | Connection name |
| min-calls                                          | Number | Min calls       |

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

{% tabs %}
{% tab title="200: OK Status and attributes" %}
{% code title="Example output" %}

```json
{
  "status": "Query monitoring min calls updated to value 50"
}
```

{% endcode %}
{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="404: Not Found Connection name not found" %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}
{% endtabs %}

## Min Time

<mark style="color:purple;">`PATCH`</mark> `https://localhost:8282/api/connections/{connection_name}/query-monitoring-min-time/{seconds}`

Change the value of Min Time.\
Refer to the [Collection Level](https://docs.datasentinel.io/manual/implementation/collection-level#query-monitoring-filters) section specifically dedicated to query monitoring filters for detailed instructions.

#### Path Parameters

| Name                                               | Type   | Description     |
| -------------------------------------------------- | ------ | --------------- |
| connection\_name<mark style="color:red;">\*</mark> | String | Connection name |
| seconds                                            | Number | Min time        |

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

{% tabs %}
{% tab title="200: OK Status and attributes" %}
{% code title="Example output" %}

```json
{
  "status": "Query monitoring min time updated to value 10s"
}
```

{% endcode %}
{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="404: Not Found Connection name not found" %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}
{% endtabs %}

### Query Optimize

## Enable

<mark style="color:purple;">`PATCH`</mark> `https://localhost:8282/api/connections/{connection_name}/enable-query-monitoring-optimize`

Activate Query Monitoring Optimization. \
Refer to the [Collection Level](https://docs.datasentinel.io/manual/implementation/collection-level#query-monitoring-optimize) section specifically dedicated to query monitoring optimization for detailed instructions.

#### Path Parameters

| Name                                               | Type   | Description     |
| -------------------------------------------------- | ------ | --------------- |
| connection\_name<mark style="color:red;">\*</mark> | String | Connection name |

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

{% tabs %}
{% tab title="200: OK Status and attributes" %}

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

{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="404: Not Found Connection name not found" %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}
{% endtabs %}

## Disable

<mark style="color:purple;">`PATCH`</mark> `https://localhost:8282/api/connections/{connection_name}/disable-query-monitoring-optimize`

Deactivate Query Monitoring Optimization. \
Refer to the [Collection Level](https://docs.datasentinel.io/manual/implementation/collection-level#query-monitoring-optimize) section specifically dedicated to query monitoring optimization for detailed instructions.

#### Path Parameters

| Name                                               | Type   | Description     |
| -------------------------------------------------- | ------ | --------------- |
| connection\_name<mark style="color:red;">\*</mark> | String | Connection name |

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| api-token<mark style="color:red;">\*</mark> | String | Datasentinel license key |

{% tabs %}
{% tab title="200: OK Status and attributes" %}

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

{% endtab %}

{% tab title="500: Internal Server Error Internal error" %}

{% endtab %}

{% tab title="404: Not Found Connection name not found" %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}
{% endtabs %}
