You've already forked postgres_exporter
							
							
				mirror of
				https://github.com/prometheus-community/postgres_exporter.git
				synced 2025-11-03 07:53:12 +03:00 
			
		
		
		
	Update pg_long_running_transactions.go (#1092)
To extract time in seconds for pg_long_running_transactions_oldest_timestamp_seconds query which currently return epoch time. Signed-off-by: Jyothi Kiran Thammana <147131742+jyothikirant-sayukth@users.noreply.github.com>
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							a324fe37bc
						
					
				
				
					commit
					6f36adfadf
				
			@@ -52,9 +52,11 @@ var (
 | 
			
		||||
	longRunningTransactionsQuery = `
 | 
			
		||||
	SELECT                                                              
 | 
			
		||||
    COUNT(*) as transactions,
 | 
			
		||||
   		MAX(EXTRACT(EPOCH FROM clock_timestamp())) AS oldest_timestamp_seconds
 | 
			
		||||
    MAX(EXTRACT(EPOCH FROM clock_timestamp() - pg_stat_activity.xact_start)) AS oldest_timestamp_seconds
 | 
			
		||||
FROM pg_catalog.pg_stat_activity
 | 
			
		||||
    WHERE state is distinct from 'idle' AND query not like 'autovacuum:%'
 | 
			
		||||
WHERE state IS DISTINCT FROM 'idle'
 | 
			
		||||
AND query NOT LIKE 'autovacuum:%'
 | 
			
		||||
AND pg_stat_activity.xact_start IS NOT NULL;
 | 
			
		||||
	`
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user