Skip to main content

ListRawSessionStates

Retrieves raw statistics on sessions. Corresponds to the pg_stat_activity view.

import { cloudApi, serviceClients, Session } from "@yandex-cloud/nodejs-sdk";

const ListRawSessionStatesRequest =
cloudApi.mdb.postgresql_perf_diag_service.ListRawSessionStatesRequest;

(async () => {
const authToken = process.env["YC_OAUTH_TOKEN"];
const session = new Session({ oauthToken: authToken });
const client = session.client(
serviceClients.PerformanceDiagnosticsServiceClient
);

const result = await client.listRawSessionStates(
ListRawSessionStatesRequest.fromPartial({
clusterId: "clusterId",
// fromTime: {
// seconds: 0,
// nanos: 0
// },
// toTime: {
// seconds: 0,
// nanos: 0
// },
// pageSize: 0,
// pageToken: "pageToken"
})
);
console.log(result);
})();

ListRawSessionStatesRequest​

clusterId : string​

ID of a PostgreSQL cluster to request session statistics for.

To get a PostgreSQL cluster ID, use the ClusterService.List request.

fromTime : google.protobuf.Timestamp​

Beginning of the period for which you need to request data (in the RFC3339 text format).

toTime : google.protobuf.Timestamp​

End of the period for which you need to request data (in the RFC3339 text format).

pageSize : int64​

The maximum number of results per page to return. If the number of the results is larger than page_size, the service returns ListRawSessionStatesResponse.next_page_token. You can use it to get the next page of the results in subsequent requests.

pageToken : string​

Page token. To get the next page of results, set page_token to the ListRawSessionStatesResponse.next_page_token returned by the previous PostgreSQL session list request.

ListRawSessionStatesResponse​

sessionStates : SessionState​

List of PostgreSQL sessions.

nextPageToken : string​

This token allows you to get the next page of results when requesting the PostgreSQL session list. If the number of the results is larger than ListRawSessionStatesRequest.page_size, use the next_page_token as the value for the ListRawSessionStatesRequest.page_token parameter in the next request. Each subsequent request will have its own next_page_token to continue paging through the results.

SessionState​

time : google.protobuf.Timestamp​

Time of collecting statistics on sessions (in the RFC3339 text format).

host : string​

Host of the connected client.

pid : int64​

Server process ID. For client connections, this is a client connection ID.

database : string​

Database ID.

user : string​

User ID.

applicationName : string​

Application name on the connected client.

backendStart : google.protobuf.Timestamp​

Time when a given process was started. For client connections, this is the time when the client connected to the server.

xactStart : google.protobuf.Timestamp​

Time when a transaction of a given process was started. Returns NULL if no transaction is active.

If the currently active query is the first of its transaction, the value of this parameter is equal to the value of the query_start parameter.

queryStart : google.protobuf.Timestamp​

Time when the currently active query was started.

If the state parameter does not take the value active, the parameter returns the time when the lastest query was started.

stateChange : google.protobuf.Timestamp​

Time when the state parameter was last changed.

waitEventType : string​

Type of event for which the backend is waiting. Such an event is called a wait event. A backend refers to the process that maintains the client connection.

For the list of wait events, see the PostgreSQL documentation. If the backend is not waiting for any event, the parameter returns NULL.

waitEvent : string​

Wait event name.

For the list of such names, see the PostgreSQL documentation. If the backend is not waiting for any event, the parameter returns NULL.

state : string​

Current backend state. For the list of possible values, see the PostgreSQL documentation.

query : string​

Text of the most recent query.

If the state parameter takes the value active, the parameter shows the currently executing query. For the rest of the states, the parameter shows the last query that was executed. By default, the query text is truncated to 1024 bytes.

backendType : string​

Current backend type. For the list of possible values, see the PostgreSQL documentation.

clientAddr : string​

IP address of the connected client.

The parameter returns NULL in the following cases:

  • The client is connected via a Unix socket on the server.
  • A given process is internal (for example, autovacuum).
clientHostname : string​

Host name of the connected client (relevant for IP connections).

clientPort : int64​

TCP port number that the client is using for communication with the server.

Returns -1 if the client is connected via a Unix socket on the server. Returns NULL if a given process is internal (for example, autovacuum).

backendXid : int64​

Top-level transaction ID, if any.

backendXmin : int64​

Current [xmin horizon][22].

blockingPids : string​

Process IDs that are blocking a given server process ID.

queryId : string​

Query ID.


[22]: #sessionstatexmin horizon