Skip to content

postgresqlreceiver - Include execution time metric into query samples #42429

@sv-splunk

Description

@sv-splunk

Component(s)

receiver/postgresql

Is your feature request related to a problem? Please describe.

The logs collection in PostgreSQL receiver currently does not include execution time of the currently running queries in payload. This needs to be calculated in the collector query itself based on the query_start time.

Describe the solution you'd like

The query execution time for currently running queries can be calculated by the collector query (query_samples) itself with the addition of below logic:

CASE
    WHEN state = 'active' THEN
        EXTRACT(EPOCH FROM (clock_timestamp() - query_start)) * 1e3
    WHEN state IN ('idle','idle in transaction','idle in transaction (aborted)')
        AND state_change IS NOT NULL THEN
        EXTRACT(EPOCH FROM (state_change - query_start)) * 1e3
    ELSE
        NULL
END AS duration_ms

Describe alternatives you've considered

No response

Additional context

No response

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions